Add in/inArray; expand Field ctr func names
This commit is contained in:
@@ -18,121 +18,123 @@ use PHPUnit\Framework\TestCase;
|
||||
#[TestDox('Field (Unit tests)')]
|
||||
class FieldTest extends TestCase
|
||||
{
|
||||
#[TestDox('Append parameter succeeds for EX')]
|
||||
public function testAppendParameterSucceedsForEX(): void
|
||||
public function testAppendParameterSucceedsForExists(): void
|
||||
{
|
||||
$this->assertEquals([], Field::EX('exists')->appendParameter([]), 'EX should not have appended a parameter');
|
||||
$this->assertEquals([], Field::exists('exists')->appendParameter([]),
|
||||
'exists should not have appended a parameter');
|
||||
}
|
||||
|
||||
#[TestDox('Append parameter succeeds for NEX')]
|
||||
public function testAppendParameterSucceedsForNEX(): void
|
||||
#[TestDox('Append parameter succeeds for notExists')]
|
||||
public function testAppendParameterSucceedsForNotExists(): void
|
||||
{
|
||||
$this->assertEquals([], Field::NEX('absent')->appendParameter([]), 'NEX should not have appended a parameter');
|
||||
$this->assertEquals([], Field::notExists('absent')->appendParameter([]),
|
||||
'notExists should not have appended a parameter');
|
||||
}
|
||||
|
||||
#[TestDox('Append parameter succeeds for BT')]
|
||||
public function testAppendParameterSucceedsForBT(): void
|
||||
public function testAppendParameterSucceedsForBetween(): void
|
||||
{
|
||||
$this->assertEquals(['@nummin' => 5, '@nummax' => 9], Field::BT('exists', 5, 9, '@num')->appendParameter([]),
|
||||
$this->assertEquals(['@nummin' => 5, '@nummax' => 9],
|
||||
Field::between('exists', 5, 9, '@num')->appendParameter([]),
|
||||
'BT should have appended min and max parameters');
|
||||
}
|
||||
|
||||
public function testAppendParameterSucceedsForOthers(): void
|
||||
{
|
||||
$this->assertEquals(['@test' => 33], Field::EQ('the_field', 33, '@test')->appendParameter([]),
|
||||
$this->assertEquals(['@test' => 33], Field::equal('the_field', 33, '@test')->appendParameter([]),
|
||||
'Field parameter not returned correctly');
|
||||
}
|
||||
|
||||
#[TestDox('To where succeeds for EX without qualifier for PostgreSQL')]
|
||||
public function testToWhereSucceedsForEXWithoutQualifierForPostgreSQL(): void
|
||||
#[TestDox('To where succeeds for exists without qualifier for PostgreSQL')]
|
||||
public function testToWhereSucceedsForExistsWithoutQualifierForPostgreSQL(): void
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
try {
|
||||
$this->assertEquals("data->>'that_field' IS NOT NULL", Field::EX('that_field')->toWhere(),
|
||||
$this->assertEquals("data->>'that_field' IS NOT NULL", Field::exists('that_field')->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
Configuration::overrideMode(null);
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('To where succeeds for EX without qualifier for SQLite')]
|
||||
public function testToWhereSucceedsForEXWithoutQualifierForSQLite(): void
|
||||
#[TestDox('To where succeeds for exists without qualifier for SQLite')]
|
||||
public function testToWhereSucceedsForExistsWithoutQualifierForSQLite(): void
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
try {
|
||||
$this->assertEquals("data->>'that_field' IS NOT NULL", Field::EX('that_field')->toWhere(),
|
||||
$this->assertEquals("data->>'that_field' IS NOT NULL", Field::exists('that_field')->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
Configuration::overrideMode(null);
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('To where succeeds for NEX without qualifier for PostgreSQL')]
|
||||
public function testToWhereSucceedsForNEXWithoutQualifierForPostgreSQL(): void
|
||||
#[TestDox('To where succeeds for notExists without qualifier for PostgreSQL')]
|
||||
public function testToWhereSucceedsForNotExistsWithoutQualifierForPostgreSQL(): void
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
try {
|
||||
$this->assertEquals("data->>'a_field' IS NULL", Field::NEX('a_field')->toWhere(),
|
||||
$this->assertEquals("data->>'a_field' IS NULL", Field::notExists('a_field')->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
Configuration::overrideMode(null);
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('To where succeeds for NEX without qualifier for SQLite')]
|
||||
public function testToWhereSucceedsForNEXWithoutQualifierForSQLite(): void
|
||||
#[TestDox('To where succeeds for notExists without qualifier for SQLite')]
|
||||
public function testToWhereSucceedsForNotExistsWithoutQualifierForSQLite(): void
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
try {
|
||||
$this->assertEquals("data->>'a_field' IS NULL", Field::NEX('a_field')->toWhere(),
|
||||
$this->assertEquals("data->>'a_field' IS NULL", Field::notExists('a_field')->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
Configuration::overrideMode(null);
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('To where succeeds for BT without qualifier for SQLite')]
|
||||
public function testToWhereSucceedsForBTWithoutQualifierForSQLite(): void
|
||||
#[TestDox('To where succeeds for between without qualifier for SQLite')]
|
||||
public function testToWhereSucceedsForBetweenWithoutQualifierForSQLite(): void
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
try {
|
||||
$this->assertEquals("data->>'age' BETWEEN @agemin AND @agemax", Field::BT('age', 13, 17, '@age')->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
$this->assertEquals("data->>'age' BETWEEN @agemin AND @agemax",
|
||||
Field::between('age', 13, 17, '@age')->toWhere(), 'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
Configuration::overrideMode(null);
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('To where succeeds for BT without qualifier for PostgreSQL with numeric range')]
|
||||
public function testToWhereSucceedsForBTWithoutQualifierForPostgreSQLWithNumericRange(): void
|
||||
#[TestDox('To where succeeds for between without qualifier for PostgreSQL with numeric range')]
|
||||
public function testToWhereSucceedsForBetweenWithoutQualifierForPostgreSQLWithNumericRange(): void
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
try {
|
||||
$this->assertEquals("(data->>'age')::numeric BETWEEN @agemin AND @agemax",
|
||||
Field::BT('age', 13, 17, '@age')->toWhere(), 'WHERE fragment not generated correctly');
|
||||
Field::between('age', 13, 17, '@age')->toWhere(), 'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
Configuration::overrideMode(null);
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('To where succeeds for BT without qualifier for PostgreSQL with non-numeric range')]
|
||||
public function testToWhereSucceedsForBTWithoutQualifierForPostgreSQLWithNonNumericRange(): void
|
||||
#[TestDox('To where succeeds for between without qualifier for PostgreSQL with non-numeric range')]
|
||||
public function testToWhereSucceedsForBetweenWithoutQualifierForPostgreSQLWithNonNumericRange(): void
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
try {
|
||||
$this->assertEquals("data->>'city' BETWEEN :citymin AND :citymax",
|
||||
Field::BT('city', 'Atlanta', 'Chicago', ':city')->toWhere(), 'WHERE fragment not generated correctly');
|
||||
Field::between('city', 'Atlanta', 'Chicago', ':city')->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
Configuration::overrideMode(null);
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('To where succeeds for BT with qualifier for SQLite')]
|
||||
public function testToWhereSucceedsForBTWithQualifierForSQLite(): void
|
||||
#[TestDox('To where succeeds for between with qualifier for SQLite')]
|
||||
public function testToWhereSucceedsForBetweenWithQualifierForSQLite(): void
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
try {
|
||||
$field = Field::BT('age', 13, 17, '@age');
|
||||
$field = Field::between('age', 13, 17, '@age');
|
||||
$field->qualifier = 'me';
|
||||
$this->assertEquals("me.data->>'age' BETWEEN @agemin AND @agemax", $field->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
@@ -141,12 +143,12 @@ class FieldTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('To where succeeds for BT with qualifier for PostgreSQL with numeric range')]
|
||||
public function testToWhereSucceedsForBTWithQualifierForPostgreSQLWithNumericRange(): void
|
||||
#[TestDox('To where succeeds for between with qualifier for PostgreSQL with numeric range')]
|
||||
public function testToWhereSucceedsForBetweenWithQualifierForPostgreSQLWithNumericRange(): void
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
try {
|
||||
$field = Field::BT('age', 13, 17, '@age');
|
||||
$field = Field::between('age', 13, 17, '@age');
|
||||
$field->qualifier = 'me';
|
||||
$this->assertEquals("(me.data->>'age')::numeric BETWEEN @agemin AND @agemax", $field->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
@@ -155,12 +157,12 @@ class FieldTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('To where succeeds for BT with qualifier for PostgreSQL with non-numeric range')]
|
||||
public function testToWhereSucceedsForBTWithQualifierForPostgreSQLWithNonNumericRange(): void
|
||||
#[TestDox('To where succeeds for between with qualifier for PostgreSQL with non-numeric range')]
|
||||
public function testToWhereSucceedsForBetweenWithQualifierForPostgreSQLWithNonNumericRange(): void
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
try {
|
||||
$field = Field::BT('city', 'Atlanta', 'Chicago', ':city');
|
||||
$field = Field::between('city', 'Atlanta', 'Chicago', ':city');
|
||||
$field->qualifier = 'me';
|
||||
$this->assertEquals("me.data->>'city' BETWEEN :citymin AND :citymax", $field->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
@@ -174,7 +176,7 @@ class FieldTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
try {
|
||||
$this->assertEquals("data->>'some_field' = @value", Field::EQ('some_field', '', '@value')->toWhere(),
|
||||
$this->assertEquals("data->>'some_field' = @value", Field::equal('some_field', '', '@value')->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
Configuration::overrideMode(null);
|
||||
@@ -186,7 +188,7 @@ class FieldTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
try {
|
||||
$this->assertEquals("data->>'some_field' = @value", Field::EQ('some_field', '', '@value')->toWhere(),
|
||||
$this->assertEquals("data->>'some_field' = @value", Field::equal('some_field', '', '@value')->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
Configuration::overrideMode(null);
|
||||
@@ -198,7 +200,7 @@ class FieldTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
try {
|
||||
$field = Field::EX('no_field');
|
||||
$field = Field::exists('no_field');
|
||||
$field->qualifier = 'test';
|
||||
$this->assertEquals("test.data->>'no_field' IS NOT NULL", $field->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
@@ -212,7 +214,7 @@ class FieldTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
try {
|
||||
$field = Field::EX('no_field');
|
||||
$field = Field::exists('no_field');
|
||||
$field->qualifier = 'test';
|
||||
$this->assertEquals("test.data->>'no_field' IS NOT NULL", $field->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
@@ -226,7 +228,7 @@ class FieldTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
try {
|
||||
$field = Field::LE('le_field', 18, '@it');
|
||||
$field = Field::lessOrEqual('le_field', 18, '@it');
|
||||
$field->qualifier = 'q';
|
||||
$this->assertEquals("(q.data->>'le_field')::numeric <= @it", $field->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
@@ -240,7 +242,7 @@ class FieldTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
try {
|
||||
$field = Field::LE('le_field', 18, '@it');
|
||||
$field = Field::lessOrEqual('le_field', 18, '@it');
|
||||
$field->qualifier = 'q';
|
||||
$this->assertEquals("q.data->>'le_field' <= @it", $field->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
@@ -254,7 +256,7 @@ class FieldTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::PgSQL);
|
||||
try {
|
||||
$field = Field::EQ('sub.foo.bar', 22, '@it');
|
||||
$field = Field::equal('sub.foo.bar', 22, '@it');
|
||||
$this->assertEquals("(data#>>'{sub,foo,bar}')::numeric = @it", $field->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
@@ -267,7 +269,7 @@ class FieldTest extends TestCase
|
||||
{
|
||||
Configuration::overrideMode(Mode::SQLite);
|
||||
try {
|
||||
$field = Field::EQ('sub.foo.bar', 22, '@it');
|
||||
$field = Field::equal('sub.foo.bar', 22, '@it');
|
||||
$this->assertEquals("data->>'sub'->>'foo'->>'bar' = @it", $field->toWhere(),
|
||||
'WHERE fragment not generated correctly');
|
||||
} finally {
|
||||
@@ -275,178 +277,178 @@ class FieldTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('EQ succeeds without parameter')]
|
||||
public function testEQSucceedsWithoutParameter(): void
|
||||
#[TestDox('equal succeeds without parameter')]
|
||||
public function testEqualSucceedsWithoutParameter(): void
|
||||
{
|
||||
$field = Field::EQ('my_test', 9);
|
||||
$field = Field::equal('my_test', 9);
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('my_test', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::EQ, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::Equal, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(9, $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('', $field->paramName, 'Parameter name should have been blank');
|
||||
}
|
||||
|
||||
#[TestDox('EQ succeeds with parameter')]
|
||||
public function testEQSucceedsWithParameter(): void
|
||||
#[TestDox('equal succeeds with parameter')]
|
||||
public function testEqualSucceedsWithParameter(): void
|
||||
{
|
||||
$field = Field::EQ('another_test', 'turkey', '@test');
|
||||
$field = Field::equal('another_test', 'turkey', '@test');
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('another_test', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::EQ, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::Equal, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals('turkey', $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('@test', $field->paramName, 'Parameter name not filled correctly');
|
||||
}
|
||||
|
||||
#[TestDox('GT succeeds without parameter')]
|
||||
public function testGTSucceedsWithoutParameter(): void
|
||||
#[TestDox('greater succeeds without parameter')]
|
||||
public function testGreaterSucceedsWithoutParameter(): void
|
||||
{
|
||||
$field = Field::GT('your_test', 4);
|
||||
$field = Field::greater('your_test', 4);
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('your_test', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::GT, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::Greater, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(4, $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('', $field->paramName, 'Parameter name should have been blank');
|
||||
}
|
||||
|
||||
#[TestDox('GT succeeds with parameter')]
|
||||
public function testGTSucceedsWithParameter(): void
|
||||
#[TestDox('greater succeeds with parameter')]
|
||||
public function testGreaterSucceedsWithParameter(): void
|
||||
{
|
||||
$field = Field::GT('more_test', 'chicken', '@value');
|
||||
$field = Field::greater('more_test', 'chicken', '@value');
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('more_test', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::GT, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::Greater, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals('chicken', $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('@value', $field->paramName, 'Parameter name not filled correctly');
|
||||
}
|
||||
|
||||
#[TestDox('GE succeeds without parameter')]
|
||||
public function testGESucceedsWithoutParameter(): void
|
||||
#[TestDox('greaterOrEqual succeeds without parameter')]
|
||||
public function testGreaterOrEqualSucceedsWithoutParameter(): void
|
||||
{
|
||||
$field = Field::GE('their_test', 6);
|
||||
$field = Field::greaterOrEqual('their_test', 6);
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('their_test', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::GE, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::GreaterOrEqual, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(6, $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('', $field->paramName, 'Parameter name should have been blank');
|
||||
}
|
||||
|
||||
#[TestDox('GE succeeds with parameter')]
|
||||
public function testGESucceedsWithParameter(): void
|
||||
#[TestDox('greaterOrEqual succeeds with parameter')]
|
||||
public function testGreaterOrEqualSucceedsWithParameter(): void
|
||||
{
|
||||
$field = Field::GE('greater_test', 'poultry', '@cluck');
|
||||
$field = Field::greaterOrEqual('greater_test', 'poultry', '@cluck');
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('greater_test', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::GE, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::GreaterOrEqual, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals('poultry', $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('@cluck', $field->paramName, 'Parameter name not filled correctly');
|
||||
}
|
||||
|
||||
#[TestDox('LT succeeds without parameter')]
|
||||
public function testLTSucceedsWithoutParameter(): void
|
||||
#[TestDox('less succeeds without parameter')]
|
||||
public function testLessSucceedsWithoutParameter(): void
|
||||
{
|
||||
$field = Field::LT('z', 32);
|
||||
$field = Field::less('z', 32);
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('z', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::LT, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::Less, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(32, $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('', $field->paramName, 'Parameter name should have been blank');
|
||||
}
|
||||
|
||||
#[TestDox('LT succeeds with parameter')]
|
||||
public function testLTSucceedsWithParameter(): void
|
||||
#[TestDox('less succeeds with parameter')]
|
||||
public function testLessSucceedsWithParameter(): void
|
||||
{
|
||||
$field = Field::LT('additional_test', 'fowl', '@boo');
|
||||
$field = Field::less('additional_test', 'fowl', '@boo');
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('additional_test', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::LT, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::Less, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals('fowl', $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('@boo', $field->paramName, 'Parameter name not filled correctly');
|
||||
}
|
||||
|
||||
#[TestDox('LE succeeds without parameter')]
|
||||
public function testLESucceedsWithoutParameter(): void
|
||||
#[TestDox('lessOrEqual succeeds without parameter')]
|
||||
public function testLessOrEqualSucceedsWithoutParameter(): void
|
||||
{
|
||||
$field = Field::LE('g', 87);
|
||||
$field = Field::lessOrEqual('g', 87);
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('g', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::LE, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::LessOrEqual, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(87, $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('', $field->paramName, 'Parameter name should have been blank');
|
||||
}
|
||||
|
||||
#[TestDox('LE succeeds with parameter')]
|
||||
public function testLESucceedsWithParameter(): void
|
||||
#[TestDox('lessOrEqual succeeds with parameter')]
|
||||
public function testLessOrEqualSucceedsWithParameter(): void
|
||||
{
|
||||
$field = Field::LE('lesser_test', 'hen', '@woo');
|
||||
$field = Field::lessOrEqual('lesser_test', 'hen', '@woo');
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('lesser_test', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::LE, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::LessOrEqual, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals('hen', $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('@woo', $field->paramName, 'Parameter name not filled correctly');
|
||||
}
|
||||
|
||||
#[TestDox('NE succeeds without parameter')]
|
||||
public function testNESucceedsWithoutParameter(): void
|
||||
#[TestDox('notEqual succeeds without parameter')]
|
||||
public function testNotEqualSucceedsWithoutParameter(): void
|
||||
{
|
||||
$field = Field::NE('j', 65);
|
||||
$field = Field::notEqual('j', 65);
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('j', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::NE, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::NotEqual, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(65, $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('', $field->paramName, 'Parameter name should have been blank');
|
||||
}
|
||||
|
||||
#[TestDox('NE succeeds with parameter')]
|
||||
public function testNESucceedsWithParameter(): void
|
||||
#[TestDox('notEqual succeeds with parameter')]
|
||||
public function testNotEqualSucceedsWithParameter(): void
|
||||
{
|
||||
$field = Field::NE('unequal_test', 'egg', '@zoo');
|
||||
$field = Field::notEqual('unequal_test', 'egg', '@zoo');
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('unequal_test', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::NE, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::NotEqual, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals('egg', $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('@zoo', $field->paramName, 'Parameter name not filled correctly');
|
||||
}
|
||||
|
||||
#[TestDox('BT succeeds without parameter')]
|
||||
public function testBTSucceedsWithoutParameter(): void
|
||||
#[TestDox('between succeeds without parameter')]
|
||||
public function testBetweenSucceedsWithoutParameter(): void
|
||||
{
|
||||
$field = Field::BT('k', 'alpha', 'zed');
|
||||
$field = Field::between('k', 'alpha', 'zed');
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('k', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::BT, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::Between, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(['alpha', 'zed'], $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('', $field->paramName, 'Parameter name should have been blank');
|
||||
}
|
||||
|
||||
#[TestDox('BT succeeds with parameter')]
|
||||
public function testBTSucceedsWithParameter(): void
|
||||
#[TestDox('between succeeds with parameter')]
|
||||
public function testBetweenSucceedsWithParameter(): void
|
||||
{
|
||||
$field = Field::BT('between_test', 18, 49, '@count');
|
||||
$field = Field::between('between_test', 18, 49, '@count');
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('between_test', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::BT, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::Between, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals([18, 49], $field->value, 'Value not filled correctly');
|
||||
$this->assertEquals('@count', $field->paramName, 'Parameter name not filled correctly');
|
||||
}
|
||||
|
||||
#[TestDox('EX succeeds')]
|
||||
public function testEXSucceeds(): void
|
||||
#[TestDox('exists succeeds')]
|
||||
public function testExistsSucceeds(): void
|
||||
{
|
||||
$field = Field::EX('be_there');
|
||||
$field = Field::exists('be_there');
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('be_there', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::EX, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::Exists, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals('', $field->value, 'Value should have been blank');
|
||||
$this->assertEquals('', $field->paramName, 'Parameter name should have been blank');
|
||||
}
|
||||
|
||||
#[TestDox('NEX succeeds')]
|
||||
public function testNEXSucceeds(): void
|
||||
#[TestDox('notExists succeeds')]
|
||||
public function testNotExistsSucceeds(): void
|
||||
{
|
||||
$field = Field::NEX('be_absent');
|
||||
$field = Field::notExists('be_absent');
|
||||
$this->assertNotNull($field, 'The field should not have been null');
|
||||
$this->assertEquals('be_absent', $field->fieldName, 'Field name not filled correctly');
|
||||
$this->assertEquals(Op::NEX, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals(Op::NotExists, $field->op, 'Operation not filled correctly');
|
||||
$this->assertEquals('', $field->value, 'Value should have been blank');
|
||||
$this->assertEquals('', $field->paramName, 'Parameter name should have been blank');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user