public function setUp() { $node = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface'); $node->expects($this->any())->method('getPath')->will($this->returnValue('/foo/bar')); $mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock(); $node->expects($this->any())->method('getContext')->will($this->returnValue($mockContext)); $mockWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock(); $mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($mockWorkspace)); $mockWorkspace->expects($this->any())->method('getName')->will($this->returnValue('user-foo')); $this->queryBuilder = new ElasticSearchQueryBuilder(); $this->queryBuilder->query($node); }
public function setUp() { $node = $this->createMock(NodeInterface::class); $node->expects($this->any())->method('getPath')->will($this->returnValue('/foo/bar')); $mockContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); $mockContext->expects($this->any())->method('getDimensions')->will($this->returnValue([])); $node->expects($this->any())->method('getContext')->will($this->returnValue($mockContext)); $mockWorkspace = $this->getMockBuilder(Workspace::class)->disableOriginalConstructor()->getMock(); $mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($mockWorkspace)); $mockWorkspace->expects($this->any())->method('getName')->will($this->returnValue('user-foo')); $this->queryBuilder = new ElasticSearchQueryBuilder(); $this->queryBuilder->query($node); }
/** * @test */ public function aggregationsCanAdded() { $aggregationTitle = "titleagg"; $result = $this->queryBuilder->query($this->context->getRootNode())->fieldBasedAggregation($aggregationTitle, "title")->execute()->getAggregations(); $this->assertArrayHasKey($aggregationTitle, $result); // assume three results because there are three nodes created with an title set $this->assertCount(3, $result[$aggregationTitle]); }
/** * @param NodeInterface $node * @return \TYPO3\TYPO3CR\Search\Search\QueryBuilderInterface */ public function query(NodeInterface $node) { return parent::query($node); }
/** * @test */ public function nodesWillBeSortedAsc() { $ascendingResult = $this->queryBuilder->query($this->context->getRootNode())->sortAsc("title")->execute(); $node = $ascendingResult->getFirst(); $this->assertEquals("chicken", $node->getProperty("title"), "Asserting a asc sort order by property title"); }