本文整理汇总了PHP中Drupal\Core\Entity\EntityTypeInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityTypeInterface::expects方法的具体用法?PHP EntityTypeInterface::expects怎么用?PHP EntityTypeInterface::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityTypeInterface
的用法示例。
在下文中一共展示了EntityTypeInterface::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
$this->entityTypeId = $this->randomMachineName();
$this->provider = $this->randomMachineName();
$this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue($this->provider));
$this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
$this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
}
示例2: testCreateInstance
/**
* @covers ::createInstance
* @covers ::__construct
*/
function testCreateInstance()
{
$this->entityType->expects($this->any())->method('id')->willReturn('currency');
$entity_manager = $this->getMock(EntityManagerInterface::class);
$entity_manager->expects($this->once())->method('getStorage')->with('currency')->willReturn($this->entityStorage);
$container = $this->getMock(ContainerInterface::class);
$map = array(array('entity.manager', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $entity_manager), array('module_handler', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->moduleHandler), array('string_translation', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->stringTranslation));
$container->expects($this->any())->method('get')->willReturnMap($map);
$sut = CurrencyLocaleListBuilder::createInstance($container, $this->entityType);
$this->assertInstanceOf(CurrencyLocaleListBuilder::class, $sut);
}
示例3: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue('responsive_image'));
$this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
$this->entityManager->expects($this->any())->method('getDefinition')->with('responsive_image_style')->will($this->returnValue($this->entityType));
$this->breakpointManager = $this->getMock('\\Drupal\\breakpoint\\BreakpointManagerInterface');
$container = new ContainerBuilder();
$container->set('entity.manager', $this->entityManager);
$container->set('breakpoint.manager', $this->breakpointManager);
\Drupal::setContainer($container);
}
示例4: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->entityType = $this->randomMachineName();
$this->entityInfo = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$this->entityInfo->expects($this->any())->method('getProvider')->will($this->returnValue('entity'));
$this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
$this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
$container = new ContainerBuilder();
$container->set('entity.manager', $this->entityManager);
$container->set('uuid', $this->uuid);
\Drupal::setContainer($container);
}
示例5: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
$this->entityTypeId = $this->randomName();
$this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue('breakpoint'));
$this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
$this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
$this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
$container = new ContainerBuilder();
$container->set('entity.manager', $this->entityManager);
$container->set('uuid', $this->uuid);
\Drupal::setContainer($container);
}
示例6: setUp
/**
* {@inheritdoc}
*
* @covers ::__construct()
*/
protected function setUp()
{
parent::setUp();
$this->entityType = $this->getMock('Drupal\\Core\\Entity\\EntityTypeInterface');
$this->entityTypeId = 'test_entity_type';
$this->entityType->expects($this->any())->method('getKey')->will($this->returnValueMap(array(array('id', 'id'), array('uuid', 'uuid'))));
$this->entityType->expects($this->any())->method('id')->will($this->returnValue($this->entityTypeId));
$this->entityType->expects($this->any())->method('getConfigPrefix')->will($this->returnValue('the_config_prefix'));
$this->entityType->expects($this->any())->method('getClass')->will($this->returnValue(get_class($this->getMockEntity())));
$this->entityType->expects($this->any())->method('getListCacheTags')->willReturn(array('test_entity_type_list'));
$this->moduleHandler = $this->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
$this->uuidService = $this->getMock('Drupal\\Component\\Uuid\\UuidInterface');
$this->languageManager = $this->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
$this->languageManager->expects($this->any())->method('getDefaultLanguage')->will($this->returnValue(new Language(array('langcode' => 'en'))));
$this->configFactory = $this->getMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
$this->entityQuery = $this->getMock('Drupal\\Core\\Entity\\Query\\QueryInterface');
$this->entityStorage = $this->getMockBuilder('Drupal\\Core\\Config\\Entity\\ConfigEntityStorage')->setConstructorArgs(array($this->entityType, $this->configFactory, $this->uuidService, $this->languageManager))->setMethods(array('getQuery'))->getMock();
$this->entityStorage->expects($this->any())->method('getQuery')->will($this->returnValue($this->entityQuery));
$this->entityStorage->setModuleHandler($this->moduleHandler);
$this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
$this->entityManager->expects($this->any())->method('getDefinition')->with('test_entity_type')->will($this->returnValue($this->entityType));
$this->cacheBackend = $this->getMock('Drupal\\Core\\Cache\\CacheBackendInterface');
$this->typedConfigManager = $this->getMock('Drupal\\Core\\Config\\TypedConfigManagerInterface');
$this->typedConfigManager->expects($this->any())->method('getDefinition')->will($this->returnValue(array('mapping' => array('id' => '', 'uuid' => '', 'dependencies' => ''))));
$container = new ContainerBuilder();
$container->set('entity.manager', $this->entityManager);
$container->set('config.typed', $this->typedConfigManager);
$container->set('cache.test', $this->cacheBackend);
$container->setParameter('cache_bins', array('cache.test' => 'test'));
\Drupal::setContainer($container);
}
示例7: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->editorId = $this->randomMachineName();
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue('editor'));
$this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
$this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
$this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
$this->editorPluginManager = $this->getMockBuilder('Drupal\\editor\\Plugin\\EditorManager')->disableOriginalConstructor()->getMock();
$container = new ContainerBuilder();
$container->set('entity.manager', $this->entityManager);
$container->set('uuid', $this->uuid);
$container->set('plugin.manager.editor', $this->editorPluginManager);
\Drupal::setContainer($container);
}
示例8: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
$this->entityTypeId = $this->randomName();
$this->provider = $this->randomName();
$this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue($this->provider));
$this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
$this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
$this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
$this->breakpointGroupId = $this->randomName(9);
$this->breakpointGroup = $this->getMock('Drupal\\breakpoint\\Entity\\BreakpointGroup', array(), array(array('name' => 'test', 'id' => $this->breakpointGroupId)));
$this->breakpointGroupStorage = $this->getMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
$this->breakpointGroupStorage->expects($this->any())->method('load')->with($this->breakpointGroupId)->will($this->returnValue($this->breakpointGroup));
$this->entityManager->expects($this->any())->method('getStorage')->will($this->returnValue($this->breakpointGroupStorage));
$container = new ContainerBuilder();
$container->set('entity.manager', $this->entityManager);
$container->set('uuid', $this->uuid);
\Drupal::setContainer($container);
}
示例9: testToArray
/**
* @covers ::toArray()
*/
public function testToArray()
{
$field = new FieldConfig(array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle', 'field_type' => 'test_field'), $this->entityTypeId);
$expected = array('id' => 'test_entity_type.test_bundle.field_test', 'uuid' => NULL, 'status' => TRUE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'field_name' => 'field_test', 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle', 'label' => '', 'description' => '', 'required' => FALSE, 'default_value' => array(), 'default_value_callback' => '', 'settings' => array(), 'dependencies' => array(), 'field_type' => 'test_field');
$this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
$this->entityType->expects($this->once())->method('getKey')->with('id')->will($this->returnValue('id'));
$this->typedConfigManager->expects($this->once())->method('getDefinition')->will($this->returnValue(array('mapping' => array_fill_keys(array_keys($expected), ''))));
$export = $field->toArray();
$this->assertEquals($expected, $export);
}
示例10: testLabel
/**
* @covers ::label
*/
public function testLabel()
{
// Make a mock with one method that we use as the entity's label callback.
// We check that it is called, and that the entity's label is the callback's
// return value.
$callback_label = $this->randomMachineName();
$callback_container = $this->getMock(get_class());
$callback_container->expects($this->once())->method(__FUNCTION__)->will($this->returnValue($callback_label));
$this->entityType->expects($this->once())->method('getLabelCallback')->will($this->returnValue(array($callback_container, __FUNCTION__)));
$this->assertSame($callback_label, $this->entity->label());
}
示例11: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
$this->editorId = $this->randomMachineName();
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue('editor'));
$this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
$this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
$this->uuid = $this->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
$this->editorPluginManager = $this->getMockBuilder('Drupal\\editor\\Plugin\\EditorManager')->disableOriginalConstructor()->getMock();
$this->moduleHandler = $this->getMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
$this->moduleHandler->expects($this->once())->method('invokeAll')->with('editor_default_settings', array($this->editorId))->will($this->returnValue(array()));
$this->moduleHandler->expects($this->once())->method('alter')->with('editor_default_settings', array(), $this->editorId)->will($this->returnValue(array()));
$container = new ContainerBuilder();
$container->set('entity.manager', $this->entityManager);
$container->set('uuid', $this->uuid);
$container->set('plugin.manager.editor', $this->editorPluginManager);
$container->set('module_handler', $this->moduleHandler);
\Drupal::setContainer($container);
}
示例12: testRender
/**
* @covers ::render
*
* @depends testBuildHeader
*/
public function testRender()
{
$query = $this->getMock(QueryInterface::class);
$query->expects($this->atLeastOnce())->method('pager')->willReturnSelf();
$query->expects($this->atLeastOnce())->method('sort')->willReturnSelf();
$this->entityStorage->expects($this->atLeastOnce())->method('getQuery')->willReturn($query);
$this->entityType->expects($this->any())->method('getClass')->willReturn(ConfigEntityBase::class);
$this->entityStorage->expects($this->once())->method('loadMultipleOverrideFree')->willReturn([]);
$build = $this->sut->render();
unset($build['table']['#attached']);
unset($build['table']['#header']);
$expected_build = array('#type' => 'table', '#title' => NULL, '#rows' => [], '#attributes' => array('class' => array('payment-method-configuration-list')), '#cache' => ['contexts' => NULL, 'tags' => NULL]);
$this->assertInstanceOf(TranslatableMarkup::class, $build['table']['#empty']);
unset($build['table']['#empty']);
$this->assertEquals($expected_build, $build['table']);
}
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:21,代码来源:PaymentMethodConfigurationListBuilderTest.php
示例13: testCreateDuplicate
/**
* @covers ::createDuplicate
*/
public function testCreateDuplicate()
{
$this->entityType->expects($this->at(0))->method('getKey')->with('id')->will($this->returnValue('id'));
$this->entityType->expects($this->at(1))->method('hasKey')->with('uuid')->will($this->returnValue(TRUE));
$this->entityType->expects($this->at(2))->method('getKey')->with('uuid')->will($this->returnValue('uuid'));
$new_uuid = '8607ef21-42bc-4913-978f-8c06207b0395';
$this->uuid->expects($this->once())->method('generate')->will($this->returnValue($new_uuid));
$duplicate = $this->entity->createDuplicate();
$this->assertInstanceOf('\\Drupal\\Core\\Entity\\Entity', $duplicate);
$this->assertNotSame($this->entity, $duplicate);
$this->assertFalse($this->entity->isNew());
$this->assertTrue($duplicate->isNew());
$this->assertNull($duplicate->id());
$this->assertNull($duplicate->getOriginalId());
$this->assertNotEquals($this->entity->uuid(), $duplicate->uuid());
$this->assertSame($new_uuid, $duplicate->uuid());
}
示例14: testDelete
/**
* @covers ::delete
* @covers ::doDelete
*/
public function testDelete()
{
$entities['foo'] = $this->getMockEntity('Drupal\\Core\\Entity\\Entity', array(array('id' => 'foo')));
$entities['bar'] = $this->getMockEntity('Drupal\\Core\\Entity\\Entity', array(array('id' => 'bar')));
$this->entityType->expects($this->once())->method('getClass')->will($this->returnValue(get_class(reset($entities))));
$this->setUpKeyValueEntityStorage();
$this->moduleHandler->expects($this->at(0))->method('invokeAll')->with('test_entity_type_predelete');
$this->moduleHandler->expects($this->at(1))->method('invokeAll')->with('entity_predelete');
$this->moduleHandler->expects($this->at(2))->method('invokeAll')->with('test_entity_type_predelete');
$this->moduleHandler->expects($this->at(3))->method('invokeAll')->with('entity_predelete');
$this->moduleHandler->expects($this->at(4))->method('invokeAll')->with('test_entity_type_delete');
$this->moduleHandler->expects($this->at(5))->method('invokeAll')->with('entity_delete');
$this->moduleHandler->expects($this->at(6))->method('invokeAll')->with('test_entity_type_delete');
$this->moduleHandler->expects($this->at(7))->method('invokeAll')->with('entity_delete');
$this->keyValueStore->expects($this->once())->method('deleteMultiple')->with(array('foo', 'bar'));
$this->entityStorage->delete($entities);
}
示例15: testLabel
/**
* @covers ::label
*/
public function testLabel()
{
// Make a mock with one method that we use as the entity's uri_callback. We
// check that it is called, and that the entity's label is the callback's
// return value.
$callback_label = $this->randomMachineName();
$property_label = $this->randomMachineName();
$callback_container = $this->getMock(get_class());
$callback_container->expects($this->once())->method(__FUNCTION__)->will($this->returnValue($callback_label));
$this->entityType->expects($this->at(0))->method('getLabelCallback')->will($this->returnValue(array($callback_container, __FUNCTION__)));
$this->entityType->expects($this->at(1))->method('getLabelCallback')->will($this->returnValue(NULL));
$this->entityType->expects($this->at(2))->method('getKey')->with('label')->will($this->returnValue('label'));
// Set a dummy property on the entity under test to test that the label can
// be returned form a property if there is no callback.
$this->entityManager->expects($this->at(1))->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue(array('entity_keys' => array('label' => 'label'))));
$this->entity->label = $property_label;
$this->assertSame($callback_label, $this->entity->label());
$this->assertSame($property_label, $this->entity->label());
}