assertTrue(method_exists(TermNode::class, '__toString'), 'Class does not have method __toString'); $node = new TermNode('foo'); $this->assertEquals('', (string) $node); $node_with_context = new TermNode('foo', new Context('bar')); $this->assertEquals('', (string) $node_with_context); } public function testQueryBuild() { $query_context = $this->prophesize(QueryContext::class); $query_context ->getLocalizedFields() ->willReturn(['foo.fr', 'foo.en']); $query_context ->getAllowedPrivateFields() ->willReturn([]); $query_context ->getFields() ->willReturn(['foo']); $node = new TermNode('bar'); $node->setConcepts([ new Concept('/baz'), new Concept('/qux'), ]); $query = $node->buildQuery($query_context->reveal()); $expected = '{ "bool": { "should": [{ "multi_match": { "fields": ["concept_path.foo"], "query": "/baz" } }, { "multi_match": { "fields": ["concept_path.foo"], "query": "/qux" } }] } }'; $this->assertEquals(json_decode($expected, true), $query); } }