1
0
Fork 0
mirror of synced 2024-07-06 07:00:56 +12:00
appwrite/tests/unit/Database/Validator/CustomIdTest.php

42 lines
1.5 KiB
PHP
Raw Normal View History

2021-07-06 19:11:14 +12:00
<?php
namespace Appwrite\Tests;
use Appwrite\Database\Validator\CustomId;
use PHPUnit\Framework\TestCase;
class CustomIdTest extends TestCase
{
/**
* @var Key
*/
protected $object = null;
public function setUp(): void
{
$this->object = new CustomId();
}
public function tearDown(): void
{
}
public function testValues()
{
$this->assertEquals($this->object->isValid('unique()'), true);
$this->assertEquals($this->object->isValid('unique)'), false);
$this->assertEquals($this->object->isValid('else()'), false);
$this->assertEquals($this->object->isValid('dasda asdasd'), false);
$this->assertEquals($this->object->isValid('dasda_asdasd'), true);
$this->assertEquals($this->object->isValid('asdasdasdas'), true);
$this->assertEquals($this->object->isValid('_asdasdasdas'), false);
$this->assertEquals($this->object->isValid('as$$5dasdasdas'), false);
$this->assertEquals($this->object->isValid(false), false);
$this->assertEquals($this->object->isValid(null), false);
2021-08-05 16:17:30 +12:00
$this->assertEquals($this->object->isValid('socialAccountForYoutubeAndRestSubscribers'), false);
$this->assertEquals($this->object->isValid('socialAccountForYoutubeAndRSubscriber'), false);
2021-07-06 19:11:14 +12:00
$this->assertEquals($this->object->isValid('socialAccountForYoutubeSubscribe'), true);
$this->assertEquals($this->object->isValid('socialAccountForYoutubeSubscrib'), true);
}
}