diff --git a/tests/src/Unit/Plugin/Processor/AddHierarchyTest.php b/tests/src/Unit/Plugin/Processor/AddHierarchyTest.php deleted file mode 100644 index e3be2a3..0000000 --- a/tests/src/Unit/Plugin/Processor/AddHierarchyTest.php +++ /dev/null @@ -1,105 +0,0 @@ -processor = new AddHierarchy(array(), 'hierarchy', array()); - $this->translation = $this->getStringTranslationStub(); - $this->processor->setStringTranslation($this->translation); - } - - /** - * Test data properties alter. - * - * @covers ::alterPropertyDefinitions - * @covers ::isEntityReferenceField - */ - public function testAlterPropertyDefinitions() { - // Without a datasource, properties should be unaltered. - $expected = $properties = array( - 'foo' => 'bar', - ); - $this->processor->alterPropertyDefinitions($properties); - $this->assertArrayEquals($expected, $properties); - - // Test with a non-entity reference. - $field = $this->prophesize(FieldInterface::class); - $field->getOriginalType()->willReturn('string'); - $index = $this->prophesize(IndexInterface::class); - $index->getFields()->willReturn(array($field->reveal())); - $datasource = $this->prophesize(DatasourceInterface::class); - $datasource->getIndex()->willReturn($index->reveal()); - $this->processor->alterPropertyDefinitions($properties, $datasource->reveal()); - $this->assertArrayEquals($expected, $properties); - - // Test with a field item, but not an entity reference field. - $field = $this->prophesize(FieldInterface::class); - $field->getOriginalType()->willReturn('field_item:string'); - $index = $this->prophesize(IndexInterface::class); - $index->getFields()->willReturn([$field->reveal()]); - $datasource = $this->prophesize(DatasourceInterface::class); - $datasource->getIndex()->willReturn($index->reveal()); - $this->processor->alterPropertyDefinitions($properties, $datasource->reveal()); - $this->assertArrayEquals($expected, $properties); - - // Test with an entity reference field. - $field = $this->prophesize(FieldInterface::class); - $field->getOriginalType()->willReturn('field_item:entity_reference'); - $field->getLabel()->willReturn('Foo field'); - $field->getFieldIdentifier()->willReturn('foo_field'); - $index = $this->prophesize(IndexInterface::class); - $index->getFields()->willReturn([$field->reveal()]); - $datasource = $this->prophesize(DatasourceInterface::class); - $datasource->getIndex()->willReturn($index->reveal()); - $this->processor->alterPropertyDefinitions($properties, $datasource->reveal()); - $definition = array( - 'label' => $this->translation->translate('Hierarchy of %field', array('%field' => 'Foo field')), - 'description' => $this->translation->translate('The complete hierarchy for the entity reference', array()), - 'type' => 'string', - 'locked' => TRUE, - ); - $expected = array( - 'foo' => 'bar', - 'search_api_hierarchy:foo_field' => new DataDefinition($definition), - ); - $this->assertArrayEquals($expected, $properties); - } - -}