pdo-document/tests/unit/Query/CountTest.php

27 lines
666 B
PHP
Raw Normal View History

<?php declare(strict_types=1);
namespace Test\Unit\Query;
use BitBadger\PDODocument\Field;
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()
{
2024-06-05 00:59:24 +00:00
$this->assertEquals("SELECT COUNT(*) FROM somewhere WHERE data->>'errors' > :errors",
Count::byFields('somewhere', [Field::GT('errors', 10, ':errors')]));
}
}