Commit e64ce311 authored by Bas de Nooijer's avatar Bas de Nooijer

Added unittests for new functionality to develop (TDD)

parent 3ea5b8b8
......@@ -231,6 +231,28 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase
);
}
public function testRemovePluginAndGetPluginsWithObjectInput()
{
$options = array('option1' => 1);
$this->_client->registerPlugin('testplugin','MyClientPlugin',$options);
$plugin = $this->_client->getPlugin('testplugin');
$plugins = $this->_client->getPlugins();
$this->assertEquals(
array('testplugin' => $plugin),
$plugins
);
$this->_client->removePlugin($plugin);
$plugins = $this->_client->getPlugins();
$this->assertEquals(
array(),
$plugins
);
}
public function testCreateRequest()
{
$queryStub = $this->getMock('Solarium_Query_Select');
......
......@@ -260,6 +260,25 @@ class Solarium_Query_Select_Component_Facet_MultiQueryTest extends PHPUnit_Frame
);
}
public function testRemoveQueryWithObjectInput()
{
$facetQuery = new Solarium_Query_Select_Component_Facet_Query;
$facetQuery->setKey('k1');
$facetQuery->setQuery('category:1');
$this->_facet->addQuery($facetQuery);
$this->assertEquals(
array('k1' => $facetQuery),
$this->_facet->getQueries()
);
$this->_facet->removeQuery($facetQuery);
$this->assertEquals(
array(),
$this->_facet->getQueries()
);
}
public function testRemoveInvalidQuery()
{
$facetQuery = new Solarium_Query_Select_Component_Facet_Query;
......
......@@ -192,6 +192,24 @@ class Solarium_Query_Select_Component_FacetSetTest extends PHPUnit_Framework_Tes
);
}
public function testRemoveFacetWithObjectInput()
{
$fq1 = new Solarium_Query_Select_Component_Facet_Query;
$fq1->setKey('f1')->setQuery('category:1');
$fq2 = new Solarium_Query_Select_Component_Facet_Query;
$fq2->setKey('f2')->setQuery('category:2');
$facets = array('f1' => $fq1, 'f2' => $fq2);
$this->_facetSet->addFacets($facets);
$this->_facetSet->removeFacet($fq1);
$this->assertEquals(
array('f2' => $fq2),
$this->_facetSet->getFacets()
);
}
public function testRemoveInvalidFacet()
{
$fq1 = new Solarium_Query_Select_Component_Facet_Query;
......
......@@ -287,6 +287,24 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
);
}
public function testRemoveFilterQueryWithObjectInput()
{
$fq1 = new Solarium_Query_Select_FilterQuery;
$fq1->setKey('fq1')->setQuery('category:1');
$fq2 = new Solarium_Query_Select_FilterQuery;
$fq2->setKey('fq2')->setQuery('category:2');
$filterQueries = array($fq1, $fq2);
$this->_query->addFilterQueries($filterQueries);
$this->_query->removeFilterQuery($fq1);
$this->assertEquals(
array('fq2' => $fq2),
$this->_query->getFilterQueries()
);
}
public function testRemoveInvalidFilterQuery()
{
$fq1 = new Solarium_Query_Select_FilterQuery;
......@@ -455,6 +473,24 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
);
}
public function testRemoveComponentWithObjectInput()
{
$mlt = new Solarium_Query_Select_Component_MoreLikeThis;
$this->_query->setComponent('mlt',$mlt);
$this->assertEquals(
array('mlt' => $mlt),
$this->_query->getComponents()
);
$this->_query->removeComponent($mlt);
$this->assertEquals(
array(),
$this->_query->getComponents()
);
}
public function testGetMoreLikeThis()
{
$mlt = $this->_query->getMoreLikeThis();
......
......@@ -185,6 +185,22 @@ class Solarium_Query_UpdateTest extends PHPUnit_Framework_TestCase
);
}
public function testRemoveWithObjectInput()
{
$rollback = new Solarium_Query_Update_Command_Rollback;
$this->_query->add('rb', $rollback);
$commit = new Solarium_Query_Update_Command_Commit;
$this->_query->add('cm', $commit);
$this->_query->remove($rollback);
$this->assertEquals(
array('cm' => $commit),
$this->_query->getCommands()
);
}
public function testRemoveInvalidKey()
{
$rollback = new Solarium_Query_Update_Command_Rollback;
......
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