_parser = new Solarium_Client_ResponseParser_Select_Component_Grouping; $this->_query = new Solarium_Query_Select(); $this->_grouping = $this->_query->getGrouping(); $this->_grouping->addField('fieldA'); $this->_grouping->addQuery('cat:1'); $data = array( 'grouped' => array( 'fieldA' => array( 'matches' => 25, 'ngroups' => 12, 'groups' => array( array( 'groupValue' => 'test value', 'doclist' => array( 'numFound' => 13, 'docs' => array( array('id' => 1, 'name' => 'test') ) ) ) ) ), 'cat:1' => array( 'matches' => 40, 'doclist' => array( 'numFound' => 22, 'docs' => array( array('id' => 2, 'name' => 'dummy2'), array('id' => 5, 'name' => 'dummy5') ) ) ) ) ); $this->_result = $this->_parser->parse($this->_query, $this->_grouping, $data); } public function testGroupParsing() { $this->assertEquals(2, count($this->_result->getGroups())); $fieldGroup = $this->_result->getGroup('fieldA'); $queryGroup = $this->_result->getGroup('cat:1'); $this->assertEquals('Solarium_Result_Select_Grouping_FieldGroup', get_class($fieldGroup)); $this->assertEquals('Solarium_Result_Select_Grouping_QueryGroup', get_class($queryGroup)); } public function testFieldGroupParsing() { $fieldGroup = $this->_result->getGroup('fieldA'); $valueGroups = $fieldGroup->getValueGroups(); $this->assertEquals(25, $fieldGroup->getMatches()); $this->assertEquals(12, $fieldGroup->getNumberOfGroups()); $this->assertEquals(1, count($valueGroups)); $valueGroup = $valueGroups[0]; $this->assertEquals(13, $valueGroup->getNumFound()); $docs = $valueGroup->getDocuments(); $this->assertEquals('test', $docs[0]->name); } public function testQueryGroupParsing() { $queryGroup = $this->_result->getGroup('cat:1'); $this->assertEquals(40, $queryGroup->getMatches()); $this->assertEquals(22, $queryGroup->getNumFound()); $docs = $queryGroup->getDocuments(); $this->assertEquals('dummy5', $docs[1]->name); } public function testParseNoData() { $result = $this->_parser->parse($this->_query, $this->_grouping, array()); $this->assertEquals(array(), $result->getGroups()); } }