/** * @covers ::onFieldDefinitionUpdate */ public function testOnFieldDefinitionUpdate() { $field_definition = $this->prophesize(FieldDefinitionInterface::class); $field_definition->getTargetEntityTypeId()->willReturn('test_entity_type'); $field = $field_definition->reveal(); $storage = $this->prophesize(DynamicallyFieldableEntityStorageInterface::class); $storage->onFieldDefinitionUpdate($field, $field) ->shouldBeCalledTimes(1); $entity = $this->prophesize(EntityTypeInterface::class); $this->entityManager->setHandler('storage', 'test_entity_type', $storage->reveal()); $this->setUpEntityManager(array('test_entity_type' => $entity)); $this->entityManager->onFieldDefinitionUpdate($field, $field); }
/** * @covers ::onFieldDefinitionUpdate */ public function testOnFieldDefinitionUpdate() { $field_definition = $this->prophesize(FieldDefinitionInterface::class); $field_definition->getTargetEntityTypeId()->willReturn('test_entity_type'); $class = $this->getMockClass(DynamicallyFieldableEntityStorageInterface::class); $entity = $this->prophesize(EntityTypeInterface::class); $entity->getHandlerClass('storage')->willReturn($class); $this->setUpEntityManager(array('test_entity_type' => $entity)); // The entity manager will instantiate a new object with the given class // name. Define the mock expectations on that. $storage = $this->entityManager->getStorage('test_entity_type'); $storage->expects($this->once())->method('onFieldDefinitionUpdate')->with($field_definition->reveal()); $this->entityManager->onFieldDefinitionUpdate($field_definition->reveal(), $field_definition->reveal()); }
/** * @covers ::onFieldDefinitionUpdate */ public function testonFieldDefinitionUpdate() { $field_definition = $this->getMock('Drupal\\Core\\Field\\FieldDefinitionInterface'); $field_definition->expects($this->atLeastOnce())->method('getTargetEntityTypeId')->willReturn('test_entity_type'); $storage = $this->getMock('Drupal\\Core\\Entity\\DynamicallyFieldableEntityStorageInterface'); $class = get_class($storage); $entity = $this->getMock('Drupal\\Core\\Entity\\EntityTypeInterface'); $entity->expects($this->once())->method('getHandlerClass')->with('storage')->will($this->returnValue($class)); $this->setUpEntityManager(array('test_entity_type' => $entity)); // The entity manager will instantiate a new object with the given class // name. Define the mock expectations on that. $storage = $this->entityManager->getStorage('test_entity_type'); $storage->expects($this->once())->method('onFieldDefinitionUpdate')->with($field_definition); $this->entityManager->onFieldDefinitionUpdate($field_definition, $field_definition); }