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