Commit 9b84d58f authored by Bas de Nooijer's avatar Bas de Nooijer

style fix and improved test coverage

parent 80accb1a
......@@ -47,8 +47,7 @@ class Solarium_Client_Response_Select extends Solarium_Client_Response
}
}
foreach ($this->_query->getFacets() AS $facet)
{
foreach ($this->_query->getFacets() AS $facet) {
switch ($facet->getType()) {
case Solarium_Query_Select_Facet::FIELD:
$this->_addFacetField($facet);
......
......@@ -32,48 +32,66 @@
class Solarium_Query_Select_Facet_FieldTest extends PHPUnit_Framework_TestCase
{
protected $_facet;
public function setUp()
{
$this->_facet = new Solarium_Query_Select_Facet_Field;
}
public function testGetType()
{
//TODO
$this->assertEquals(
Solarium_Query_Select_Facet::FIELD,
$this->_facet->getType()
);
}
public function testSetAndGetField()
{
//TODO
$this->_facet->setField('category');
$this->assertEquals('category', $this->_facet->getField());
}
public function testSetAndGetSort()
{
//TODO
$this->_facet->setSort('index');
$this->assertEquals('index', $this->_facet->getSort());
}
public function testSetAndGetPrefix()
{
//TODO
$this->_facet->setPrefix('xyz');
$this->assertEquals('xyz', $this->_facet->getPrefix());
}
public function testSetAndGetLimit()
{
//TODO
$this->_facet->setLimit(12);
$this->assertEquals(12, $this->_facet->getLimit());
}
public function testSetAndGetOffset()
{
//TODO
$this->_facet->setOffset(40);
$this->assertEquals(40, $this->_facet->getOffset());
}
public function testSetAndGetMinCount()
{
//TODO
$this->_facet->setMincount(100);
$this->assertEquals(100, $this->_facet->getMincount());
}
public function testSetAndGetMissing()
{
//TODO
$this->_facet->setMissing(true);
$this->assertEquals(true, $this->_facet->getMissing());
}
public function testSetAndGetMethod()
{
//TODO
$this->_facet->setMethod('enum');
$this->assertEquals('enum', $this->_facet->getMethod());
}
}
......@@ -32,14 +32,26 @@
class Solarium_Query_Select_Facet_QueryTest extends PHPUnit_Framework_TestCase
{
public function testSetAndGetQuery()
protected $_facet;
public function setUp()
{
//TODO
$this->_facet = new Solarium_Query_Select_Facet_Query;
}
public function testGetType()
{
//TODO
$this->assertEquals(
Solarium_Query_Select_Facet::QUERY,
$this->_facet->getType()
);
}
public function testSetAndGetQuery()
{
$this->_facet->setQuery('category:1');
$this->assertEquals('category:1', $this->_facet->getQuery());
}
}
......@@ -32,33 +32,57 @@
class Solarium_Query_Select_FacetTest extends PHPUnit_Framework_TestCase
{
protected $_facet;
public function setUp()
{
$this->_facet = new TestFacet;
}
public function testSetAndGetKey()
{
//TODO
$this->_facet->setKey('testkey');
$this->assertEquals('testkey', $this->_facet->getKey());
}
public function testAddExclude()
{
//TODO
$this->_facet->addExclude('e1');
$this->assertEquals(array('e1'), $this->_facet->getExcludes());
}
public function testAddExcludes()
{
//TODO
$this->_facet->addExcludes(array('e1','e2'));
$this->assertEquals(array('e1','e2'), $this->_facet->getExcludes());
}
public function testRemoveExclude()
{
//TODO
$this->_facet->addExcludes(array('e1','e2'));
$this->_facet->removeExclude('e1');
$this->assertEquals(array('e2'), $this->_facet->getExcludes());
}
public function testClearExcludes()
{
//TODO
$this->_facet->addExcludes(array('e1','e2'));
$this->_facet->clearExcludes();
$this->assertEquals(array(), $this->_facet->getExcludes());
}
public function testSetExcludes()
{
//TODO
$this->_facet->addExcludes(array('e1','e2'));
$this->_facet->addExcludes(array('e3','e4'));
$this->assertEquals(array('e3','e4'), $this->_facet->getExcludes());
}
}
class TestFacet extends Solarium_Query_Select_Facet{
public function getType()
{
return 'test';
}
}
\ No newline at end of file
......@@ -32,38 +32,55 @@
class Solarium_Query_Select_FilterQueryTest extends PHPUnit_Framework_TestCase
{
protected $_filterQuery;
public function setUp()
{
$this->_filterQuery = new Solarium_Query_Select_FilterQuery;
}
public function testSetAndGetKey()
{
//TODO
$this->_filterQuery->setKey('testkey');
$this->assertEquals('testkey', $this->_filterQuery->getKey());
}
public function testSetAndGetQuery()
{
//TODO
$this->_filterQuery->setQuery('category:1');
$this->assertEquals('category:1', $this->_filterQuery->getQuery());
}
public function testAddTag()
{
//TODO
$this->_filterQuery->addTag('testtag');
$this->assertEquals(array('testtag'), $this->_filterQuery->getTags());
}
public function testAddTags()
{
//TODO
$this->_filterQuery->addTags(array('t1','t2'));
$this->assertEquals(array('t1','t2'), $this->_filterQuery->getTags());
}
public function testRemoveTags()
public function testRemoveTag()
{
//TODO
$this->_filterQuery->addTags(array('t1','t2'));
$this->_filterQuery->removeTag('t1');
$this->assertEquals(array('t2'), $this->_filterQuery->getTags());
}
public function testClearTags()
{
//TODO
$this->_filterQuery->addTags(array('t1','t2'));
$this->_filterQuery->clearTags();
$this->assertEquals(array(), $this->_filterQuery->getTags());
}
public function testSetTags()
{
//TODO
$this->_filterQuery->addTags(array('t1','t2'));
$this->_filterQuery->setTags(array('t3','t4'));
$this->assertEquals(array('t3','t4'), $this->_filterQuery->getTags());
}
}
......@@ -57,7 +57,7 @@ class Solarium_Result_Select_Facet_FieldTest extends PHPUnit_Framework_TestCase
public function testIterator()
{
$values = array();
foreach($this->_facet->getValues() AS $key => $value)
foreach($this->_facet AS $key => $value)
{
$values[$key] = $value;
}
......
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