Changes for beta10 (#5)

- Add In/InArray support
- Add ORDER BY support for `Find` functions
- Update dependencies
- Implement fixes identified via static analysis

Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
2024-09-27 02:15:00 +00:00
parent 9e0e663811
commit d067f8983f
66 changed files with 1728 additions and 664 deletions

View File

@@ -18,6 +18,7 @@ use PHPUnit\Framework\TestCase;
#[TestDox('Array Mapper (Unit tests)')]
class ArrayMapperTest extends TestCase
{
#[TestDox('map() succeeds')]
public function testMapSucceeds(): void
{
$result = ['one' => 2, 'three' => 4, 'eight' => 'five'];

View File

@@ -18,6 +18,7 @@ use PHPUnit\Framework\TestCase;
#[TestDox('Count Mapper (Unit tests)')]
class CountMapperTest extends TestCase
{
#[TestDox('map() succeeds')]
public function testMapSucceeds(): void
{
$this->assertEquals(5, (new CountMapper())->map([5, 8, 10]), 'Count not correct');

View File

@@ -44,7 +44,7 @@ class DocumentMapperTest extends TestCase
$this->assertEquals('json', $mapper->fieldName, 'Field name not recorded correctly');
}
#[TestDox('Map succeeds with valid JSON')]
#[TestDox('map() succeeds with valid JSON')]
public function testMapSucceedsWithValidJSON(): void
{
$doc = (new DocumentMapper(TestDocument::class))->map(['data' => '{"id":7,"subDoc":{"id":22,"name":"tester"}}']);
@@ -55,7 +55,7 @@ class DocumentMapperTest extends TestCase
$this->assertEquals('tester', $doc->subDoc->name, 'Sub-document name not filled correctly');
}
#[TestDox('Map succeeds with valid JSON for pjson class')]
#[TestDox('map() succeeds with valid JSON for Pjson class')]
public function testMapSucceedsWithValidJSONForPjsonClass(): void
{
$doc = (new DocumentMapper(PjsonDocument::class))->map(['data' => '{"id":"seven","name":"bob","num_value":8}']);
@@ -66,14 +66,14 @@ class DocumentMapperTest extends TestCase
$this->assertFalse(isset($doc->skipped), 'Non-JSON field has not been set');
}
#[TestDox('Map fails with invalid JSON')]
#[TestDox('map() fails with invalid JSON')]
public function testMapFailsWithInvalidJSON(): void
{
$this->expectException(DocumentException::class);
(new DocumentMapper(TestDocument::class))->map(['data' => 'this is not valid']);
}
#[TestDox('Map fails with invalid JSON for pjson class')]
#[TestDox('map() fails with invalid JSON for Pjson class')]
public function testMapFailsWithInvalidJSONForPjsonClass(): void
{
$this->expectException(DocumentException::class);

View File

@@ -19,7 +19,7 @@ use PHPUnit\Framework\TestCase;
#[TestDox('Exists Mapper (Unit tests)')]
class ExistsMapperTest extends TestCase
{
#[TestDox('Map succeeds for PostgreSQL')]
#[TestDox('map() succeeds for PostgreSQL')]
public function testMapSucceedsForPostgreSQL(): void
{
try {
@@ -30,7 +30,7 @@ class ExistsMapperTest extends TestCase
}
}
#[TestDox('Map succeeds for SQLite')]
#[TestDox('map() succeeds for SQLite')]
public function testMapSucceedsForSQLite(): void
{
try {
@@ -41,6 +41,7 @@ class ExistsMapperTest extends TestCase
}
}
#[TestDox('map() fails when mode not set')]
public function testMapFailsWhenModeNotSet(): void
{
$this->expectException(DocumentException::class);

View File

@@ -18,21 +18,24 @@ use PHPUnit\Framework\TestCase;
#[TestDox('String Mapper (Unit tests)')]
class StringMapperTest extends TestCase
{
public function testMapSucceedsWhenFieldIsPresentAndString()
#[TestDox('map() succeeds when field is present and string')]
public function testMapSucceedsWhenFieldIsPresentAndString(): void
{
$result = ['test_field' => 'test_value'];
$mapper = new StringMapper('test_field');
$this->assertEquals('test_value', $mapper->map($result), 'String value not returned correctly');
}
public function testMapSucceedsWhenFieldIsPresentAndNotString()
#[TestDox('map() succeeds when field is present and not string')]
public function testMapSucceedsWhenFieldIsPresentAndNotString(): void
{
$result = ['a_number' => 6.7];
$mapper = new StringMapper('a_number');
$this->assertEquals('6.7', $mapper->map($result), 'Number value not returned correctly');
}
public function testMapSucceedsWhenFieldIsNotPresent()
#[TestDox('map() succeeds when field is not present')]
public function testMapSucceedsWhenFieldIsNotPresent(): void
{
$mapper = new StringMapper('something_else');
$this->assertNull($mapper->map([]), 'Missing value not returned correctly');