本文整理汇总了PHP中Drupal\Core\Config\Entity\ConfigEntityInterface::getOriginalId方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigEntityInterface::getOriginalId方法的具体用法?PHP ConfigEntityInterface::getOriginalId怎么用?PHP ConfigEntityInterface::getOriginalId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\Entity\ConfigEntityInterface
的用法示例。
在下文中一共展示了ConfigEntityInterface::getOriginalId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSaveRename
/**
* @covers ::save
* @covers ::doSave
*
* @depends testSaveInsert
*/
public function testSaveRename(ConfigEntityInterface $entity)
{
$config_object = $this->getMockBuilder('Drupal\\Core\\Config\\Config')->disableOriginalConstructor()->getMock();
$config_object->expects($this->atLeastOnce())->method('isNew')->will($this->returnValue(FALSE));
$config_object->expects($this->exactly(1))->method('setData');
$config_object->expects($this->once())->method('save');
$config_object->expects($this->atLeastOnce())->method('get')->willReturn([]);
$this->cacheTagsInvalidator->expects($this->once())->method('invalidateTags')->with(array($this->entityTypeId . '_list'));
$this->configFactory->expects($this->once())->method('rename')->willReturn($this->configFactory);
$this->configFactory->expects($this->exactly(1))->method('getEditable')->with('the_config_prefix.bar')->will($this->returnValue($config_object));
$this->configFactory->expects($this->exactly(2))->method('loadMultiple')->with(array('the_config_prefix.foo'))->will($this->returnValue(array()));
$this->configFactory->expects($this->once())->method('get')->with('the_config_prefix.foo')->will($this->returnValue($config_object));
// Performing a rename does not change the original ID until saving.
$this->assertSame('foo', $entity->getOriginalId());
$entity->set('id', 'bar');
$this->assertSame('foo', $entity->getOriginalId());
$this->entityQuery->expects($this->once())->method('condition')->with('uuid', 'bar')->will($this->returnSelf());
$this->entityQuery->expects($this->once())->method('execute')->will($this->returnValue(array($entity->id())));
$return = $this->entityStorage->save($entity);
$this->assertSame(SAVED_UPDATED, $return);
$this->assertSame('bar', $entity->getOriginalId());
}