Skip to content
Permalink
Browse files

Merge pull request #1227 from ezsystems/impl-EZP-24267-indexable-rela…

…tion

Implement EZP-24266: Indexable Relation field type
  • Loading branch information...
pspanja committed May 1, 2015
2 parents 659b3e1 + c9a9047 commit 784b3daae18f341c200d966d4744297c3a0c9906
Showing with 901 additions and 678 deletions.
  1. +27 −1 eZ/Publish/API/Repository/Tests/FieldType/RelationIntegrationTest.php
  2. +111 −0 eZ/Publish/API/Repository/Tests/FieldType/RelationSearchBaseIntegrationTest.php
  3. +4 −4 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/ContentId.php
  4. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/ContentTypeGroupId.php
  5. +8 −8 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/DateMetadataLte.php
  6. +4 −4 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/DeprecatedContentIdQuery.php
  7. +6 −6 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/DepthIn.php
  8. +8 −8 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/DepthLte.php
  9. +4 −4 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/ContentId.php
  10. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/ContentTypeGroupId.php
  11. +8 −8 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/DateMetadataLte.php
  12. +6 −6 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/DepthIn.php
  13. +8 −8 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/DepthLte.php
  14. +6 −6 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/LogicalOr.php
  15. +4 −4 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/RemoteId.php
  16. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/SectionId.php
  17. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/SortSectionIdentifier.php
  18. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/SortSectionName.php
  19. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/Subtree.php
  20. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/UserMetadata.php
  21. +15 −15 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Location/Visibility.php
  22. +6 −6 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/LogicalOr.php
  23. +4 −4 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/RemoteId.php
  24. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/SectionId.php
  25. +144 −144 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/SortFieldMultipleTypes.php
  26. +144 −144 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/SortFieldMultipleTypesReverse.php
  27. +67 −66 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/SortFieldMultipleTypesSlice.php
  28. +67 −67 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/SortFieldMultipleTypesSliceReverse.php
  29. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/SortSectionIdentifier.php
  30. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/SortSectionName.php
  31. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Subtree.php
  32. +12 −12 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/UserMetadata.php
  33. +15 −15 eZ/Publish/API/Repository/Tests/_fixtures/Elasticsearch/Visibility.php
  34. +7 −0 eZ/Publish/API/Repository/Values/Content/Query/SortClause/ContentId.php
  35. +8 −0 eZ/Publish/API/Repository/Values/Content/Query/SortClause/Field.php
  36. +65 −0 eZ/Publish/Core/FieldType/Relation/SearchField.php
  37. +2 −2 eZ/Publish/Core/Search/Elasticsearch/Content/Resources/mappings/content.json
  38. +3 −3 eZ/Publish/Core/Search/Elasticsearch/Content/Resources/mappings/location.json
  39. +6 −1 eZ/Publish/Core/settings/indexable_fieldtypes.yml
@@ -21,7 +21,7 @@
* @group integration
* @group field-type
*/
class RelationFieldTypeIntegrationTest extends RelationBaseIntegrationTest
class RelationFieldTypeIntegrationTest extends RelationSearchBaseIntegrationTest
{
/**
* Get name of tested field type
@@ -363,4 +363,30 @@ public function providerForTestIsNotEmptyValue()
),
);
}
protected function getValidSearchValueOne()
{
// Using different values for Legacy Search Engine, in order to demonstrate that sort will
// depend on how search engine stores field type's value. Legacy stores it as integer, while
// other engines (Solr and Elasticsearch) store it as string.
if ( ltrim( get_class( $this->getSetupFactory() ), '\\' ) === 'eZ\Publish\API\Repository\Tests\SetupFactory\Legacy' )
{
return 4;
}
return 10;
}
protected function getValidSearchValueTwo()
{
// Using different values for Legacy Search Engine, in order to demonstrate that sort will
// depend on how search engine stores field type's value. Legacy stores it as integer, while
// other engines (Solr and Elasticsearch) store it as string.
if ( ltrim( get_class( $this->getSetupFactory() ), '\\' ) === 'eZ\Publish\API\Repository\Tests\SetupFactory\Legacy' )
{
return 49;
}
return 4;
}
}
@@ -0,0 +1,111 @@
<?php
/**
* This file is part of the eZ Publish Kernel package
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version //autogentag//
*/
namespace eZ\Publish\API\Repository\Tests\FieldType;
use eZ\Publish\Core\Repository\Values\Content\Relation;
use eZ\Publish\API\Repository\Values\Content\Content;
/**
* Base integration test for field types handling content relations.
*
* @group integration
* @group field-type
* @group relation
*/
abstract class RelationSearchBaseIntegrationTest extends SearchBaseIntegrationTest
{
/**
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
*
* @return \eZ\Publish\API\Repository\Values\Content\Relation[]
*/
abstract public function getCreateExpectedRelations( Content $content );
/**
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
*
* @return \eZ\Publish\API\Repository\Values\Content\Relation[]
*/
abstract public function getUpdateExpectedRelations( Content $content );
/**
* Tests relation processing on field create.
*/
public function testCreateContentRelationsProcessedCorrect()
{
$content = $this->createContent( $this->getValidCreationFieldData() );
$this->assertEquals(
$this->normalizeRelations(
$this->getCreateExpectedRelations( $content )
),
$this->normalizeRelations(
$this->getRepository()->getContentService()->loadRelations( $content->versionInfo )
)
);
}
/**
* Tests relation processing on field update.
*/
public function testUpdateContentRelationsProcessedCorrect()
{
$content = $this->updateContent( $this->getValidUpdateFieldData() );
$this->assertEquals(
$this->normalizeRelations(
$this->getUpdateExpectedRelations( $content )
),
$this->normalizeRelations(
$this->getRepository()->getContentService()->loadRelations( $content->versionInfo )
)
);
}
/**
* Normalizes given $relations for easier comparison.
*
* @param \eZ\Publish\Core\Repository\Values\Content\Relation[] $relations
*
* @return \eZ\Publish\Core\Repository\Values\Content\Relation[]
*/
protected function normalizeRelations( array $relations )
{
usort(
$relations,
function ( Relation $a, Relation $b )
{
if ( $a->type == $b->type )
{
return $a->destinationContentInfo->id < $b->destinationContentInfo->id ? 1 : -1;
}
return $a->type < $b->type ? 1 : -1;
}
);
$normalized = array_map(
function ( Relation $relation )
{
$newRelation = new Relation(
array(
"id" => null,
"sourceFieldDefinitionIdentifier" => $relation->sourceFieldDefinitionIdentifier,
"type" => $relation->type,
"sourceContentInfo" => $relation->sourceContentInfo,
"destinationContentInfo" => $relation->destinationContentInfo
)
);
return $newRelation;
},
$relations
);
return $normalized;
}
}
@@ -10,8 +10,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 4,
'title' => 'Users',
'id' => 10,
'title' => 'Anonymous User',
),
'score' => 1,
'index' => NULL,
@@ -21,8 +21,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 10,
'title' => 'Anonymous User',
'id' => 4,
'title' => 'Users',
),
'score' => 1,
'index' => NULL,
@@ -10,8 +10,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 4,
'title' => 'Users',
'id' => 10,
'title' => 'Anonymous User',
),
'score' => 1,
'index' => NULL,
@@ -21,8 +21,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 10,
'title' => 'Anonymous User',
'id' => 11,
'title' => 'Members',
),
'score' => 1,
'index' => NULL,
@@ -32,8 +32,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 11,
'title' => 'Members',
'id' => 12,
'title' => 'Administrator users',
),
'score' => 1,
'index' => NULL,
@@ -43,8 +43,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 12,
'title' => 'Administrator users',
'id' => 13,
'title' => 'Editors',
),
'score' => 1,
'index' => NULL,
@@ -54,8 +54,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 13,
'title' => 'Editors',
'id' => 14,
'title' => 'Administrator User',
),
'score' => 1,
'index' => NULL,
@@ -65,8 +65,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 14,
'title' => 'Administrator User',
'id' => 4,
'title' => 'Users',
),
'score' => 1,
'index' => NULL,
@@ -10,8 +10,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 4,
'title' => 'Users',
'id' => 10,
'title' => 'Anonymous User',
),
'score' => 1,
'index' => NULL,
@@ -21,8 +21,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 10,
'title' => 'Anonymous User',
'id' => 12,
'title' => 'Administrator users',
),
'score' => 1,
'index' => NULL,
@@ -32,8 +32,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 12,
'title' => 'Administrator users',
'id' => 13,
'title' => 'Editors',
),
'score' => 1,
'index' => NULL,
@@ -43,8 +43,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 13,
'title' => 'Editors',
'id' => 4,
'title' => 'Users',
),
'score' => 1,
'index' => NULL,
@@ -10,8 +10,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 4,
'title' => 'Users',
'id' => 10,
'title' => 'Anonymous User',
),
'score' => 1,
'index' => NULL,
@@ -21,8 +21,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 10,
'title' => 'Anonymous User',
'id' => 4,
'title' => 'Users',
),
'score' => 1,
'index' => NULL,
@@ -10,8 +10,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 4,
'title' => 'Users',
'id' => 10,
'title' => 'Anonymous User',
),
'score' => 0.35355337999999997,
'index' => NULL,
@@ -21,8 +21,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 10,
'title' => 'Anonymous User',
'id' => 14,
'title' => 'Administrator User',
),
'score' => 0.35355337999999997,
'index' => NULL,
@@ -32,8 +32,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 14,
'title' => 'Administrator User',
'id' => 4,
'title' => 'Users',
),
'score' => 0.35355337999999997,
'index' => NULL,
@@ -10,8 +10,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 4,
'title' => 'Users',
'id' => 11,
'title' => 'Members',
),
'score' => 1,
'index' => NULL,
@@ -21,8 +21,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 11,
'title' => 'Members',
'id' => 12,
'title' => 'Administrator users',
),
'score' => 1,
'index' => NULL,
@@ -32,8 +32,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 12,
'title' => 'Administrator users',
'id' => 13,
'title' => 'Editors',
),
'score' => 1,
'index' => NULL,
@@ -43,8 +43,8 @@
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array (
'id' => 13,
'title' => 'Editors',
'id' => 4,
'title' => 'Users',
),
'score' => 1,
'index' => NULL,
Oops, something went wrong.

0 comments on commit 784b3da

Please sign in to comment.
You can’t perform that action at this time.