_query = new Solarium_Query_Select; $this->_builder = new Solarium_Client_RequestBuilder_Select; } public function testGetMethod() { $request = $this->_builder->build($this->_query); $this->assertEquals( Solarium_Client_Request::METHOD_GET, $request->getMethod() ); } public function testSelectUrlWithDefaultValues() { $request = $this->_builder->build($this->_query); $this->assertEquals( null, $request->getRawData() ); $this->assertEquals( 'select?wt=json&q=*:*&start=0&rows=10&fl=*,score', urldecode($request->getUri()) ); } public function testSelectUrlWithSort() { $this->_query->addSort('id', Solarium_Query_Select::SORT_ASC); $this->_query->addSort('name', Solarium_Query_Select::SORT_DESC); $request = $this->_builder->build($this->_query); $this->assertEquals( null, $request->getRawData() ); $this->assertEquals( 'select?wt=json&q=*:*&start=0&rows=10&fl=*,score&sort=id asc,name desc', urldecode($request->getUri()) ); } public function testSelectUrlWithQueryDefaultFieldAndOperator() { $this->_query->setQueryDefaultField('mydefault'); $this->_query->setQueryDefaultOperator(Solarium_Query_Select::QUERY_OPERATOR_AND); $request = $this->_builder->build($this->_query); $this->assertEquals( null, $request->getRawData() ); $this->assertEquals( 'select?wt=json&q=*:*&start=0&rows=10&fl=*,score&q.op=AND&df=mydefault', urldecode($request->getUri()) ); } public function testSelectUrlWithSortAndFilters() { $this->_query->addSort('id', Solarium_Query_Select::SORT_ASC); $this->_query->addSort('name', Solarium_Query_Select::SORT_DESC); $this->_query->addFilterQuery(new Solarium_Query_Select_FilterQuery(array('key' => 'f1', 'query' => 'published:true'))); $this->_query->addFilterQuery(new Solarium_Query_Select_FilterQuery(array('key' => 'f2', 'tag' => array('t1','t2'), 'query' => 'category:23'))); $request = $this->_builder->build($this->_query); $this->assertEquals( null, $request->getRawData() ); $this->assertEquals( 'select?wt=json&q=*:*&start=0&rows=10&fl=*,score&sort=id asc,name desc&fq=published:true&fq={!tag=t1,t2}category:23', urldecode($request->getUri()) ); } public function testWithComponentNoBuilder() { $request = $this->_builder->build($this->_query); $this->_query->registerComponentType('testcomponent','TestDummyComponent'); $this->_query->getComponent('testcomponent', true); $requestWithNoBuilderComponent = $this->_builder->build($this->_query); $this->assertEquals( $request, $requestWithNoBuilderComponent ); } public function testWithComponent() { $this->_query->getDisMax(); $request = $this->_builder->build($this->_query); $this->assertEquals( 'dismax', $request->getParam('defType') ); } } class TestDummyComponent extends Solarium_Query_Select_Component{ public function getType() { return 'testcomponent'; } }