Skip to content

Commit

Permalink
EZP-24274: tests: introduced separate methods for Field search target…
Browse files Browse the repository at this point in the history
… values
  • Loading branch information
pspanja committed Apr 30, 2015
1 parent 9500fba commit 655f489
Showing 1 changed file with 72 additions and 40 deletions.
112 changes: 72 additions & 40 deletions Repository/Tests/FieldType/SearchBaseIntegrationTest.php
Expand Up @@ -50,6 +50,12 @@
* as Content One, and Content Two. See the descriptions of the abstract declarations of
* these methods for more details on how to choose proper values.
*
* If needed you can override the methods that provide Field criterion target value and
* which by default fall back to the methods mentioned above:
*
* - getSearchTargetValueOne()
* - getValidSearchValueTwo()
*
* Note: this test case does not concern itself with testing field filters, behaviour
* of multiple sort clauses or combination with other criteria. These are tested
* elsewhere as a general field search cases, which enables keeping this test case
Expand All @@ -72,6 +78,19 @@ abstract class SearchBaseIntegrationTest extends BaseIntegrationTest
*/
abstract protected function getValidSearchValueOne();

/**
* Get search target field value One.
*
* Returns the Field criterion target value for the field value One.
* Default implementation falls back on {@link getValidSearchValueOne}.
*
* @return mixed
*/
protected function getSearchTargetValueOne()
{
return $this->getValidSearchValueOne();
}

/**
* Get search field value Two.
*
Expand All @@ -87,6 +106,19 @@ abstract protected function getValidSearchValueOne();
*/
abstract protected function getValidSearchValueTwo();

/**
* Get search target field value Two.
*
* Returns the Field criterion target value for the field value Two.
* Default implementation falls back on {@link getValidSearchValueTwo}.
*
* @return mixed
*/
protected function getSearchTargetValueTwo()
{
return $this->getValidSearchValueTwo();
}

/**
* Creates and returns content with given $fieldData
*
Expand Down Expand Up @@ -131,7 +163,7 @@ public function criteriaProvider()
// value EQ One
//
// The result should contain Content One.
new Field( "data", Operator::EQ, $this->getValidSearchValueOne() ),
new Field( "data", Operator::EQ, $this->getSearchTargetValueOne() ),
true,
false,
),
Expand All @@ -143,7 +175,7 @@ public function criteriaProvider()
// NOT( value EQ One )
//
// The result should contain Content Two.
new LogicalNot( new Field( "data", Operator::EQ, $this->getValidSearchValueOne() ) ),
new LogicalNot( new Field( "data", Operator::EQ, $this->getSearchTargetValueOne() ) ),
false,
true,
),
Expand All @@ -155,7 +187,7 @@ public function criteriaProvider()
// value EQ Two
//
// The result should contain Content Two.
new Field( "data", Operator::EQ, $this->getValidSearchValueTwo() ),
new Field( "data", Operator::EQ, $this->getSearchTargetValueTwo() ),
false,
true,
),
Expand All @@ -167,7 +199,7 @@ public function criteriaProvider()
// NOT( value EQ Two )
//
// The result should contain Content One.
new LogicalNot( new Field( "data", Operator::EQ, $this->getValidSearchValueTwo() ) ),
new LogicalNot( new Field( "data", Operator::EQ, $this->getSearchTargetValueTwo() ) ),
true,
false,
),
Expand All @@ -179,7 +211,7 @@ public function criteriaProvider()
// value IN [One]
//
// The result should contain Content One.
new Field( "data", Operator::IN, array( $this->getValidSearchValueOne() ) ),
new Field( "data", Operator::IN, array( $this->getSearchTargetValueOne() ) ),
true,
false,
),
Expand All @@ -192,7 +224,7 @@ public function criteriaProvider()
//
// The result should contain Content Two.
new LogicalNot(
new Field( "data", Operator::IN, array( $this->getValidSearchValueOne() ) )
new Field( "data", Operator::IN, array( $this->getSearchTargetValueOne() ) )
),
false,
true,
Expand All @@ -205,7 +237,7 @@ public function criteriaProvider()
// value IN [Two]
//
// The result should contain Content Two.
new Field( "data", Operator::IN, array( $this->getValidSearchValueTwo() ) ),
new Field( "data", Operator::IN, array( $this->getSearchTargetValueTwo() ) ),
false,
true,
),
Expand All @@ -218,7 +250,7 @@ public function criteriaProvider()
//
// The result should contain Content One.
new LogicalNot(
new Field( "data", Operator::IN, array( $this->getValidSearchValueTwo() ) )
new Field( "data", Operator::IN, array( $this->getSearchTargetValueTwo() ) )
),
true,
false,
Expand All @@ -235,8 +267,8 @@ public function criteriaProvider()
"data",
Operator::IN,
array(
$this->getValidSearchValueOne(),
$this->getValidSearchValueTwo(),
$this->getSearchTargetValueOne(),
$this->getSearchTargetValueTwo(),
)
),
true,
Expand All @@ -255,8 +287,8 @@ public function criteriaProvider()
"data",
Operator::IN,
array(
$this->getValidSearchValueOne(),
$this->getValidSearchValueTwo(),
$this->getSearchTargetValueOne(),
$this->getSearchTargetValueTwo(),
)
)
),
Expand All @@ -271,7 +303,7 @@ public function criteriaProvider()
// value GT One
//
// The result should contain Content Two.
new Field( "data", Operator::GT, $this->getValidSearchValueOne() ),
new Field( "data", Operator::GT, $this->getSearchTargetValueOne() ),
false,
true,
),
Expand All @@ -283,7 +315,7 @@ public function criteriaProvider()
// NOT( value GT One )
//
// The result should contain Content One.
new LogicalNot( new Field( "data", Operator::GT, $this->getValidSearchValueOne() ) ),
new LogicalNot( new Field( "data", Operator::GT, $this->getSearchTargetValueOne() ) ),
true,
false,
),
Expand All @@ -295,7 +327,7 @@ public function criteriaProvider()
// value GT Two
//
// The result should be empty.
new Field( "data", Operator::GT, $this->getValidSearchValueTwo() ),
new Field( "data", Operator::GT, $this->getSearchTargetValueTwo() ),
false,
false,
),
Expand All @@ -307,7 +339,7 @@ public function criteriaProvider()
// NOT( value GT Two )
//
// The result should contain both Content One and Content Two.
new LogicalNot( new Field( "data", Operator::GT, $this->getValidSearchValueTwo() ) ),
new LogicalNot( new Field( "data", Operator::GT, $this->getSearchTargetValueTwo() ) ),
true,
true,
),
Expand All @@ -319,7 +351,7 @@ public function criteriaProvider()
// value GTE One
//
// The result should contain both Content One and Content Two.
new Field( "data", Operator::GTE, $this->getValidSearchValueOne() ),
new Field( "data", Operator::GTE, $this->getSearchTargetValueOne() ),
true,
true,
),
Expand All @@ -331,7 +363,7 @@ public function criteriaProvider()
// NOT( value GTE One )
//
// The result should be empty.
new LogicalNot( new Field( "data", Operator::GTE, $this->getValidSearchValueOne() ) ),
new LogicalNot( new Field( "data", Operator::GTE, $this->getSearchTargetValueOne() ) ),
false,
false,
),
Expand All @@ -343,7 +375,7 @@ public function criteriaProvider()
// value GTE Two
//
// The result should contain Content Two.
new Field( "data", Operator::GTE, $this->getValidSearchValueTwo() ),
new Field( "data", Operator::GTE, $this->getSearchTargetValueTwo() ),
false,
true,
),
Expand All @@ -355,7 +387,7 @@ public function criteriaProvider()
// NOT( value GTE Two )
//
// The result should contain Content One.
new LogicalNot( new Field( "data", Operator::GTE, $this->getValidSearchValueTwo() ) ),
new LogicalNot( new Field( "data", Operator::GTE, $this->getSearchTargetValueTwo() ) ),
true,
false,
),
Expand All @@ -367,7 +399,7 @@ public function criteriaProvider()
// value LT One
//
// The result should be empty.
new Field( "data", Operator::LT, $this->getValidSearchValueOne() ),
new Field( "data", Operator::LT, $this->getSearchTargetValueOne() ),
false,
false,
),
Expand All @@ -379,7 +411,7 @@ public function criteriaProvider()
// NOT( value LT One )
//
// The result should contain both Content One and Content Two.
new LogicalNot( new Field( "data", Operator::LT, $this->getValidSearchValueOne() ) ),
new LogicalNot( new Field( "data", Operator::LT, $this->getSearchTargetValueOne() ) ),
true,
true,
),
Expand All @@ -391,7 +423,7 @@ public function criteriaProvider()
// value LT Two
//
// The result should contain Content One.
new Field( "data", Operator::LT, $this->getValidSearchValueTwo() ),
new Field( "data", Operator::LT, $this->getSearchTargetValueTwo() ),
true,
false,
),
Expand All @@ -403,7 +435,7 @@ public function criteriaProvider()
// NOT( value LT Two )
//
// The result should contain Content Two.
new LogicalNot( new Field( "data", Operator::LT, $this->getValidSearchValueTwo() ) ),
new LogicalNot( new Field( "data", Operator::LT, $this->getSearchTargetValueTwo() ) ),
false,
true,
),
Expand All @@ -415,7 +447,7 @@ public function criteriaProvider()
// value LTE One
//
// The result should contain Content One.
new Field( "data", Operator::LTE, $this->getValidSearchValueOne() ),
new Field( "data", Operator::LTE, $this->getSearchTargetValueOne() ),
true,
false,
),
Expand All @@ -427,7 +459,7 @@ public function criteriaProvider()
// NOT( value LTE One )
//
// The result should contain Content Two.
new LogicalNot( new Field( "data", Operator::LTE, $this->getValidSearchValueOne() ) ),
new LogicalNot( new Field( "data", Operator::LTE, $this->getSearchTargetValueOne() ) ),
false,
true,
),
Expand All @@ -439,7 +471,7 @@ public function criteriaProvider()
// value LTE Two
//
// The result should contain both Content One and Content Two.
new Field( "data", Operator::LTE, $this->getValidSearchValueTwo() ),
new Field( "data", Operator::LTE, $this->getSearchTargetValueTwo() ),
true,
true,
),
Expand All @@ -451,7 +483,7 @@ public function criteriaProvider()
// NOT( value LTE Two )
//
// The result should be empty.
new LogicalNot( new Field( "data", Operator::LTE, $this->getValidSearchValueTwo() ) ),
new LogicalNot( new Field( "data", Operator::LTE, $this->getSearchTargetValueTwo() ) ),
false,
false,
),
Expand All @@ -467,8 +499,8 @@ public function criteriaProvider()
"data",
Operator::BETWEEN,
array(
$this->getValidSearchValueOne(),
$this->getValidSearchValueTwo(),
$this->getSearchTargetValueOne(),
$this->getSearchTargetValueTwo(),
)
),
true,
Expand All @@ -487,8 +519,8 @@ public function criteriaProvider()
"data",
Operator::BETWEEN,
array(
$this->getValidSearchValueOne(),
$this->getValidSearchValueTwo(),
$this->getSearchTargetValueOne(),
$this->getSearchTargetValueTwo(),
)
)
),
Expand All @@ -507,8 +539,8 @@ public function criteriaProvider()
"data",
Operator::BETWEEN,
array(
$this->getValidSearchValueTwo(),
$this->getValidSearchValueOne(),
$this->getSearchTargetValueTwo(),
$this->getSearchTargetValueOne(),
)
),
false,
Expand All @@ -527,8 +559,8 @@ public function criteriaProvider()
"data",
Operator::BETWEEN,
array(
$this->getValidSearchValueTwo(),
$this->getValidSearchValueOne(),
$this->getSearchTargetValueTwo(),
$this->getSearchTargetValueOne(),
)
)
),
Expand All @@ -543,7 +575,7 @@ public function criteriaProvider()
// value CONTAINS One
//
// The result should contain Content One.
new Field( "data", Operator::CONTAINS, $this->getValidSearchValueOne() ),
new Field( "data", Operator::CONTAINS, $this->getSearchTargetValueOne() ),
true,
false,
),
Expand All @@ -555,7 +587,7 @@ public function criteriaProvider()
// NOT( value CONTAINS One )
//
// The result should contain Content Two.
new LogicalNot( new Field( "data", Operator::CONTAINS, $this->getValidSearchValueOne() ) ),
new LogicalNot( new Field( "data", Operator::CONTAINS, $this->getSearchTargetValueOne() ) ),
false,
true,
),
Expand All @@ -567,7 +599,7 @@ public function criteriaProvider()
// value CONTAINS Two
//
// The result should contain Content Two.
new Field( "data", Operator::CONTAINS, $this->getValidSearchValueTwo() ),
new Field( "data", Operator::CONTAINS, $this->getSearchTargetValueTwo() ),
false,
true,
),
Expand All @@ -580,7 +612,7 @@ public function criteriaProvider()
//
// The result should contain Content One.
new LogicalNot(
new Field( "data", Operator::CONTAINS, $this->getValidSearchValueTwo() )
new Field( "data", Operator::CONTAINS, $this->getSearchTargetValueTwo() )
),
true,
false,
Expand Down

0 comments on commit 655f489

Please sign in to comment.