/** * Tests that getFieldDefinitions() method sets the 'provider' definition key. * * @covers ::getFieldDefinitions * @covers ::buildBundleFieldDefinitions */ public function testGetFieldDefinitionsProvider() { $this->setUpEntityWithFieldDefinition(TRUE); $module = 'entity_manager_test_module'; // @todo Mock FieldDefinitionInterface once it exposes a proper provider // setter. See https://www.drupal.org/node/2225961. $field_definition = $this->prophesize(BaseFieldDefinition::class); // We expect two calls as the field definition will be returned from both // base and bundle entity field info hook implementations. $field_definition->getProvider()->shouldBeCalled(); $field_definition->setProvider($module)->shouldBeCalledTimes(2); $field_definition->setName(0)->shouldBeCalledTimes(2); $field_definition->setTargetEntityTypeId('test_entity_type')->shouldBeCalled(); $field_definition->setTargetBundle(NULL)->shouldBeCalled(); $field_definition->setTargetBundle('test_bundle')->shouldBeCalled(); $this->moduleHandler->getImplementations(Argument::type('string'))->willReturn([$module]); $this->moduleHandler->invoke($module, 'entity_base_field_info', [$this->entityType])->willReturn([$field_definition->reveal()]); $this->moduleHandler->invoke($module, 'entity_bundle_field_info', Argument::type('array'))->willReturn([$field_definition->reveal()]); $this->entityManager->getFieldDefinitions('test_entity_type', 'test_bundle'); }