descriptionFactory = new DescriptionFactory(); $this->conditionBuilder = $this->getMockBuilder( '\SMW\Elastic\QueryEngine\ConditionBuilder' ) ->disableOriginalConstructor() ->setMethods( [ 'interpretDescription' ] ) ->getMock(); } public function testCanConstruct() { $this->assertInstanceOf( ConjunctionInterpreter::class, new ConjunctionInterpreter( $this->conditionBuilder ) ); } public function testInterpretDescription_Empty() { $instance = new ConjunctionInterpreter( $this->conditionBuilder ); $condition = $instance->interpretDescription( $this->descriptionFactory->newConjunction( [] ) ); $this->assertEquals( [], $condition ); } public function testInterpretDescription_NotEmpty() { $this->conditionBuilder->expects( $this->any() ) ->method( 'interpretDescription' ) ->willReturn( $this->conditionBuilder->newCondition( [ 'Foo' ] ) ); $description = $this->getMockBuilder( '\SMW\Query\Language\Description' ) ->disableOriginalConstructor() ->getMock(); $description->expects( $this->any() ) ->method( 'getPrintRequests' ) ->willReturn( [] ); $instance = new ConjunctionInterpreter( $this->conditionBuilder ); $condition = $instance->interpretDescription( $this->descriptionFactory->newConjunction( [ $description ] ) ); $this->assertEquals( '{"bool":{"must":[{"bool":{"must":["Foo"]}}]}}', $condition ); } }