summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php')
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php97
1 files changed, 62 insertions, 35 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php
index 796bfb8d..925c23bb 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Type;
use Elastica\Document;
@@ -11,6 +10,9 @@ use Elastica\Type\Mapping;
class MappingTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testMappingStoreFields()
{
$client = $this->_getClient();
@@ -34,7 +36,7 @@ class MappingTest extends BaseTest
$doc = new Document(1,
array(
'firstname' => $firstname,
- 'lastname' => 'Ruflin'
+ 'lastname' => 'Ruflin',
)
);
@@ -61,6 +63,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testEnableAllField()
{
$index = $this->_createIndex();
@@ -79,6 +84,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testEnableTtl()
{
$client = $this->_getClient();
@@ -97,6 +105,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testNestedMapping()
{
$client = $this->_getClient();
@@ -105,7 +116,7 @@ class MappingTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $this->markTestIncomplete('nested mapping is not set right yet');
+ //$this->markTestIncomplete('nested mapping is not set right yet');
$mapping = new Mapping($type,
array(
'test' => array(
@@ -115,20 +126,21 @@ class MappingTest extends BaseTest
'firstname' => array('type' => 'string', 'store' => 'yes'),
'lastname' => array('type' => 'string', 'store' => 'yes'),
'age' => array('type' => 'integer', 'store' => 'yes'),
- )
+ ),
),
),
),
)
);
- $type->setMapping($mapping);
+ $response = $type->setMapping($mapping);
+ $this->assertFalse($response->hasError());
$doc = new Document(1, array(
'user' => array(
'firstname' => 'Nicolas',
'lastname' => 'Ruflin',
- 'age' => 9
+ 'age' => 9,
),
));
@@ -136,17 +148,21 @@ class MappingTest extends BaseTest
$index->refresh();
$resultSet = $type->search('ruflin');
+ $this->assertEquals($resultSet->count(), 1);
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testParentMapping()
{
$index = $this->_createIndex();
$parenttype = new Type($index, 'parenttype');
$parentmapping = new Mapping($parenttype,
array(
- 'name' => array('type' => 'string', 'store' => 'yes')
+ 'name' => array('type' => 'string', 'store' => 'yes'),
)
);
@@ -168,6 +184,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testMappingExample()
{
$index = $this->_createIndex();
@@ -177,10 +196,10 @@ class MappingTest extends BaseTest
array(
'note' => array(
'store' => 'yes', 'properties' => array(
- 'titulo' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0),
- 'contenido' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0)
- )
- )
+ 'titulo' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0),
+ 'contenido' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0),
+ ),
+ ),
)
);
@@ -189,14 +208,14 @@ class MappingTest extends BaseTest
$doc = new Document(1, array(
'note' => array(
array(
- 'titulo' => 'nota1',
- 'contenido' => 'contenido1'
+ 'titulo' => 'nota1',
+ 'contenido' => 'contenido1',
),
array(
- 'titulo' => 'nota2',
- 'contenido' => 'contenido2'
- )
- )
+ 'titulo' => 'nota2',
+ 'contenido' => 'contenido2',
+ ),
+ ),
)
);
@@ -206,36 +225,38 @@ class MappingTest extends BaseTest
}
/**
+ * @group functional
+ *
* Test setting a dynamic template and validate whether the right mapping is applied after adding a document which
* should match the dynamic template. The example is the template_1 from the Elasticsearch documentation.
- *
- * @link http://www.elasticsearch.org/guide/reference/mapping/root-object-type/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-root-object-type.html
*/
public function testDynamicTemplate()
{
$index = $this->_createIndex();
- $type = $index->getType('person');
-
- // set a dynamic template "template_1" which creates a multi field for multi* matches.
+ $type = $index->getType('person');
+
+ // set a dynamic template "template_1" which creates a multi field for multi* matches.
$mapping = new Mapping($type);
$mapping->setParam('dynamic_templates', array(
array('template_1' => array(
- 'match' => 'multi*',
+ 'match' => 'multi*',
'mapping' => array(
- 'type' => 'multi_field',
+ 'type' => 'multi_field',
'fields' => array(
'{name}' => array('type' => '{dynamic_type}', 'index' => 'analyzed'),
- 'org' => array('type' => '{dynamic_type}', 'index' => 'not_analyzed')
- )
- )
- ))
+ 'org' => array('type' => '{dynamic_type}', 'index' => 'not_analyzed'),
+ ),
+ ),
+ )),
));
-
+
$mapping->send();
-
+
// when running the tests, the mapping sometimes isn't available yet. Optimize index to enforce reload mapping.
$index->optimize();
-
+
// create a document which should create a mapping for the field: multiname.
$testDoc = new Document('person1', array('multiname' => 'Jasper van Wanrooy'), $type);
$index->addDocuments(array($testDoc));
@@ -260,13 +281,16 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetMeta()
{
$index = $this->_createIndex();
$type = $index->getType('test');
$mapping = new Mapping($type, array(
'firstname' => array('type' => 'string', 'store' => 'yes'),
- 'lastname' => array('type' => 'string')
+ 'lastname' => array('type' => 'string'),
));
$mapping->setMeta(array('class' => 'test'));
$type->setMapping($mapping);
@@ -277,18 +301,21 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetters()
{
$index = $this->_createIndex();
$type = $index->getType('test');
$properties = array(
'firstname' => array('type' => 'string', 'store' => 'yes'),
- 'lastname' => array('type' => 'string')
+ 'lastname' => array('type' => 'string'),
);
$mapping = new Mapping($type, $properties);
$all = array(
- "enabled" => true,
- "store" => "yes"
+ 'enabled' => true,
+ 'store' => 'yes',
);
$mapping->setParam('_all', $all);
$get_all = $mapping->getParam('_all');