mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-07-06 21:11:30 -07:00
Updated tests to use random (md5 of unixtime) space names
This commit is contained in:
parent
c0b1a43141
commit
bdd06aa0b7
3 changed files with 15 additions and 19 deletions
|
@ -8,6 +8,7 @@ use SpacesAPI\Spaces;
|
||||||
|
|
||||||
class FileTest extends TestCase
|
class FileTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private static $tempSpaceName;
|
||||||
private static $space;
|
private static $space;
|
||||||
private static $file;
|
private static $file;
|
||||||
|
|
||||||
|
@ -19,18 +20,15 @@ class FileTest extends TestCase
|
||||||
|
|
||||||
$spaces = new Spaces($_ENV['SPACES_KEY'], $_ENV['SPACES_SECRET']);
|
$spaces = new Spaces($_ENV['SPACES_KEY'], $_ENV['SPACES_SECRET']);
|
||||||
|
|
||||||
try {
|
self::$tempSpaceName = md5(time());
|
||||||
$spaces->space('spaces-api-test')->destroy();
|
|
||||||
} catch (SpaceDoesntExistException $e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$space = $spaces->create('spaces-api-test');
|
self::$space = $spaces->create(self::$tempSpaceName);
|
||||||
self::$file = self::$space->uploadText('Lorem ipsum', 'lorem-ipsum.txt');
|
self::$file = self::$space->uploadText('Lorem ipsum', 'lorem-ipsum.txt');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tearDownAfterClass(): void
|
public static function tearDownAfterClass(): void
|
||||||
{
|
{
|
||||||
(new Spaces($_ENV['SPACES_KEY'], $_ENV['SPACES_SECRET']))->space('spaces-api-test')->destroy();
|
self::$space->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCanUpdatePrivacy()
|
public function testCanUpdatePrivacy()
|
||||||
|
|
|
@ -9,6 +9,7 @@ use SpacesAPI\Spaces;
|
||||||
|
|
||||||
class SpaceTest extends TestCase
|
class SpaceTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private static $tempSpaceName;
|
||||||
private static $space;
|
private static $space;
|
||||||
|
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
|
@ -19,17 +20,14 @@ class SpaceTest extends TestCase
|
||||||
|
|
||||||
$spaces = new Spaces($_ENV['SPACES_KEY'], $_ENV['SPACES_SECRET']);
|
$spaces = new Spaces($_ENV['SPACES_KEY'], $_ENV['SPACES_SECRET']);
|
||||||
|
|
||||||
try {
|
self::$tempSpaceName = md5(time());
|
||||||
$spaces->space('spaces-api-test')->destroy();
|
|
||||||
} catch (SpaceDoesntExistException $e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$space = $spaces->create('spaces-api-test');
|
self::$space = $spaces->create(self::$tempSpaceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tearDownAfterClass(): void
|
public static function tearDownAfterClass(): void
|
||||||
{
|
{
|
||||||
// (new Spaces($_ENV['SPACES_KEY'], $_ENV['SPACES_SECRET']))->space('spaces-api-test')->destroy();
|
self::$space->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCanUpdateSpacePrivacy()
|
public function testCanUpdateSpacePrivacy()
|
||||||
|
|
|
@ -10,21 +10,21 @@ use SpacesAPI\Spaces;
|
||||||
|
|
||||||
class SpacesTest extends TestCase
|
class SpacesTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private static $tempSpaceName;
|
||||||
|
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
{
|
{
|
||||||
$dotenv = Dotenv::createImmutable(__DIR__ . "/..");
|
$dotenv = Dotenv::createImmutable(__DIR__ . "/..");
|
||||||
$dotenv->load();
|
$dotenv->load();
|
||||||
$dotenv->required(['SPACES_KEY', 'SPACES_SECRET']);
|
$dotenv->required(['SPACES_KEY', 'SPACES_SECRET']);
|
||||||
|
|
||||||
try {
|
// This should hopefully always be unique amongst all DO spaces
|
||||||
(new Spaces($_ENV['SPACES_KEY'], $_ENV['SPACES_SECRET']))->space('spaces-api-test')->destroy();
|
self::$tempSpaceName = md5(time());
|
||||||
} catch (SpaceDoesntExistException $e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tearDownAfterClass(): void
|
public static function tearDownAfterClass(): void
|
||||||
{
|
{
|
||||||
(new Spaces($_ENV['SPACES_KEY'], $_ENV['SPACES_SECRET']))->space('spaces-api-test')->destroy();
|
(new Spaces($_ENV['SPACES_KEY'], $_ENV['SPACES_SECRET']))->space(self::$tempSpaceName)->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAuthenticationCanFail()
|
public function testAuthenticationCanFail()
|
||||||
|
@ -53,7 +53,7 @@ class SpacesTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testCanCreateSpace(Spaces $spaces)
|
public function testCanCreateSpace(Spaces $spaces)
|
||||||
{
|
{
|
||||||
$space = $spaces->create('spaces-api-test');
|
$space = $spaces->create(self::$tempSpaceName);
|
||||||
$this->assertInstanceOf(Space::class, $space);
|
$this->assertInstanceOf(Space::class, $space);
|
||||||
|
|
||||||
return $space;
|
return $space;
|
||||||
|
@ -69,7 +69,7 @@ class SpacesTest extends TestCase
|
||||||
|
|
||||||
$spaceFound = false;
|
$spaceFound = false;
|
||||||
foreach ($list as $name => $space) {
|
foreach ($list as $name => $space) {
|
||||||
if ($name == 'spaces-api-test' && $space->getName() == 'spaces-api-test') {
|
if ($name == self::$tempSpaceName && $space->getName() == self::$tempSpaceName) {
|
||||||
$spaceFound = true;
|
$spaceFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue