1
0
Fork 0
mirror of synced 2024-10-03 19:53:33 +13:00

Unit test SelectTest.php

This commit is contained in:
fogelito 2023-03-23 16:33:11 +02:00
parent 6539f15178
commit 671888d975

View file

@ -3,7 +3,10 @@
namespace Tests\Unit\Utopia\Database\Validator\Query;
use Appwrite\Utopia\Database\Validator\Query\Base;
use Appwrite\Utopia\Database\Validator\Query\Order;
use Appwrite\Utopia\Database\Validator\Query\Select;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Query;
use PHPUnit\Framework\TestCase;
@ -16,7 +19,15 @@ class SelectTest extends TestCase
public function setUp(): void
{
$this->validator = new Select();
$this->validator = new Select(
attributes: [
new Document([
'key' => 'attr',
'type' => Database::VAR_STRING,
'array' => false,
]),
],
);
}
public function tearDown(): void
@ -26,7 +37,7 @@ class SelectTest extends TestCase
public function testValue(): void
{
// Test for Success
$this->assertEquals($this->validator->isValid(Query::select(['*', 'attr1', 'attr2', 'collection.id'])), true, $this->validator->getDescription());
$this->assertEquals($this->validator->isValid(Query::select(['*', 'attr'])), true, $this->validator->getDescription());
// Test for Failure
$this->assertEquals($this->validator->isValid(Query::limit(1)), false, $this->validator->getDescription());