Add in/inArray tests

- Make nameFields void (modifies array by ref)
This commit is contained in:
2024-09-25 20:03:17 -04:00
parent 9a2cf4c204
commit a3ad158dfe
14 changed files with 140 additions and 37 deletions

View File

@@ -349,7 +349,7 @@ class FieldTest extends TestCase
Configuration::overrideMode(Mode::PgSQL);
try {
$field = Field::inArray('even', 'tbl', [2, 4, 6, 8], ':it');
$this->assertEquals("data->'even' ?| ARRAY[:it_0, :it_1, :it_2, :it_3]", $field->toWhere(),
$this->assertEquals("data->'even' ??| ARRAY[:it_0, :it_1, :it_2, :it_3]", $field->toWhere(),
'WHERE fragment not generated correctly');
} finally {
Configuration::overrideMode(null);

View File

@@ -69,7 +69,7 @@ class OpTest extends TestCase
#[TestDox('toSQL() succeeds for InArray')]
public function testToSQLSucceedsForInArray(): void
{
$this->assertEquals('?|', Op::InArray->toSQL(), 'InArray SQL operator incorrect');
$this->assertEquals('??|', Op::InArray->toSQL(), 'InArray SQL operator incorrect');
}
#[TestDox('toSQL() succeeds for Exists')]

View File

@@ -84,8 +84,8 @@ class ParametersTest extends TestCase
#[TestDox('nameFields() succeeds')]
public function testNameFieldsSucceeds(): void
{
$named = Parameters::nameFields(
[Field::equal('it', 17), Field::equal('also', 22, ':also'), Field::equal('other', 24)]);
$named = [Field::equal('it', 17), Field::equal('also', 22, ':also'), Field::equal('other', 24)];
Parameters::nameFields($named);
$this->assertCount(3, $named, 'There should be 3 parameters in the array');
$this->assertEquals(':field0', $named[0]->paramName, 'Parameter 1 not named correctly');
$this->assertEquals(':also', $named[1]->paramName, 'Parameter 2 not named correctly');