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/Filter/HasParentTest.php | |
parent | 15e69f7b20b6596b9148030acce5b59993b95a45 (diff) | |
parent | 257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff) |
Merge branch 'mw-1.26'
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php index 7998372b..50143dda 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php @@ -1,5 +1,4 @@ <?php - namespace Elastica\Test\Filter; use Elastica\Document; @@ -9,6 +8,9 @@ use Elastica\Test\Base as BaseTest; class HasParentTest extends BaseTest { + /** + * @group unit + */ public function testToArray() { $q = new MatchAll(); @@ -20,35 +22,41 @@ class HasParentTest extends BaseTest $expectedArray = array( 'has_parent' => array( 'query' => $q->toArray(), - 'type' => $type - ) + 'type' => $type, + ), ); $this->assertEquals($expectedArray, $filter->toArray()); } - public function testSetScope() + /** + * @group functional + */ + public function testSetType() { - $q = new MatchAll(); + $index = $this->prepareSearchData(); - $type = 'test'; + $filter = new HasParent(new MatchAll(), 'type_name'); + $this->assertEquals('type_name', $filter->getParam('type')); - $scope = 'foo'; + $filter->setType('new_type_name'); + $this->assertEquals('new_type_name', $filter->getParam('type')); - $filter = new HasParent($q, $type); - $filter->setScope($scope); + $type = $index->getType('foo'); + $filter = new HasParent(new MatchAll(), $type); + $this->assertEquals('foo', $filter->getParam('type')); - $expectedArray = array( - 'has_parent' => array( - 'query' => $q->toArray(), - 'type' => $type, - '_scope' => $scope - ) - ); + $type = $index->getType('bar'); + $filter->setType($type); + $this->assertEquals('bar', $filter->getParam('type')); - $this->assertEquals($expectedArray, $filter->toArray()); + $returnValue = $filter->setType('last'); + $this->assertInstanceOf('Elastica\Filter\HasParent', $returnValue); } + /** + * @group unit + */ public function testFilterInsideHasParent() { $f = new \Elastica\Filter\MatchAll(); @@ -60,14 +68,16 @@ class HasParentTest extends BaseTest $expectedArray = array( 'has_parent' => array( 'filter' => $f->toArray(), - 'type' => $type - ) + 'type' => $type, + ), ); $this->assertEquals($expectedArray, $filter->toArray()); - } + /** + * @group functional + */ public function testFilterInsideHasParentSearch() { $index = $this->prepareSearchData(); @@ -77,7 +87,7 @@ class HasParentTest extends BaseTest $filter = new HasParent($f, 'parent'); $searchQuery = new \Elastica\Query(); - $searchQuery->setFilter($filter); + $searchQuery->setPostFilter($filter); $searchResults = $index->search($searchQuery); $this->assertEquals(1, $searchResults->count()); @@ -88,6 +98,9 @@ class HasParentTest extends BaseTest $this->assertEquals($expected, $result); } + /** + * @group functional + */ public function testQueryInsideHasParentSearch() { $index = $this->prepareSearchData(); @@ -97,7 +110,7 @@ class HasParentTest extends BaseTest $filter = new HasParent($f, 'parent'); $searchQuery = new \Elastica\Query(); - $searchQuery->setFilter($filter); + $searchQuery->setPostFilter($filter); $searchResults = $index->search($searchQuery); $this->assertEquals(1, $searchResults->count()); @@ -134,6 +147,7 @@ class HasParentTest extends BaseTest $childType->addDocument($child2); $index->refresh(); + return $index; } } |