本文整理汇总了PHP中Drupal\Core\Entity\EntityTypeInterface::reveal方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityTypeInterface::reveal方法的具体用法?PHP EntityTypeInterface::reveal怎么用?PHP EntityTypeInterface::reveal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityTypeInterface
的用法示例。
在下文中一共展示了EntityTypeInterface::reveal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @covers ::__construct
*/
public function setUp()
{
parent::setUp();
$this->contextHandler = $this->prophesize(ContextHandlerInterface::class);
$this->entityType = $this->prophesize(EntityTypeInterface::class);
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$module_handler->invokeAll(Argument::cetera())->willReturn([]);
$this->pageAccess = new PageAccess($this->entityType->reveal(), $this->contextHandler->reveal());
$this->pageAccess->setModuleHandler($module_handler->reveal());
}
示例2: setUp
/**
* @covers ::__construct
*/
public function setUp()
{
parent::setUp();
$this->contextHandler = $this->prophesize(ContextHandlerInterface::class);
$this->entityType = $this->prophesize(EntityTypeInterface::class);
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$module_handler->invokeAll(Argument::cetera())->willReturn([]);
$this->pageAccess = new PageAccess($this->entityType->reveal(), $this->contextHandler->reveal());
$this->pageAccess->setModuleHandler($module_handler->reveal());
$this->cacheContextsManager = $this->prophesize(CacheContextsManager::class);
$container = new ContainerBuilder();
$container->set('cache_contexts_manager', $this->cacheContextsManager->reveal());
\Drupal::setContainer($container);
}
示例3: getEntity
/**
* Returns a mock entity for testing.
*
* @param string $class
* The class name to mock. Should be \Drupal\Core\Entity\Entity or a
* subclass.
* @param array $values
* An array of entity values to construct the mock entity with.
* @param array $methods
* (optional) An array of additional methods to mock on the entity object.
* The getEntityType() and entityManager() methods are always mocked.
*
* @return \Drupal\Core\Entity\Entity|\PHPUnit_Framework_MockObject_MockObject
*/
protected function getEntity($class, array $values, array $methods = [])
{
$methods = array_merge($methods, ['getEntityType', 'entityManager']);
// Prophecy does not allow prophesizing abstract classes while actually
// calling their code. We use Prophecy below because that allows us to
// add method prophecies later while still revealing the prophecy now.
$entity = $this->getMockBuilder($class)->setConstructorArgs([$values, $this->entityTypeId])->setMethods($methods)->getMockForAbstractClass();
$this->entityType = $this->prophesize(EntityTypeInterface::class);
$this->entityType->getLinkTemplates()->willReturn([]);
$this->entityType->getKey('langcode')->willReturn(FALSE);
$entity->method('getEntityType')->willReturn($this->entityType->reveal());
$this->entityManager = $this->prophesize(EntityManagerInterface::class);
$entity->method('entityManager')->willReturn($this->entityManager->reveal());
return $entity;
}