diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
commit | a2190ac74dd4d7080b12bab90e552d7aa81209ef (patch) | |
tree | 8b31f38de9882d18df54cf8d9e0de74167a094eb /vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php | |
parent | 15e69f7b20b6596b9148030acce5b59993b95a45 (diff) | |
parent | 257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff) |
Merge branch 'mw-1.26'
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php index 16b7e07b..178c803e 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php @@ -1,61 +1,48 @@ <?php - namespace Elastica\Test\Query; use Elastica\Document; use Elastica\Filter\Term; -use Elastica\Index; -use Elastica\Query\Match; use Elastica\Query; +use Elastica\Query\Match; use Elastica\Test\Base as BaseTest; class PostFilterTest extends BaseTest { - /** - * @var Index - */ - protected $_index; - - protected function setUp() + protected function _getTestIndex() { - parent::setUp(); - $this->_index = $this->_createIndex("query"); + $index = $this->_createIndex(); $docs = array( - new Document("1", array("color" => "green", "make" => "ford")), - new Document("2", array("color" => "blue", "make" => "volvo")), - new Document("3", array("color" => "red", "make" => "ford")), - new Document("4", array("color" => "green", "make" => "renault")), + new Document(1, array('color' => 'green', 'make' => 'ford')), + new Document(2, array('color' => 'blue', 'make' => 'volvo')), + new Document(3, array('color' => 'red', 'make' => 'ford')), + new Document(4, array('color' => 'green', 'make' => 'renault')), ); - $this->_index->getType("test")->addDocuments($docs); - $this->_index->refresh(); + $index->getType('test')->addDocuments($docs); + $index->refresh(); + return $index; } - protected function tearDown() - { - parent::tearDown(); - if ($this->_index instanceof Index) { - $this->_index->delete(); - } - } - + /** + * @group unit + */ public function testToArray() { $query = new Query(); $post_filter = new Term(array('color' => 'green')); - $query->setPostFilter($post_filter->toArray()); + $query->setPostFilter($post_filter); $data = $query->toArray(); $this->assertArrayHasKey('post_filter', $data); $this->assertEquals(array('term' => array('color' => 'green')), $data['post_filter']); - - $query->setPostFilter(array()); - - $this->assertArrayNotHasKey('post_filter', $query->toArray()); } + /** + * @group functional + */ public function testQuery() { $query = new Query(); @@ -68,16 +55,10 @@ class PostFilterTest extends BaseTest $filter = new Term(); $filter->setTerm('color', 'green'); - $query->setPostFilter($filter->toArray()); + $query->setPostFilter($filter); - $results = $this->_index->search($query); + $results = $this->_getTestIndex()->search($query); $this->assertEquals(1, $results->getTotalHits()); - - } - - protected function _createIndex($name = 'test', $delete = true, $shards = 1) - { - return parent::_createIndex('test_postfilter_' . $name, $delete, $shards); } } |