Initial SQLite development (#1)
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
31
tests/unit/Query/CountTest.php
Normal file
31
tests/unit/Query/CountTest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Test\Unit\Query;
|
||||
|
||||
use BitBadger\PDODocument\{Configuration, Field, Mode};
|
||||
use BitBadger\PDODocument\Query\Count;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Unit tests for the Count class
|
||||
*/
|
||||
class CountTest extends TestCase
|
||||
{
|
||||
|
||||
public function testAllSucceeds()
|
||||
{
|
||||
$this->assertEquals('SELECT COUNT(*) FROM a_table', Count::all('a_table'),
|
||||
'SELECT statement not generated correctly');
|
||||
}
|
||||
|
||||
public function testByFieldsSucceeds()
|
||||
{
|
||||
Configuration::$mode = Mode::SQLite;
|
||||
try {
|
||||
$this->assertEquals("SELECT COUNT(*) FROM somewhere WHERE data->>'errors' > :errors",
|
||||
Count::byFields('somewhere', [Field::GT('errors', 10, ':errors')]));
|
||||
} finally {
|
||||
Configuration::$mode = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user