Add Count and Document SQLite integration tests

This commit is contained in:
2024-06-07 23:35:48 -04:00
parent 9fba3781d6
commit a96fdf9d14
3 changed files with 130 additions and 1 deletions

View File

@@ -0,0 +1,42 @@
<?php declare(strict_types=1);
namespace Test\Integration\SQLite;
use BitBadger\PDODocument\{Count, Field};
use PHPUnit\Framework\TestCase;
class CountTest extends TestCase
{
/** @var string Database name for throwaway database */
private string $dbName;
protected function setUp(): void
{
parent::setUp();
$this->dbName = ThrowawayDb::create();
}
protected function tearDown(): void
{
ThrowawayDb::destroy($this->dbName);
parent::tearDown();
}
public function testAllSucceeds(): void
{
$count = Count::all(ThrowawayDb::TABLE);
$this->assertEquals(5, $count, 'There should have been 5 matching documents');
}
public function testByFieldsSucceedsForANumericRange(): void
{
$count = Count::byFields(ThrowawayDb::TABLE, [Field::BT('num_value', 10, 20)]);
$this->assertEquals(3, $count, 'There should have been 3 matching documents');
}
public function testByFieldsSucceedsForANonNumericRange(): void
{
$count = Count::byFields(ThrowawayDb::TABLE, [Field::BT('value', 'aardvark', 'apple')]);
$this->assertEquals(1, $count, 'There should have been 1 matching document');
}
}