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/RegexpTest.php | |
parent | 15e69f7b20b6596b9148030acce5b59993b95a45 (diff) | |
parent | 257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff) |
Merge branch 'mw-1.26'
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php | 83 |
1 files changed, 54 insertions, 29 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php index e06064dd..6e3a0395 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php @@ -1,14 +1,16 @@ <?php - namespace Elastica\Test\Filter; use Elastica\Document; use Elastica\Filter\Regexp; -use Elastica\Type\Mapping; use Elastica\Test\Base as BaseTest; +use Elastica\Type\Mapping; class RegexpTest extends BaseTest { + /** + * @group unit + */ public function testToArray() { $field = 'name'; @@ -18,13 +20,41 @@ class RegexpTest extends BaseTest $expectedArray = array( 'regexp' => array( - $field => $regexp - ) + $field => $regexp, + ), ); $this->assertequals($expectedArray, $filter->toArray()); } + /** + * @group unit + */ + public function testToArrayWithOptions() + { + $field = 'name'; + $regexp = 'ruf'; + $options = array( + 'flags' => 'ALL', + ); + + $filter = new Regexp($field, $regexp, $options); + + $expectedArray = array( + 'regexp' => array( + $field => array( + 'value' => $regexp, + 'flags' => 'ALL', + ), + ), + ); + + $this->assertequals($expectedArray, $filter->toArray()); + } + + /** + * @group functional + */ public function testDifferentRegexp() { $client = $this->_getClient(); @@ -38,17 +68,13 @@ class RegexpTest extends BaseTest ) ); $type->setMapping($mapping); - - $doc = new Document(1, array('name' => 'Basel-Stadt')); - $type->addDocument($doc); - $doc = new Document(2, array('name' => 'New York')); - $type->addDocument($doc); - $doc = new Document(3, array('name' => 'Baden')); - $type->addDocument($doc); - $doc = new Document(4, array('name' => 'Baden Baden')); - $type->addDocument($doc); - $doc = new Document(5, array('name' => 'New Orleans')); - $type->addDocument($doc); + $type->addDocuments(array( + new Document(1, array('name' => 'Basel-Stadt')), + new Document(2, array('name' => 'New York')), + new Document(3, array('name' => 'Baden')), + new Document(4, array('name' => 'Baden Baden')), + new Document(5, array('name' => 'New Orleans')), + )); $index->refresh(); @@ -74,6 +100,9 @@ class RegexpTest extends BaseTest $this->assertEquals(0, $resultSet->count()); } + /** + * @group functional + */ public function testDifferentRegexpLowercase() { $client = $this->_getClient(); @@ -85,10 +114,10 @@ class RegexpTest extends BaseTest 'lw' => array( 'type' => 'custom', 'tokenizer' => 'keyword', - 'filter' => array('lowercase') - ) + 'filter' => array('lowercase'), + ), ), - ) + ), ); $index->create($indexParams, true); @@ -99,17 +128,13 @@ class RegexpTest extends BaseTest ) ); $type->setMapping($mapping); - - $doc = new Document(1, array('name' => 'Basel-Stadt')); - $type->addDocument($doc); - $doc = new Document(2, array('name' => 'New York')); - $type->addDocument($doc); - $doc = new Document(3, array('name' => 'Baden')); - $type->addDocument($doc); - $doc = new Document(4, array('name' => 'Baden Baden')); - $type->addDocument($doc); - $doc = new Document(5, array('name' => 'New Orleans')); - $type->addDocument($doc); + $type->addDocuments(array( + new Document(1, array('name' => 'Basel-Stadt')), + new Document(2, array('name' => 'New York')), + new Document(3, array('name' => 'Baden')), + new Document(4, array('name' => 'Baden Baden')), + new Document(5, array('name' => 'New Orleans')), + )); $index->refresh(); |