Add classes and tests from common project
This commit is contained in:
26
tests/unit/Query/FindTest.php
Normal file
26
tests/unit/Query/FindTest.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Test\Unit\Query;
|
||||
|
||||
use BitBadger\PDODocument\Field;
|
||||
use BitBadger\PDODocument\Query\Find;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Unit tests for the Find class
|
||||
*/
|
||||
class FindTest extends TestCase
|
||||
{
|
||||
public function testByIdSucceeds(): void
|
||||
{
|
||||
$this->assertEquals("SELECT data FROM here WHERE data->>'id' = @id", Find::byId('here'),
|
||||
'SELECT query not generated correctly');
|
||||
}
|
||||
|
||||
public function testByFieldsSucceeds(): void
|
||||
{
|
||||
$this->assertEquals("SELECT data FROM there WHERE data->>'active' = @act OR data->>'locked' = @lock",
|
||||
Find::byFields('there', [Field::EQ('active', true, '@act'), Field::EQ('locked', true, '@lock')], 'OR'),
|
||||
'SELECT query not generated correctly');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user