2022-04-04 18:30:07 +12:00
|
|
|
<?php
|
|
|
|
|
2022-08-01 22:22:04 +12:00
|
|
|
namespace Tests\Unit\Event\Validator;
|
2022-04-04 18:30:07 +12:00
|
|
|
|
|
|
|
use Appwrite\Event\Validator\Event;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class EventValidatorTest extends TestCase
|
|
|
|
{
|
|
|
|
protected ?Event $object = null;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
$this->object = new Event();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown(): void
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-08-01 22:22:04 +12:00
|
|
|
public function testValues(): void
|
2022-04-04 18:30:07 +12:00
|
|
|
{
|
2022-04-21 01:34:55 +12:00
|
|
|
/**
|
|
|
|
* Test for SUCCESS
|
|
|
|
*/
|
2022-04-04 18:30:07 +12:00
|
|
|
$this->assertTrue($this->object->isValid('users.*.create'));
|
|
|
|
$this->assertTrue($this->object->isValid('users.torsten.update'));
|
|
|
|
$this->assertTrue($this->object->isValid('users.torsten'));
|
|
|
|
$this->assertTrue($this->object->isValid('users.*.update.email'));
|
|
|
|
$this->assertTrue($this->object->isValid('users.*.update'));
|
|
|
|
$this->assertTrue($this->object->isValid('users.*'));
|
2022-06-22 22:51:49 +12:00
|
|
|
$this->assertTrue($this->object->isValid('databases.books.collections.chapters.documents.prolog.create'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.books.collections.chapters.documents.prolog'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.books.collections.chapters.documents.*.create'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.books.collections.chapters.documents.*'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.books.collections.*.documents.prolog.create'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.books.collections.*.documents.prolog'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.books.collections.*.documents.*.create'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.books.collections.*.documents.*'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.*.collections.chapters.documents.prolog.create'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.*.collections.chapters.documents.prolog'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.*.collections.chapters.documents.*.create'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.*.collections.chapters.documents.*'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.*.collections.*.documents.prolog.create'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.*.collections.*.documents.prolog'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.*.collections.*.documents.*.create'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.*.collections.*.documents.*'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.*.collections.*'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.*'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.books'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.books.collections.chapters'));
|
|
|
|
$this->assertTrue($this->object->isValid('databases.books.collections.*'));
|
2023-09-12 15:56:30 +12:00
|
|
|
$this->assertTrue($this->object->isValid('functions.*'));
|
2022-04-04 18:30:07 +12:00
|
|
|
$this->assertTrue($this->object->isValid('buckets.*'));
|
|
|
|
$this->assertTrue($this->object->isValid('teams.*'));
|
|
|
|
$this->assertTrue($this->object->isValid('users.*'));
|
2022-05-09 02:31:32 +12:00
|
|
|
$this->assertTrue($this->object->isValid('teams.*.memberships.*.update.status'));
|
2022-04-04 18:30:07 +12:00
|
|
|
|
2022-04-21 01:34:55 +12:00
|
|
|
/**
|
|
|
|
* Test for FAILURE
|
|
|
|
*/
|
2022-04-04 18:30:07 +12:00
|
|
|
$this->assertFalse($this->object->isValid(false));
|
|
|
|
$this->assertFalse($this->object->isValid(null));
|
|
|
|
$this->assertFalse($this->object->isValid(''));
|
2022-04-21 01:34:55 +12:00
|
|
|
$this->assertFalse($this->object->isValid('unknown.*'));
|
2022-04-04 18:30:07 +12:00
|
|
|
$this->assertFalse($this->object->isValid('collections'));
|
|
|
|
$this->assertFalse($this->object->isValid('collections.*.unknown'));
|
|
|
|
$this->assertFalse($this->object->isValid('collections.*.documents.*.unknown'));
|
|
|
|
$this->assertFalse($this->object->isValid('users.torsten.unknown'));
|
2022-04-21 01:34:55 +12:00
|
|
|
$this->assertFalse($this->object->isValid('users.torsten.delete.email'));
|
2022-05-09 02:31:32 +12:00
|
|
|
$this->assertFalse($this->object->isValid('teams.*.memberships.*.update.unknown'));
|
2022-04-04 18:30:07 +12:00
|
|
|
}
|
|
|
|
}
|