Skip to content
Snippets Groups Projects
Commit 729740b0 authored by Niels Nijens's avatar Niels Nijens
Browse files

Add tests for BoolQuery::getQueries

parent 23913d14
No related branches found
No related tags found
No related merge requests found
......@@ -112,4 +112,54 @@ class BoolQueryTest extends \PHPUnit_Framework_TestCase
];
$this->assertEquals($expected, $bool->toArray());
}
/**
* Tests if BoolQuery::getQueries returns an empty array.
*/
public function testGetQueriesEmpty()
{
$bool = new BoolQuery();
$this->assertInternalType('array', $bool->getQueries());
}
/**
* Tests if BoolQuery::getQueries returns an array with the added queries of all bool types.
*/
public function testGetQueries()
{
$query = new TermQuery('key1', 'value1');
$query2 = new TermQuery('key2', 'value2');
$bool = new BoolQuery();
$bool->add($query, BoolQuery::MUST, 'query');
$bool->add($query2, BoolQuery::SHOULD, 'query2');
$this->assertSame(array('query' => $query, 'query2' => $query2), $bool->getQueries());
}
/**
* Tests if BoolQuery::getQueries with specified bool type returns an empty array.
*/
public function testGetQueriesByBoolTypeEmpty()
{
$bool = new BoolQuery();
$this->assertInternalType('array', $bool->getQueries(BoolQuery::MUST));
}
/**
* Tests if BoolQuery::getQueries with specified bool type returns an array with added queries.
*/
public function testGetQueriesByBoolTypeWithQueryAddedToBoolType()
{
$query = new TermQuery('key1', 'value1');
$query2 = new TermQuery('key2', 'value2');
$bool = new BoolQuery();
$bool->add($query, BoolQuery::MUST, 'query');
$bool->add($query2, BoolQuery::SHOULD, 'query2');
$this->assertSame(array('query' => $query), $bool->getQueries(BoolQuery::MUST));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment