summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php
diff options
context:
space:
mode:
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.php58
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;
}
}