/** * Test if "setSort" method of Elastica query has been called. */ public function testExecuteWithSort() { $this->finder->expects($this->once())->method('createPaginatorAdapter'); $this->proxyQuery->setSortBy(null, $this->fieldMapping)->setSortOrder('DESC'); $this->proxyQuery->execute(); $queryReflection = new \ReflectionClass($this->proxyQuery); $queryProperty = $queryReflection->getProperty('query'); $queryProperty->setAccessible(true); $this->assertEquals(array('name' => array('order' => 'desc')), $queryProperty->getValue($this->proxyQuery)->getParam('sort')); }