Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functional test for OrBool Filter #887

Merged
merged 2 commits into from Jul 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -15,6 +15,10 @@ matrix:
- php: hhvm
fast_finish: true

branches:
only:
- master

install:
- /bin/bash ansible/provision.sh

Expand Down
27 changes: 27 additions & 0 deletions test/lib/Elastica/Test/Filter/BoolOrTest.php
@@ -1,6 +1,7 @@
<?php
namespace Elastica\Test\Filter;

use Elastica\Document;
use Elastica\Filter\BoolOr;
use Elastica\Filter\Ids;
use Elastica\Test\Base as BaseTest;
Expand Down Expand Up @@ -60,4 +61,30 @@ public function testConstruct()

$this->assertEquals($and1->toArray(), $and2->toArray());
}

/**
* @group functional
*/
public function testOrFilter()
{
$index = $this->_createIndex();
$type = $index->getType('test');

$doc1 = new Document('', array('categoryId' => 1));
$doc2 = new Document('', array('categoryId' => 2));
$doc3 = new Document('', array('categoryId' => 3));

$type->addDocument($doc1);
$type->addDocument($doc2);
$type->addDocument($doc3);

$index->refresh();

$boolOr = new \Elastica\Filter\BoolOr();
$boolOr->addFilter(new \Elastica\Filter\Term(array('categoryId' => '1')));
$boolOr->addFilter(new \Elastica\Filter\Term(array('categoryId' => '2')));

$resultSet = $type->search($boolOr);
$this->assertEquals(2, $resultSet->count());
}
}