$dateValidator

This commit is contained in:
fogelito
2022-12-15 10:51:27 +02:00
parent d7a833faef
commit bdc3e9f935
16 changed files with 95 additions and 94 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
stopOnFailure="true"
>
<extensions>
<extension class="Appwrite\Tests\TestHook" />
+3 -4
View File
@@ -9,7 +9,6 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use CURLFile;
use Tests\E2E\Services\Functions\FunctionsBase;
use Utopia\Database\DateTime;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
@@ -642,7 +641,7 @@ class UsageTest extends Scope
$this->assertEquals(202, $deployment['headers']['status-code']);
$this->assertNotEmpty($deployment['body']['$id']);
$this->assertEquals(true, DateTime::isValid($deployment['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($deployment['body']['$createdAt']));
$this->assertEquals('index.php', $deployment['body']['entrypoint']);
// Wait for deployment to build.
@@ -652,8 +651,8 @@ class UsageTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$this->assertEquals(true, DateTime::isValid($response['body']['$updatedAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$updatedAt']));
$this->assertEquals($deploymentId, $response['body']['deployment']);
$execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', $headers, [
+7 -4
View File
@@ -6,6 +6,8 @@ use Appwrite\Tests\Retryable;
use Tests\E2E\Client;
use PHPUnit\Framework\TestCase;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\DatetimeValidator;
use Utopia\Validator;
abstract class Scope extends TestCase
{
@@ -16,10 +18,9 @@ abstract class Scope extends TestCase
*/
protected $client = null;
/**
* @var string
*/
protected $endpoint = 'http://localhost/v1';
protected string $endpoint = 'http://localhost/v1';
public static Validator $dateValidator;
protected function setUp(): void
{
@@ -28,6 +29,8 @@ abstract class Scope extends TestCase
$this->client
->setEndpoint($this->endpoint)
;
self::$dateValidator = new DatetimeValidator();
}
protected function tearDown(): void
+13 -13
View File
@@ -34,7 +34,7 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
@@ -198,7 +198,7 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
@@ -343,7 +343,7 @@ trait AccountBase
$this->assertIsNumeric($response['body']['total']);
$this->assertContains($response['body']['logs'][1]['event'], ["session.create"]);
$this->assertEquals($response['body']['logs'][1]['ip'], filter_var($response['body']['logs'][1]['ip'], FILTER_VALIDATE_IP));
$this->assertEquals(true, DateTime::isValid($response['body']['logs'][1]['time']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['logs'][1]['time']));
$this->assertEquals('Windows', $response['body']['logs'][1]['osName']);
$this->assertEquals('WIN', $response['body']['logs'][1]['osCode']);
@@ -365,7 +365,7 @@ trait AccountBase
$this->assertContains($response['body']['logs'][2]['event'], ["user.create"]);
$this->assertEquals($response['body']['logs'][2]['ip'], filter_var($response['body']['logs'][2]['ip'], FILTER_VALIDATE_IP));
$this->assertEquals(true, DateTime::isValid($response['body']['logs'][2]['time']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['logs'][2]['time']));
$this->assertEquals('Windows', $response['body']['logs'][2]['osName']);
$this->assertEquals('WIN', $response['body']['logs'][2]['osCode']);
@@ -476,7 +476,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $newName);
@@ -543,7 +543,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@@ -633,7 +633,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $newEmail);
/**
@@ -675,7 +675,7 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $data['email']);
$this->assertEquals($response['body']['name'], $data['name']);
@@ -817,7 +817,7 @@ trait AccountBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, DateTime::isValid($response['body']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['expire']));
$lastEmail = $this->getLastEmail();
@@ -1119,7 +1119,7 @@ trait AccountBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, DateTime::isValid($response['body']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['expire']));
$lastEmail = $this->getLastEmail();
@@ -1273,7 +1273,7 @@ trait AccountBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, DateTime::isValid($response['body']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['expire']));
$userId = $response['body']['userId'];
@@ -1379,7 +1379,7 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertTrue($response['body']['emailVerification']);
@@ -1439,7 +1439,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@@ -448,7 +448,7 @@ class AccountCustomClientTest extends Scope
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@@ -699,7 +699,7 @@ class AccountCustomClientTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, DateTime::isValid($response['body']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['expire']));
$userId = $response['body']['userId'];
@@ -799,7 +799,7 @@ class AccountCustomClientTest extends Scope
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['phone'], $number);
$this->assertTrue($response['body']['phoneVerification']);
@@ -850,7 +850,7 @@ class AccountCustomClientTest extends Scope
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@@ -892,7 +892,7 @@ class AccountCustomClientTest extends Scope
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['phone'], $newPhone);
/**
@@ -941,7 +941,7 @@ class AccountCustomClientTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, DateTime::isValid($response['body']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['expire']));
\sleep(2);
@@ -4,7 +4,6 @@ namespace Tests\E2E\Services\Databases;
use Tests\E2E\Client;
use Utopia\Database\Helpers\ID;
use Utopia\Database\DateTime;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
@@ -1531,8 +1530,8 @@ trait DatabasesBase
$this->assertEquals($databaseId, $document['body']['$databaseId']);
$this->assertEquals($document['body']['title'], 'Thor: Ragnaroc');
$this->assertEquals($document['body']['releaseYear'], 2017);
$this->assertEquals(true, DateTime::isValid($document['body']['$createdAt']));
$this->assertEquals(true, DateTime::isValid($document['body']['birthDay']));
$this->assertEquals(true, self::$dateValidator->isValid($document['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($document['body']['birthDay']));
$this->assertContains(Permission::read(Role::user($this->getUser()['$id'])), $document['body']['$permissions']);
$this->assertContains(Permission::update(Role::user($this->getUser()['$id'])), $document['body']['$permissions']);
$this->assertContains(Permission::delete(Role::user($this->getUser()['$id'])), $document['body']['$permissions']);
@@ -45,8 +45,8 @@ class FunctionsCustomServerTest extends Scope
$this->assertNotEmpty($response1['body']['$id']);
$this->assertEquals('Test', $response1['body']['name']);
$this->assertEquals('php-8.0', $response1['body']['runtime']);
$this->assertEquals(true, DateTime::isValid($response1['body']['$createdAt']));
$this->assertEquals(true, DateTime::isValid($response1['body']['$updatedAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response1['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response1['body']['$updatedAt']));
$this->assertEquals('', $response1['body']['deployment']);
$this->assertEquals([
'users.*.create',
@@ -328,8 +328,8 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $response1['headers']['status-code']);
$this->assertNotEmpty($response1['body']['$id']);
$this->assertEquals('Test1', $response1['body']['name']);
$this->assertEquals(true, DateTime::isValid($response1['body']['$createdAt']));
$this->assertEquals(true, DateTime::isValid($response1['body']['$updatedAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response1['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response1['body']['$updatedAt']));
$this->assertEquals('', $response1['body']['deployment']);
$this->assertEquals([
'users.*.update.name',
@@ -369,7 +369,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(202, $deployment['headers']['status-code']);
$this->assertNotEmpty($deployment['body']['$id']);
$this->assertEquals(true, DateTime::isValid($deployment['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($deployment['body']['$createdAt']));
$this->assertEquals('index.php', $deployment['body']['entrypoint']);
// Wait for deployment to build.
@@ -418,7 +418,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(202, $largeTag['headers']['status-code']);
$this->assertNotEmpty($largeTag['body']['$id']);
$this->assertEquals(true, DateTime::isValid($largeTag['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($largeTag['body']['$createdAt']));
$this->assertEquals('index.php', $largeTag['body']['entrypoint']);
$this->assertGreaterThan(10000, $largeTag['body']['size']);
@@ -440,8 +440,8 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$this->assertEquals(true, DateTime::isValid($response['body']['$updatedAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$updatedAt']));
$this->assertEquals($data['deploymentId'], $response['body']['deployment']);
/**
@@ -606,7 +606,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(202, $execution['headers']['status-code']);
$this->assertNotEmpty($execution['body']['$id']);
$this->assertNotEmpty($execution['body']['functionId']);
$this->assertEquals(true, DateTime::isValid($execution['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($execution['body']['$createdAt']));
$this->assertEquals($data['functionId'], $execution['body']['functionId']);
$this->assertEquals('waiting', $execution['body']['status']);
$this->assertEquals(0, $execution['body']['statusCode']);
@@ -623,7 +623,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertNotEmpty($execution['body']['$id']);
$this->assertNotEmpty($execution['body']['functionId']);
$this->assertEquals(true, DateTime::isValid($execution['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($execution['body']['$createdAt']));
$this->assertEquals($data['functionId'], $execution['body']['functionId']);
$this->assertEquals('completed', $execution['body']['status']);
$this->assertEquals(200, $execution['body']['statusCode']);
+5 -5
View File
@@ -52,7 +52,7 @@ trait StorageBase
]);
$this->assertEquals(201, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -120,7 +120,7 @@ trait StorageBase
$this->assertEquals(201, $largeFile['headers']['status-code']);
$this->assertNotEmpty($largeFile['body']['$id']);
$this->assertEquals(true, DateTime::isValid($largeFile['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($largeFile['body']['$createdAt']));
$this->assertEquals('large-file.mp4', $largeFile['body']['name']);
$this->assertEquals('video/mp4', $largeFile['body']['mimeType']);
$this->assertEquals($totalSize, $largeFile['body']['sizeOriginal']);
@@ -283,7 +283,7 @@ trait StorageBase
]);
$this->assertEquals(201, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -373,7 +373,7 @@ trait StorageBase
$this->assertEquals(200, $file1['headers']['status-code']);
$this->assertNotEmpty($file1['body']['$id']);
$this->assertEquals(true, DateTime::isValid($file1['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file1['body']['$createdAt']));
$this->assertEquals('logo.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
$this->assertEquals(47218, $file1['body']['sizeOriginal']);
@@ -712,7 +712,7 @@ trait StorageBase
$this->assertEquals(200, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -63,7 +63,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -159,7 +159,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -245,7 +245,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -370,7 +370,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -548,7 +548,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -710,7 +710,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file1['body']['$id'];
$this->assertEquals($file1['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, DateTime::isValid($file1['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file1['body']['$createdAt']));
$this->assertEquals('permissions.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
$this->assertEquals(47218, $file1['body']['sizeOriginal']);
@@ -799,7 +799,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file1['body']['$id'];
$this->assertEquals($file1['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, DateTime::isValid($file1['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file1['body']['$createdAt']));
$this->assertEquals('permissions.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
$this->assertEquals(47218, $file1['body']['sizeOriginal']);
@@ -888,7 +888,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file1['body']['$id'];
$this->assertEquals($file1['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, DateTime::isValid($file1['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file1['body']['$createdAt']));
$this->assertEquals('permissions.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
$this->assertEquals(47218, $file1['body']['sizeOriginal']);
@@ -1027,7 +1027,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -1262,7 +1262,7 @@ class StorageCustomClientTest extends Scope
$this->assertContains(Permission::read(Role::user($this->getUser()['$id'])), $file['body']['$permissions']);
$this->assertContains(Permission::update(Role::user($this->getUser()['$id'])), $file['body']['$permissions']);
$this->assertContains(Permission::delete(Role::user($this->getUser()['$id'])), $file['body']['$permissions']);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -30,7 +30,7 @@ class StorageCustomServerTest extends Scope
]);
$this->assertEquals(201, $bucket['headers']['status-code']);
$this->assertNotEmpty($bucket['body']['$id']);
$this->assertEquals(true, DateTime::isValid($bucket['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($bucket['body']['$createdAt']));
$this->assertIsArray($bucket['body']['$permissions']);
$this->assertIsArray($bucket['body']['allowedFileExtensions']);
$this->assertEquals('Test Bucket', $bucket['body']['name']);
@@ -228,7 +228,7 @@ class StorageCustomServerTest extends Scope
]);
$this->assertEquals(200, $bucket['headers']['status-code']);
$this->assertNotEmpty($bucket['body']['$id']);
$this->assertEquals(true, DateTime::isValid($bucket['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($bucket['body']['$createdAt']));
$this->assertIsArray($bucket['body']['$permissions']);
$this->assertIsArray($bucket['body']['allowedFileExtensions']);
$this->assertEquals('Test Bucket Updated', $bucket['body']['name']);
+7 -7
View File
@@ -28,7 +28,7 @@ trait TeamsBase
$this->assertEquals('Arsenal', $response1['body']['name']);
$this->assertGreaterThan(-1, $response1['body']['total']);
$this->assertIsInt($response1['body']['total']);
$this->assertEquals(true, DateTime::isValid($response1['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response1['body']['$createdAt']));
$teamUid = $response1['body']['$id'];
$teamName = $response1['body']['name'];
@@ -48,7 +48,7 @@ trait TeamsBase
$this->assertEquals('Manchester United', $response2['body']['name']);
$this->assertGreaterThan(-1, $response2['body']['total']);
$this->assertIsInt($response2['body']['total']);
$this->assertEquals(true, DateTime::isValid($response2['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response2['body']['$createdAt']));
$response3 = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
@@ -63,7 +63,7 @@ trait TeamsBase
$this->assertEquals('Newcastle', $response3['body']['name']);
$this->assertGreaterThan(-1, $response3['body']['total']);
$this->assertIsInt($response3['body']['total']);
$this->assertEquals(true, DateTime::isValid($response3['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response3['body']['$createdAt']));
/**
* Test for FAILURE
*/
@@ -98,7 +98,7 @@ trait TeamsBase
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
/**
* Test for FAILURE
@@ -275,7 +275,7 @@ trait TeamsBase
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$response = $this->client->call(Client::METHOD_PUT, '/teams/' . $response['body']['$id'], array_merge([
'content-type' => 'application/json',
@@ -290,7 +290,7 @@ trait TeamsBase
$this->assertEquals('Demo New', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
/**
* Test for FAILURE
@@ -326,7 +326,7 @@ trait TeamsBase
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamUid, array_merge([
'content-type' => 'application/json',
+5 -5
View File
@@ -150,7 +150,7 @@ trait TeamsBaseClient
$this->assertNotEmpty($response['body']['teamId']);
$this->assertNotEmpty($response['body']['teamName']);
$this->assertCount(2, $response['body']['roles']);
$this->assertEquals(false, DateTime::isValid($response['body']['joined'])); // is null in DB
$this->assertEquals(false, self::$dateValidator->isValid($response['body']['joined'])); // is null in DB
$this->assertEquals(false, $response['body']['confirm']);
/**
@@ -203,7 +203,7 @@ trait TeamsBaseClient
$this->assertNotEmpty($response['body']['teamId']);
$this->assertNotEmpty($response['body']['teamName']);
$this->assertCount(2, $response['body']['roles']);
$this->assertEquals(false, DateTime::isValid($response['body']['joined'])); // is null in DB
$this->assertEquals(false, self::$dateValidator->isValid($response['body']['joined'])); // is null in DB
$this->assertEquals(false, $response['body']['confirm']);
$lastEmail = $this->getLastEmail();
@@ -337,7 +337,7 @@ trait TeamsBaseClient
$this->assertNotEmpty($response['body']['userId']);
$this->assertNotEmpty($response['body']['teamId']);
$this->assertCount(2, $response['body']['roles']);
$this->assertEquals(true, DateTime::isValid($response['body']['joined']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['joined']));
$this->assertEquals(true, $response['body']['confirm']);
$session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
$data['session'] = $session;
@@ -369,7 +369,7 @@ trait TeamsBaseClient
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
@@ -403,7 +403,7 @@ trait TeamsBaseClient
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
+4 -4
View File
@@ -57,7 +57,7 @@ trait TeamsBaseServer
$this->assertNotEmpty($response['body']['teamId']);
$this->assertNotEmpty($response['body']['teamName']);
$this->assertCount(2, $response['body']['roles']);
$this->assertEquals(true, DateTime::isValid($response['body']['joined'])); // is null in DB
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['joined'])); // is null in DB
$this->assertEquals(true, $response['body']['confirm']);
/**
@@ -108,7 +108,7 @@ trait TeamsBaseServer
$this->assertEquals($email, $response['body']['userEmail']);
$this->assertNotEmpty($response['body']['teamId']);
$this->assertCount(2, $response['body']['roles']);
$this->assertEquals(true, DateTime::isValid($response['body']['joined']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['joined']));
$this->assertEquals(true, $response['body']['confirm']);
$userUid = $response['body']['userId'];
@@ -252,7 +252,7 @@ trait TeamsBaseServer
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertEquals(1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
/** Delete User */
$user = $this->client->call(Client::METHOD_DELETE, '/users/' . $userUid, array_merge([
@@ -277,6 +277,6 @@ trait TeamsBaseServer
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertEquals(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
}
}
+8 -8
View File
@@ -529,7 +529,7 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertIsArray($webhook['data']['$permissions']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertEquals(true, DateTime::isValid($webhook['data']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@@ -587,7 +587,7 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertIsArray($webhook['data']['$permissions']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertEquals(true, DateTime::isValid($webhook['data']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@@ -637,7 +637,7 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertIsArray($webhook['data']['$permissions']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertEquals(true, DateTime::isValid($webhook['data']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@@ -719,7 +719,7 @@ trait WebhooksBase
$this->assertEquals('Arsenal', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
/**
* Test for FAILURE
@@ -764,7 +764,7 @@ trait WebhooksBase
$this->assertEquals('Demo New', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
/**
* Test for FAILURE
@@ -813,7 +813,7 @@ trait WebhooksBase
$this->assertEquals('Chelsea', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
/**
* Test for FAILURE
@@ -874,7 +874,7 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['teamId']);
$this->assertCount(2, $webhook['data']['roles']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['invited']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['invited']));
$this->assertEquals(('server' === $this->getSide()), $webhook['data']['confirm']);
/**
@@ -946,7 +946,7 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['teamId']);
$this->assertCount(2, $webhook['data']['roles']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['invited']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['invited']));
$this->assertEquals(('server' === $this->getSide()), $webhook['data']['confirm']);
}
}
@@ -60,7 +60,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id']), true);
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $name);
$this->assertEquals(true, DateTime::isValid($webhook['data']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['registration']));
$this->assertEquals($webhook['data']['status'], true);
$this->assertEquals($webhook['data']['email'], $email);
$this->assertEquals($webhook['data']['emailVerification'], false);
@@ -136,7 +136,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $name);
$this->assertEquals(true, DateTime::isValid($webhook['data']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['registration']));
$this->assertEquals($webhook['data']['status'], false);
$this->assertEquals($webhook['data']['email'], $email);
$this->assertEquals($webhook['data']['emailVerification'], false);
@@ -196,7 +196,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id']), true);
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$this->assertEquals($webhook['data']['ip'], '127.0.0.1');
$this->assertNotEmpty($webhook['data']['osCode']);
$this->assertIsString($webhook['data']['osCode']);
@@ -371,7 +371,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$this->assertEquals($webhook['data']['ip'], '127.0.0.1');
$this->assertNotEmpty($webhook['data']['osCode']);
$this->assertIsString($webhook['data']['osCode']);
@@ -683,7 +683,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$data['secret'] = $webhook['data']['secret'];
@@ -743,7 +743,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$data['secret'] = $webhook['data']['secret'];
@@ -799,7 +799,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$data['secret'] = $webhook['data']['secret'];
@@ -857,7 +857,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['expire']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$data['secret'] = $webhook['data']['secret'];
@@ -920,7 +920,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['teamId']);
$this->assertCount(2, $webhook['data']['roles']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['joined']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['joined']));
$this->assertEquals(true, $webhook['data']['confirm']);
/**
@@ -245,7 +245,7 @@ class WebhooksCustomServerTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $name);
$this->assertEquals(true, DateTime::isValid($webhook['data']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['registration']));
$this->assertEquals($webhook['data']['status'], true);
$this->assertEquals($webhook['data']['email'], $email);
$this->assertEquals($webhook['data']['emailVerification'], false);
@@ -336,7 +336,7 @@ class WebhooksCustomServerTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $data['name']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['registration']));
$this->assertEquals($webhook['data']['status'], false);
$this->assertEquals($webhook['data']['email'], $data['email']);
$this->assertEquals($webhook['data']['emailVerification'], false);
@@ -378,7 +378,7 @@ class WebhooksCustomServerTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $data['name']);
$this->assertEquals(true, DateTime::isValid($webhook['data']['registration']));
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['registration']));
$this->assertEquals($webhook['data']['status'], false);
$this->assertEquals($webhook['data']['email'], $data['email']);
$this->assertEquals($webhook['data']['emailVerification'], false);