Commit fd6fe00b authored by Gasol Wu's avatar Gasol Wu

Added shards support unittests

parent a896fb53
......@@ -89,6 +89,29 @@ class Solarium_Client_RequestBuilder_SelectTest extends PHPUnit_Framework_TestCa
);
}
public function testSelectUrlWithShard()
{
$this->_query->addShard('shard1', 'localhost:8983/solr/shard1');
$this->_query->addShards(array(
'shard2' => 'localhost:8983/solr/shard2',
'shard3' => 'localhost:8983/solr/shard3'
));
$this->_query->setShardRequestHandler('dummy');
$request = $this->_builder->build($this->_query);
$this->assertEquals(
null,
$request->getRawData()
);
$this->assertEquals(
'select?q=*:*&start=0&rows=10&fl=*,score&wt=json' .
'&shards=localhost:8983/solr/shard1,localhost:8983/solr/shard2,localhost:8983/solr/shard3' .
'&shards.qt=dummy',
urldecode($request->getUri())
);
}
public function testSelectUrlWithSortAndFilters()
{
$this->_query->addSort('id', Solarium_Query_Select::SORT_ASC);
......@@ -142,4 +165,4 @@ class TestDummyComponent extends Solarium_Query_Select_Component{
{
return 'testcomponent';
}
}
\ No newline at end of file
}
......@@ -209,7 +209,76 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
$this->_query->getSorts()
);
}
public function testAddShard()
{
$this->_query->addShard('shard1', 'localhost:8983/solr/shard1');
$shards = $this->_query->getShards();
$this->assertEquals(
'localhost:8983/solr/shard1',
$shards['shard1']
);
}
public function testRemoveShard()
{
$this->_query->addShard('shard1', 'localhost:8983/solr/shard1');
$this->_query->removeShard('shard1');
$shards = $this->_query->getShards();
$this->assertFalse(isset($shards['shard1']));
}
public function testClearShards()
{
$this->_query->addShards(array(
'shard1' => 'localhost:8983/solr/shard1',
'shard2' => 'localhost:8983/solr/shard2',
));
$this->_query->clearShards();
$shards = $this->_query->getShards();
$this->assertTrue(is_array($shards));
$this->assertEquals(0, count($shards));
}
public function testAddShards()
{
$shards = array(
'shard1' => 'localhost:8983/solr/shard1',
'shard2' => 'localhost:8983/solr/shard2',
);
$this->_query->addShards($shards);
$this->assertEquals($shards, $this->_query->getShards());
}
public function testSetShards()
{
$this->_query->addShards(array(
'shard1' => 'localhost:8983/solr/shard1',
'shard2' => 'localhost:8983/solr/shard2',
));
$this->_query->setShards(array(
'shard3' => 'localhost:8983/solr/shard3',
'shard4' => 'localhost:8983/solr/shard4',
'shard5' => 'localhost:8983/solr/shard5',
));
$shards = $this->_query->getShards();
$this->assertEquals(3, count($shards));
$this->assertEquals(array(
'shard3' => 'localhost:8983/solr/shard3',
'shard4' => 'localhost:8983/solr/shard4',
'shard5' => 'localhost:8983/solr/shard5',
), $shards);
}
public function testSetShardRequestHandler()
{
$this->_query->setShardRequestHandler('dummy');
$this->assertEquals(
'dummy',
$this->_query->getShardRequestHandler()
);
}
public function testAddAndGetFilterQuery()
{
$fq = new Solarium_Query_Select_FilterQuery;
......@@ -581,4 +650,4 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
$fqOptions['optionB']
);
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment