*/ class QueryCriterionTest extends \oat\search\test\UnitTestHelper { /** * * @var QueryCriterion */ protected $instance; public function setUp() { $this->instance = new \oat\search\QueryCriterion; } public function testSetGetName() { $fixtureName = 'text'; $this->assertSame($this->instance, $this->instance->setName($fixtureName)); $this->assertSame($fixtureName, $this->instance->getName()); } public function testSetGetOperator() { $fixtureOperator = 'contain'; $this->assertSame($this->instance, $this->instance->setOperator($fixtureOperator)); $this->assertSame($fixtureOperator, $this->instance->getOperator()); } public function testSetGetValue() { $fixtureValue = 'christophe'; $this->assertSame($this->instance, $this->instance->setValue($fixtureValue)); $this->assertSame($fixtureValue, $this->instance->getValue()); } public function testAddGetAnd() { $fixtureValue = 'christophe'; $fixtureOperator = 'equal'; $this->assertSame($this->instance, $this->instance->addAnd($fixtureValue , $fixtureOperator)); $and = $this->instance->getAnd(); $this->assertSame($fixtureValue, $and[0]->getValue()); $this->assertSame($fixtureOperator, $and[0]->getOperator()); } public function testAddGetOr() { $fixtureValue = 'christophe'; $fixtureOperator = 'equal'; $this->assertSame($this->instance, $this->instance->addOr($fixtureValue , $fixtureOperator)); $or = $this->instance->getOr(); $this->assertSame($fixtureValue, $or[0]->getValue()); $this->assertSame($fixtureOperator, $or[0]->getOperator()); } public function setDefaultOperatorProvider() { return [ ['equal' , 'contain' ,'contain'], ['equal' , null ,'equal'], ]; } /** * @dataProvider setDefaultOperatorProvider * @param string $defaultOperator * @param string|null $operator * @param string $expected */ public function testSetDefaultOperator($defaultOperator , $operator , $expected) { $this->setInaccessibleProperty($this->instance, 'operator', $defaultOperator); $this->assertSame($expected, $this->invokeProtectedMethod($this->instance,'setDefaultOperator' , [$operator])); } public function tearDown() { $this->instance = null; } }