mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Update class for mapping type constants
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Alchemy\Tests\Phrasea\SearchEngine\AST;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\AST\QuotedTextNode;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field;
|
||||
@@ -23,7 +24,7 @@ class QuotedTextNodeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testQueryBuild()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$query_context = $this->prophesize(QueryContext::class);
|
||||
$query_context->getUnrestrictedFields()->willReturn([$field]);
|
||||
$query_context->getPrivateFields()->willReturn([]);
|
||||
@@ -46,8 +47,8 @@ class QuotedTextNodeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testQueryBuildWithPrivateFields()
|
||||
{
|
||||
$public_field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$private_field = new Field('bar', Mapping::TYPE_STRING, [
|
||||
$public_field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$private_field = new Field('bar', FieldMapping::TYPE_STRING, [
|
||||
'private' => true,
|
||||
'used_by_collections' => [1, 2, 3]
|
||||
]);
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Alchemy\Tests\Phrasea\SearchEngine\AST;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\AST\RawNode;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field;
|
||||
@@ -24,7 +25,7 @@ class RawNodeTest extends \PHPUnit_Framework_TestCase
|
||||
public function testQueryBuildOnSingleField()
|
||||
{
|
||||
$field = $this->prophesize(Field::class);
|
||||
$field->getType()->willReturn(Mapping::TYPE_STRING);
|
||||
$field->getType()->willReturn(FieldMapping::TYPE_STRING);
|
||||
$field->getIndexField(true)->willReturn('foo.raw');
|
||||
|
||||
$query_context = $this->prophesize(QueryContext::class);
|
||||
@@ -46,10 +47,10 @@ class RawNodeTest extends \PHPUnit_Framework_TestCase
|
||||
public function testQueryBuildOnMultipleFields()
|
||||
{
|
||||
$field_a = $this->prophesize(Field::class);
|
||||
$field_a->getType()->willReturn(Mapping::TYPE_STRING);
|
||||
$field_a->getType()->willReturn(FieldMapping::TYPE_STRING);
|
||||
$field_a->getIndexField(true)->willReturn('foo.raw');
|
||||
$field_b = $this->prophesize(Field::class);
|
||||
$field_b->getType()->willReturn(Mapping::TYPE_STRING);
|
||||
$field_b->getType()->willReturn(FieldMapping::TYPE_STRING);
|
||||
$field_b->getIndexField(true)->willReturn('bar.raw');
|
||||
|
||||
$query_context = $this->prophesize(QueryContext::class);
|
||||
|
@@ -4,6 +4,7 @@ namespace Alchemy\Tests\Phrasea\SearchEngine\AST;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\AST\Context;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\AST\TermNode;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field;
|
||||
@@ -27,7 +28,7 @@ class TermNodeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testQueryBuild()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$query_context = $this->prophesize(QueryContext::class);
|
||||
$query_context
|
||||
->getUnrestrictedFields()
|
||||
@@ -64,7 +65,7 @@ class TermNodeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testQueryBuildWithZeroConcept()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$query_context = $this->prophesize(QueryContext::class);
|
||||
$query_context
|
||||
->getUnrestrictedFields()
|
||||
@@ -81,8 +82,8 @@ class TermNodeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testQueryBuildWithPrivateFields()
|
||||
{
|
||||
$public_field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$private_field = new Field('bar', Mapping::TYPE_STRING, [
|
||||
$public_field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$private_field = new Field('bar', FieldMapping::TYPE_STRING, [
|
||||
'private' => true,
|
||||
'used_by_collections' => [1, 2, 3]
|
||||
]);
|
||||
|
@@ -4,6 +4,7 @@ namespace Alchemy\Tests\Phrasea\SearchEngine\AST;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\AST\Context;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\AST\TextNode;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field;
|
||||
@@ -42,7 +43,7 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testQueryBuild()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$query_context = $this->prophesize(QueryContext::class);
|
||||
$query_context->getUnrestrictedFields()->willReturn([$field]);
|
||||
$query_context->getPrivateFields()->willReturn([]);
|
||||
@@ -66,8 +67,8 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testQueryBuildWithPrivateFields()
|
||||
{
|
||||
$public_field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$private_field = new Field('bar', Mapping::TYPE_STRING, [
|
||||
$public_field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$private_field = new Field('bar', FieldMapping::TYPE_STRING, [
|
||||
'private' => true,
|
||||
'used_by_collections' => [1, 2, 3]
|
||||
]);
|
||||
@@ -125,7 +126,7 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testQueryBuildWithConcepts()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$query_context = $this->prophesize(QueryContext::class);
|
||||
$query_context->getUnrestrictedFields()->willReturn([$field]);
|
||||
$query_context->getPrivateFields()->willReturn([]);
|
||||
@@ -161,8 +162,8 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testQueryBuildWithPrivateFieldAndConcept()
|
||||
{
|
||||
$public_field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$private_field = new Field('bar', Mapping::TYPE_STRING, [
|
||||
$public_field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$private_field = new Field('bar', FieldMapping::TYPE_STRING, [
|
||||
'private' => true,
|
||||
'used_by_collections' => [1, 2, 3]
|
||||
]);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\SearchEngine\Search;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Search\AggregationHelper;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field;
|
||||
@@ -14,7 +15,7 @@ class AggregationHelperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAggregationWrappingOnPrivateField()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, [
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'private' => true,
|
||||
'used_by_collections' => [1, 2, 3]
|
||||
]);
|
||||
@@ -40,7 +41,7 @@ class AggregationHelperTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testAggregationWrappingOnUnrestrictedField()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$agg = [
|
||||
'terms' => 'bar'
|
||||
];
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\SearchEngine\Search;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field;
|
||||
@@ -24,8 +25,8 @@ class QueryContextTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetUnrestrictedFields()
|
||||
{
|
||||
$foo_field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$bar_field = new Field('bar', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$foo_field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$bar_field = new Field('bar', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$structure = $this->prophesize(Structure::class);
|
||||
$structure->getUnrestrictedFields()->willReturn([
|
||||
'foo' => $foo_field,
|
||||
@@ -41,8 +42,8 @@ class QueryContextTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetPrivateFields()
|
||||
{
|
||||
$foo_field = new Field('foo', Mapping::TYPE_STRING, ['private' => true]);
|
||||
$bar_field = new Field('bar', Mapping::TYPE_STRING, ['private' => true]);
|
||||
$foo_field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => true]);
|
||||
$bar_field = new Field('bar', FieldMapping::TYPE_STRING, ['private' => true]);
|
||||
$structure = $this->prophesize(Structure::class);
|
||||
$structure->getPrivateFields()->willReturn([
|
||||
'foo' => $foo_field,
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\SearchEngine\Structure;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Thesaurus\Concept;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field;
|
||||
@@ -14,14 +15,14 @@ class FieldTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testBasicMerge()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, ['used_by_collections' => ['1', '2']]);
|
||||
$other = new Field('foo', Mapping::TYPE_STRING, ['used_by_collections' => ['3', '4']]);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, ['used_by_collections' => ['1', '2']]);
|
||||
$other = new Field('foo', FieldMapping::TYPE_STRING, ['used_by_collections' => ['3', '4']]);
|
||||
$merged = $field->mergeWith($other);
|
||||
$this->assertInstanceOf(Field::class, $merged);
|
||||
$this->assertNotSame($field, $merged);
|
||||
$this->assertNotSame($other, $merged);
|
||||
$this->assertEquals('foo', $merged->getName());
|
||||
$this->assertEquals(Mapping::TYPE_STRING, $merged->getType());
|
||||
$this->assertEquals(FieldMapping::TYPE_STRING, $merged->getType());
|
||||
$this->assertTrue($merged->isSearchable());
|
||||
$this->assertFalse($merged->isPrivate());
|
||||
$this->assertFalse($merged->isFacet());
|
||||
@@ -35,8 +36,8 @@ class FieldTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testConflictingNameMerge()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING);
|
||||
$other = new Field('bar', Mapping::TYPE_STRING);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING);
|
||||
$other = new Field('bar', FieldMapping::TYPE_STRING);
|
||||
$field->mergeWith($other);
|
||||
}
|
||||
|
||||
@@ -46,8 +47,8 @@ class FieldTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testConflictingTypeMerge()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING);
|
||||
$other = new Field('foo', Mapping::TYPE_DATE);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING);
|
||||
$other = new Field('foo', FieldMapping::TYPE_DATE);
|
||||
$field->mergeWith($other);
|
||||
}
|
||||
|
||||
@@ -57,8 +58,8 @@ class FieldTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testMixedSearchabilityMerge()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, ['searchable' => true]);
|
||||
$other = new Field('foo', Mapping::TYPE_STRING, ['searchable' => false]);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, ['searchable' => true]);
|
||||
$other = new Field('foo', FieldMapping::TYPE_STRING, ['searchable' => false]);
|
||||
$field->mergeWith($other);
|
||||
}
|
||||
|
||||
@@ -68,8 +69,8 @@ class FieldTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testMixedPrivateAndPublicMerge()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, ['private' => true]);
|
||||
$other = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => true]);
|
||||
$other = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$field->mergeWith($other);
|
||||
}
|
||||
|
||||
@@ -79,8 +80,8 @@ class FieldTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testMixedFacetEligibilityMerge()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, ['facet' => Field::FACET_NO_LIMIT]);
|
||||
$other = new Field('foo', Mapping::TYPE_STRING, ['facet' => Field::FACET_DISABLED]);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, ['facet' => Field::FACET_NO_LIMIT]);
|
||||
$other = new Field('foo', FieldMapping::TYPE_STRING, ['facet' => Field::FACET_DISABLED]);
|
||||
$field->mergeWith($other);
|
||||
}
|
||||
|
||||
@@ -88,8 +89,8 @@ class FieldTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$foo = new Concept('/foo');
|
||||
$bar = new Concept('/bar');
|
||||
$field = new Field('foo', Mapping::TYPE_STRING);
|
||||
$other = new Field('foo', Mapping::TYPE_STRING, [
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING);
|
||||
$other = new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'thesaurus_roots' => [$foo, $bar]
|
||||
]);
|
||||
$merged = $field->mergeWith($other);
|
||||
@@ -97,10 +98,10 @@ class FieldTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$foo = new Concept('/foo');
|
||||
$bar = new Concept('/bar');
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, [
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'thesaurus_roots' => [$foo]
|
||||
]);
|
||||
$other = new Field('foo', Mapping::TYPE_STRING, [
|
||||
$other = new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'thesaurus_roots' => [$bar]
|
||||
]);
|
||||
$merged = $field->mergeWith($other);
|
||||
@@ -109,10 +110,10 @@ class FieldTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testMergeWithDependantCollections()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING, [
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'used_by_collections' => [1, 2]
|
||||
]);
|
||||
$other = new Field('foo', Mapping::TYPE_STRING, [
|
||||
$other = new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'used_by_collections' => [2, 3]
|
||||
]);
|
||||
$merged = $field->mergeWith($other);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\SearchEngine\Structure;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\LimitedStructure;
|
||||
@@ -16,7 +17,7 @@ class LimitedStructureTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetUnrestrictedFields()
|
||||
{
|
||||
$field = new Field('foo', Mapping::TYPE_STRING);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING);
|
||||
$wrapped = $this->prophesize(Structure::class);
|
||||
$wrapped
|
||||
->getUnrestrictedFields()
|
||||
@@ -38,13 +39,13 @@ class LimitedStructureTest extends \PHPUnit_Framework_TestCase
|
||||
$wrapped->get('foo')
|
||||
->shouldBeCalled()
|
||||
->willReturn(
|
||||
new Field('foo', Mapping::TYPE_STRING, [
|
||||
new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'used_by_collections' => [1, 2, 3]
|
||||
])
|
||||
)
|
||||
;
|
||||
$this->assertEquals(
|
||||
new Field('foo', Mapping::TYPE_STRING, [
|
||||
new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'used_by_collections' => [2]
|
||||
]),
|
||||
$structure->get('foo')
|
||||
@@ -65,21 +66,21 @@ class LimitedStructureTest extends \PHPUnit_Framework_TestCase
|
||||
$structure = new LimitedStructure($wrapped->reveal(), $options->reveal());
|
||||
|
||||
$wrapped->getAllFields()->willReturn([
|
||||
'foo' => new Field('foo', Mapping::TYPE_STRING, [
|
||||
'foo' => new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'private' => false,
|
||||
'used_by_collections' => [1, 2, 3]
|
||||
]),
|
||||
'bar' => new Field('bar', Mapping::TYPE_STRING, [
|
||||
'bar' => new Field('bar', FieldMapping::TYPE_STRING, [
|
||||
'private' => true,
|
||||
'used_by_collections' => [1, 2, 3]
|
||||
])
|
||||
]);
|
||||
$this->assertEquals([
|
||||
'foo' => new Field('foo', Mapping::TYPE_STRING, [
|
||||
'foo' => new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'private' => false,
|
||||
'used_by_collections' => [1, 2, 3]
|
||||
]),
|
||||
'bar' => new Field('bar', Mapping::TYPE_STRING, [
|
||||
'bar' => new Field('bar', FieldMapping::TYPE_STRING, [
|
||||
'private' => true,
|
||||
'used_by_collections' => [1, 3]
|
||||
])
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\SearchEngine\Structure;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Thesaurus\Concept;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field;
|
||||
@@ -30,7 +31,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$field = $this->prophesize(Field::class);
|
||||
$field->getName()->willReturn('foo');
|
||||
$field->getType()->willReturn(Mapping::TYPE_STRING);
|
||||
$field->getType()->willReturn(FieldMapping::TYPE_STRING);
|
||||
$field->isPrivate()->willReturn(false);
|
||||
$field->isFacet()->willReturn(false);
|
||||
$field->hasConceptInference()->willReturn(false);
|
||||
@@ -39,9 +40,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
$structure->add($field->reveal());
|
||||
$this->assertCount(1, $structure->getAllFields());
|
||||
|
||||
$conflicting_field = new Field('foo', Mapping::TYPE_STRING, ['2']);
|
||||
$conflicting_field = new Field('foo', FieldMapping::TYPE_STRING, ['2']);
|
||||
|
||||
$merged = new Field('foo', Mapping::TYPE_STRING, ['1', '2']);
|
||||
$merged = new Field('foo', FieldMapping::TYPE_STRING, ['1', '2']);
|
||||
|
||||
$field->mergeWith($conflicting_field)->willReturn($merged);
|
||||
// Should still have only one (both have the same name)
|
||||
@@ -55,14 +56,14 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$field = $this->prophesize(Field::class);
|
||||
$field->getName()->willReturn('foo');
|
||||
$field->getType()->willReturn(Mapping::TYPE_STRING);
|
||||
$field->getType()->willReturn(FieldMapping::TYPE_STRING);
|
||||
$field->isPrivate()->willReturn(false);
|
||||
$field->isFacet()->willReturn(false);
|
||||
$field->hasConceptInference()->willReturn(false);
|
||||
|
||||
$other = new Field('foo', Mapping::TYPE_STRING);
|
||||
$other = new Field('foo', FieldMapping::TYPE_STRING);
|
||||
|
||||
$merged = new Field('foo', Mapping::TYPE_STRING);
|
||||
$merged = new Field('foo', FieldMapping::TYPE_STRING);
|
||||
$field->mergeWith($other)->shouldBeCalled()->willReturn($merged);
|
||||
|
||||
$structure = new Structure();
|
||||
@@ -74,9 +75,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
public function testFieldsRestrictions()
|
||||
{
|
||||
$structure = new Structure();
|
||||
$unrestricted_field = new Field('foo', Mapping::TYPE_STRING, ['private' => false]);
|
||||
$unrestricted_field = new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]);
|
||||
$structure->add($unrestricted_field);
|
||||
$private_field = new Field('bar', Mapping::TYPE_STRING, ['private' => true]);
|
||||
$private_field = new Field('bar', FieldMapping::TYPE_STRING, ['private' => true]);
|
||||
$structure->add($private_field);
|
||||
// All
|
||||
$all_fields = $structure->getAllFields();
|
||||
@@ -94,8 +95,8 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetFacetFields()
|
||||
{
|
||||
$facet = new Field('foo', Mapping::TYPE_STRING, ['facet' => Field::FACET_NO_LIMIT]);
|
||||
$not_facet = new Field('bar', Mapping::TYPE_STRING, ['facet' => Field::FACET_DISABLED]);
|
||||
$facet = new Field('foo', FieldMapping::TYPE_STRING, ['facet' => Field::FACET_NO_LIMIT]);
|
||||
$not_facet = new Field('bar', FieldMapping::TYPE_STRING, ['facet' => Field::FACET_DISABLED]);
|
||||
$structure = new Structure();
|
||||
$structure->add($facet);
|
||||
$this->assertContains($facet, $structure->getFacetFields());
|
||||
@@ -107,8 +108,8 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetDateFields()
|
||||
{
|
||||
$string = new Field('foo', Mapping::TYPE_STRING);
|
||||
$date = new Field('bar', Mapping::TYPE_DATE);
|
||||
$string = new Field('foo', FieldMapping::TYPE_STRING);
|
||||
$date = new Field('bar', FieldMapping::TYPE_DATE);
|
||||
$structure = new Structure();
|
||||
$structure->add($string);
|
||||
$this->assertNotContains($string, $structure->getDateFields());
|
||||
@@ -120,10 +121,10 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetThesaurusEnabledFields()
|
||||
{
|
||||
$not_enabled = new Field('foo', Mapping::TYPE_STRING, [
|
||||
$not_enabled = new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'thesaurus_roots' => null
|
||||
]);
|
||||
$enabled = new Field('bar', Mapping::TYPE_STRING, [
|
||||
$enabled = new Field('bar', FieldMapping::TYPE_STRING, [
|
||||
'thesaurus_roots' => [new Concept('/foo')]
|
||||
]);
|
||||
$structure = new Structure();
|
||||
@@ -138,7 +139,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGet()
|
||||
{
|
||||
$structure = new Structure();
|
||||
$field = new Field('foo', Mapping::TYPE_STRING);
|
||||
$field = new Field('foo', FieldMapping::TYPE_STRING);
|
||||
$structure->add($field);
|
||||
$this->assertEquals($field, $structure->get('foo'));
|
||||
$this->assertNull($structure->get('bar'));
|
||||
@@ -147,19 +148,19 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
public function testTypeCheck()
|
||||
{
|
||||
$structure = new Structure();
|
||||
$structure->add(new Field('foo', Mapping::TYPE_STRING));
|
||||
$structure->add(new Field('bar', Mapping::TYPE_DATE));
|
||||
$structure->add(new Field('baz', Mapping::TYPE_DOUBLE));
|
||||
$this->assertEquals(Mapping::TYPE_STRING, $structure->typeOf('foo'));
|
||||
$this->assertEquals(Mapping::TYPE_DATE, $structure->typeOf('bar'));
|
||||
$this->assertEquals(Mapping::TYPE_DOUBLE, $structure->typeOf('baz'));
|
||||
$structure->add(new Field('foo', FieldMapping::TYPE_STRING));
|
||||
$structure->add(new Field('bar', FieldMapping::TYPE_DATE));
|
||||
$structure->add(new Field('baz', FieldMapping::TYPE_DOUBLE));
|
||||
$this->assertEquals(FieldMapping::TYPE_STRING, $structure->typeOf('foo'));
|
||||
$this->assertEquals(FieldMapping::TYPE_DATE, $structure->typeOf('bar'));
|
||||
$this->assertEquals(FieldMapping::TYPE_DOUBLE, $structure->typeOf('baz'));
|
||||
}
|
||||
|
||||
public function testPrivateCheck()
|
||||
{
|
||||
$structure = new Structure();
|
||||
$structure->add(new Field('foo', Mapping::TYPE_STRING, ['private' => false]));
|
||||
$structure->add(new Field('bar', Mapping::TYPE_STRING, ['private' => true]));
|
||||
$structure->add(new Field('foo', FieldMapping::TYPE_STRING, ['private' => false]));
|
||||
$structure->add(new Field('bar', FieldMapping::TYPE_STRING, ['private' => true]));
|
||||
$this->assertFalse($structure->isPrivate('foo'));
|
||||
$this->assertTrue($structure->isPrivate('bar'));
|
||||
}
|
||||
@@ -177,19 +178,19 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
public function testCollectionsUsedByPrivateFields()
|
||||
{
|
||||
$structure = new Structure();
|
||||
$structure->add($foo = (new Field('foo', Mapping::TYPE_STRING, [
|
||||
$structure->add($foo = (new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'private' => true,
|
||||
'used_by_collections' => [1, 2]
|
||||
])));
|
||||
$structure->add(new Field('foo', Mapping::TYPE_STRING, [
|
||||
$structure->add(new Field('foo', FieldMapping::TYPE_STRING, [
|
||||
'private' => true,
|
||||
'used_by_collections' => [2, 3]
|
||||
]));
|
||||
$structure->add(new Field('bar', Mapping::TYPE_STRING, [
|
||||
$structure->add(new Field('bar', FieldMapping::TYPE_STRING, [
|
||||
'private' => true,
|
||||
'used_by_collections' => [2, 3]
|
||||
]));
|
||||
$structure->add(new Field('baz', Mapping::TYPE_STRING, ['private' => false]));
|
||||
$structure->add(new Field('baz', FieldMapping::TYPE_STRING, ['private' => false]));
|
||||
$this->assertEquals([1, 2], $foo->getDependantCollections());
|
||||
static $expected = [
|
||||
'foo' => [1, 2, 3],
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\SearchEngine\Structure;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\FieldMapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\ValueChecker;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Typed;
|
||||
@@ -23,45 +24,45 @@ class ValueCheckerTest extends \PHPUnit_Framework_TestCase
|
||||
public function escapeRawProvider()
|
||||
{
|
||||
$values = [
|
||||
[Mapping::TYPE_FLOAT , 42 , true ],
|
||||
[Mapping::TYPE_FLOAT , '42' , true ],
|
||||
[Mapping::TYPE_FLOAT , '42foo' , false],
|
||||
[Mapping::TYPE_FLOAT , 'foo' , false],
|
||||
[Mapping::TYPE_DOUBLE , 42 , true ],
|
||||
[Mapping::TYPE_DOUBLE , '42' , true ],
|
||||
[Mapping::TYPE_DOUBLE , '42foo' , false],
|
||||
[Mapping::TYPE_DOUBLE , 'foo' , false],
|
||||
[Mapping::TYPE_INTEGER, 42 , true ],
|
||||
[Mapping::TYPE_INTEGER, '42' , true ],
|
||||
[Mapping::TYPE_INTEGER, '42foo' , false],
|
||||
[Mapping::TYPE_INTEGER, 'foo' , false],
|
||||
[Mapping::TYPE_LONG , 42 , true ],
|
||||
[Mapping::TYPE_LONG , '42' , true ],
|
||||
[Mapping::TYPE_LONG , '42foo' , false],
|
||||
[Mapping::TYPE_LONG , 'foo' , false],
|
||||
[Mapping::TYPE_SHORT , 42 , true ],
|
||||
[Mapping::TYPE_SHORT , '42' , true ],
|
||||
[Mapping::TYPE_SHORT , '42foo' , false],
|
||||
[Mapping::TYPE_SHORT , 'foo' , false],
|
||||
[Mapping::TYPE_BYTE , 42 , true ],
|
||||
[Mapping::TYPE_BYTE , '42' , true ],
|
||||
[Mapping::TYPE_BYTE , '42foo' , false],
|
||||
[Mapping::TYPE_BYTE , 'foo' , false],
|
||||
[FieldMapping::TYPE_FLOAT , 42 , true ],
|
||||
[FieldMapping::TYPE_FLOAT , '42' , true ],
|
||||
[FieldMapping::TYPE_FLOAT , '42foo' , false],
|
||||
[FieldMapping::TYPE_FLOAT , 'foo' , false],
|
||||
[FieldMapping::TYPE_DOUBLE , 42 , true ],
|
||||
[FieldMapping::TYPE_DOUBLE , '42' , true ],
|
||||
[FieldMapping::TYPE_DOUBLE , '42foo' , false],
|
||||
[FieldMapping::TYPE_DOUBLE , 'foo' , false],
|
||||
[FieldMapping::TYPE_INTEGER, 42 , true ],
|
||||
[FieldMapping::TYPE_INTEGER, '42' , true ],
|
||||
[FieldMapping::TYPE_INTEGER, '42foo' , false],
|
||||
[FieldMapping::TYPE_INTEGER, 'foo' , false],
|
||||
[FieldMapping::TYPE_LONG , 42 , true ],
|
||||
[FieldMapping::TYPE_LONG , '42' , true ],
|
||||
[FieldMapping::TYPE_LONG , '42foo' , false],
|
||||
[FieldMapping::TYPE_LONG , 'foo' , false],
|
||||
[FieldMapping::TYPE_SHORT , 42 , true ],
|
||||
[FieldMapping::TYPE_SHORT , '42' , true ],
|
||||
[FieldMapping::TYPE_SHORT , '42foo' , false],
|
||||
[FieldMapping::TYPE_SHORT , 'foo' , false],
|
||||
[FieldMapping::TYPE_BYTE , 42 , true ],
|
||||
[FieldMapping::TYPE_BYTE , '42' , true ],
|
||||
[FieldMapping::TYPE_BYTE , '42foo' , false],
|
||||
[FieldMapping::TYPE_BYTE , 'foo' , false],
|
||||
|
||||
[Mapping::TYPE_STRING , 'foo' , true ],
|
||||
[Mapping::TYPE_STRING , '42' , true ],
|
||||
[Mapping::TYPE_STRING , 42 , true ],
|
||||
[FieldMapping::TYPE_STRING , 'foo' , true ],
|
||||
[FieldMapping::TYPE_STRING , '42' , true ],
|
||||
[FieldMapping::TYPE_STRING , 42 , true ],
|
||||
|
||||
[Mapping::TYPE_BOOLEAN, true , true ],
|
||||
[Mapping::TYPE_BOOLEAN, false , true ],
|
||||
[Mapping::TYPE_BOOLEAN, 'yes' , true ],
|
||||
[Mapping::TYPE_BOOLEAN, 'no' , true ],
|
||||
[Mapping::TYPE_BOOLEAN, 'foo' , true ],
|
||||
[Mapping::TYPE_BOOLEAN, 42 , true ],
|
||||
[FieldMapping::TYPE_BOOLEAN, true , true ],
|
||||
[FieldMapping::TYPE_BOOLEAN, false , true ],
|
||||
[FieldMapping::TYPE_BOOLEAN, 'yes' , true ],
|
||||
[FieldMapping::TYPE_BOOLEAN, 'no' , true ],
|
||||
[FieldMapping::TYPE_BOOLEAN, 'foo' , true ],
|
||||
[FieldMapping::TYPE_BOOLEAN, 42 , true ],
|
||||
|
||||
[Mapping::TYPE_DATE , '2015/01/01' , true ],
|
||||
[Mapping::TYPE_DATE , '2015/01/01 00:00:00', false],
|
||||
[Mapping::TYPE_DATE , 'foo' , false],
|
||||
[FieldMapping::TYPE_DATE , '2015/01/01' , true ],
|
||||
[FieldMapping::TYPE_DATE , '2015/01/01 00:00:00', false],
|
||||
[FieldMapping::TYPE_DATE , 'foo' , false],
|
||||
];
|
||||
|
||||
foreach ($values as &$value) {
|
||||
|
Reference in New Issue
Block a user