Update testdox for integration tests

This commit is contained in:
2024-09-22 22:13:51 -04:00
parent 91bf3128c5
commit 9a2cf4c204
20 changed files with 192 additions and 75 deletions

View File

@@ -34,6 +34,7 @@ class CustomTest extends TestCase
ThrowawayDb::destroy($this->dbName);
}
#[TestDox('runQuery() succeeds with a valid query')]
public function testRunQuerySucceedsWithAValidQuery(): void
{
$stmt = &Custom::runQuery('SELECT data FROM ' . ThrowawayDb::TABLE . ' LIMIT 1', []);
@@ -44,6 +45,7 @@ class CustomTest extends TestCase
}
}
#[TestDox('runQuery() fails with an invalid query')]
public function testRunQueryFailsWithAnInvalidQuery(): void
{
$this->expectException(DocumentException::class);
@@ -55,6 +57,7 @@ class CustomTest extends TestCase
}
}
#[TestDox('list() succeeds when data is found')]
public function testListSucceedsWhenDataIsFound(): void
{
$list = Custom::list(Query::selectFromTable(ThrowawayDb::TABLE), [], new DocumentMapper(TestDocument::class));
@@ -64,6 +67,7 @@ class CustomTest extends TestCase
$this->assertEquals(5, $count, 'There should have been 5 documents in the list');
}
#[TestDox('list() succeeds when no data is found')]
public function testListSucceedsWhenNoDataIsFound(): void
{
$list = Custom::list(
@@ -73,6 +77,7 @@ class CustomTest extends TestCase
$this->assertFalse($list->hasItems(), 'There should have been no documents in the list');
}
#[TestDox('array() succeeds when data is found')]
public function testArraySucceedsWhenDataIsFound(): void
{
$array = Custom::array(Query::selectFromTable(ThrowawayDb::TABLE) . " WHERE data->>'sub' IS NOT NULL", [],
@@ -81,6 +86,7 @@ class CustomTest extends TestCase
$this->assertCount(2, $array, 'There should have been 2 documents in the array');
}
#[TestDox('array() succeeds when no data is found')]
public function testArraySucceedsWhenNoDataIsFound(): void
{
$array = Custom::array(Query::selectFromTable(ThrowawayDb::TABLE) . " WHERE data->>'value' = :value",
@@ -89,6 +95,7 @@ class CustomTest extends TestCase
$this->assertCount(0, $array, 'There should have been no documents in the array');
}
#[TestDox('single() succeeds when a row is found')]
public function testSingleSucceedsWhenARowIsFound(): void
{
$doc = Custom::single('SELECT data FROM ' . ThrowawayDb::TABLE . " WHERE data->>'id' = :id", [':id' => 'one'],
@@ -97,6 +104,7 @@ class CustomTest extends TestCase
$this->assertEquals('one', $doc->get()->id, 'The incorrect document was returned');
}
#[TestDox('single() succeeds when a row is not found')]
public function testSingleSucceedsWhenARowIsNotFound(): void
{
$doc = Custom::single('SELECT data FROM ' . ThrowawayDb::TABLE . " WHERE data->>'id' = :id",
@@ -104,6 +112,7 @@ class CustomTest extends TestCase
$this->assertTrue($doc->isNone(), 'There should not have been a document returned');
}
#[TestDox('nonQuery() succeeds when operating on data')]
public function testNonQuerySucceedsWhenOperatingOnData(): void
{
Custom::nonQuery('DELETE FROM ' . ThrowawayDb::TABLE, []);
@@ -111,6 +120,7 @@ class CustomTest extends TestCase
$this->assertEquals(0, $remaining, 'There should be no documents remaining in the table');
}
#[TestDox('nonQuery() succeeds when no data matches WHERE clause')]
public function testNonQuerySucceedsWhenNoDataMatchesWhereClause(): void
{
Custom::nonQuery('DELETE FROM ' . ThrowawayDb::TABLE . " WHERE (data->>'num_value')::numeric > :value",
@@ -119,6 +129,7 @@ class CustomTest extends TestCase
$this->assertEquals(5, $remaining, 'There should be 5 documents remaining in the table');
}
#[TestDox('scalar() succeeds')]
public function testScalarSucceeds(): void
{
$value = Custom::scalar("SELECT 5 AS it", [], new CountMapper());