当前位置: 首页>>代码示例>>PHP>>正文


PHP FieldTypePluginManagerInterface::expects方法代码示例

本文整理汇总了PHP中Drupal\Core\Field\FieldTypePluginManagerInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldTypePluginManagerInterface::expects方法的具体用法?PHP FieldTypePluginManagerInterface::expects怎么用?PHP FieldTypePluginManagerInterface::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Field\FieldTypePluginManagerInterface的用法示例。


在下文中一共展示了FieldTypePluginManagerInterface::expects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testOnDependencyRemoval

 /**
  * @covers ::onDependencyRemoval
  */
 public function testOnDependencyRemoval()
 {
     $this->fieldTypePluginManager->expects($this->any())->method('getDefinition')->with('test_field')->willReturn(['class' => '\\Drupal\\Tests\\field\\Unit\\DependencyFieldItem']);
     $field = new FieldConfig(['field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle', 'field_type' => 'test_field', 'dependencies' => ['module' => ['fruiter']], 'third_party_settings' => ['fruiter' => ['fruit' => 'apple']]]);
     $changed = $field->onDependencyRemoval(['module' => ['fruiter']]);
     $this->assertTrue($changed);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:FieldConfigEntityUnitTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityManager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->formatterPluginManager = $this->getMockBuilder('Drupal\\Core\\Field\\FormatterPluginManager')->disableOriginalConstructor()->getMock();
     $this->fieldTypePluginManager = $this->getMock('Drupal\\Core\\Field\\FieldTypePluginManagerInterface');
     $this->fieldTypePluginManager->expects($this->any())->method('getDefaultStorageSettings')->willReturn([]);
     $this->fieldTypePluginManager->expects($this->any())->method('getDefaultFieldSettings')->willReturn([]);
     $this->languageManager = $this->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
     $this->renderer = $this->getMock('Drupal\\Core\\Render\\RendererInterface');
     $this->setupExecutableAndView();
     $this->setupViewsData();
     $this->display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')->disableOriginalConstructor()->getMock();
     $this->container = new ContainerBuilder();
     $this->container->set('plugin.manager.field.field_type', $this->fieldTypePluginManager);
     \Drupal::setContainer($this->container);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:20,代码来源:FieldTest.php

示例3: testCalculateDependencies

 /**
  * @covers ::calculateDependencies
  */
 public function testCalculateDependencies()
 {
     // Create a mock entity type for FieldStorageConfig.
     $fieldStorageConfigentityType = $this->getMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityTypeInterface');
     $fieldStorageConfigentityType->expects($this->any())->method('getProvider')->will($this->returnValue('field'));
     // Create a mock entity type to attach the field to.
     $attached_entity_type_id = $this->randomMachineName();
     $attached_entity_type = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
     $attached_entity_type->expects($this->any())->method('getProvider')->will($this->returnValue('entity_provider_module'));
     // Get definition is called three times. Twice in
     // ConfigEntityBase::addDependency() to get the provider of the field config
     // entity type and once in FieldStorageConfig::calculateDependencies() to
     // get the provider of the entity type that field is attached to.
     $this->entityManager->expects($this->any())->method('getDefinition')->willReturnMap([['field_storage_config', TRUE, $fieldStorageConfigentityType], [$attached_entity_type_id, TRUE, $attached_entity_type]]);
     $this->fieldTypeManager->expects($this->atLeastOnce())->method('getDefinition')->with('test_field_type', FALSE)->willReturn(['class' => TestFieldType::class]);
     $field_storage = new FieldStorageConfig(['entity_type' => $attached_entity_type_id, 'field_name' => 'test_field', 'type' => 'test_field_type', 'module' => 'test_module']);
     $dependencies = $field_storage->calculateDependencies()->getDependencies();
     $this->assertEquals(['entity_provider_module', 'entity_test', 'test_module'], $dependencies['module']);
     $this->assertEquals(['stark'], $dependencies['theme']);
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:23,代码来源:FieldStorageConfigEntityUnitTest.php

示例4: testCalculateDependenciesIncorrectBundle

 /**
  * Test that invalid bundles are handled.
  *
  * @expectedException \LogicException
  * @expectedExceptionMessage Missing bundle entity, entity type bundle_entity_type, entity id test_bundle_not_exists.
  */
 public function testCalculateDependenciesIncorrectBundle()
 {
     $storage = $this->getMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
     $storage->expects($this->any())->method('load')->with('test_bundle_not_exists')->will($this->returnValue(NULL));
     $this->entityManager->expects($this->any())->method('getStorage')->with('bundle_entity_type')->will($this->returnValue($storage));
     $target_entity_type = new EntityType(array('id' => 'test_entity_type', 'bundle_entity_type' => 'bundle_entity_type'));
     $this->entityManager->expects($this->at(0))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
     $this->entityManager->expects($this->at(1))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
     $this->entityManager->expects($this->at(2))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
     $this->entityManager->expects($this->at(3))->method('getDefinition')->with('test_entity_type')->willReturn($target_entity_type);
     $this->fieldTypePluginManager->expects($this->any())->method('getDefinition')->with('test_field')->willReturn(['provider' => 'test_module', 'config_dependencies' => ['module' => ['test_module2']], 'class' => '\\Drupal\\Tests\\field\\Unit\\DependencyFieldItem']);
     $field = new FieldConfig(array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle_not_exists', 'field_type' => 'test_field'), $this->entityTypeId);
     $field->calculateDependencies();
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:20,代码来源:FieldConfigEntityUnitTest.php

示例5: testCalculateDependencies

 /**
  * @covers ::calculateDependencies
  */
 public function testCalculateDependencies()
 {
     // Mock the interfaces necessary to create a dependency on a bundle entity.
     $bundle_entity = $this->getMock('Drupal\\Core\\Config\\Entity\\ConfigEntityInterface');
     $bundle_entity->expects($this->any())->method('getConfigDependencyName')->will($this->returnValue('test.test_entity_type.id'));
     $storage = $this->getMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
     $storage->expects($this->any())->method('load')->with('test_bundle')->will($this->returnValue($bundle_entity));
     $this->entityManager->expects($this->any())->method('getStorage')->with('bundle_entity_type')->will($this->returnValue($storage));
     $target_entity_type = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
     $target_entity_type->expects($this->any())->method('getBundleEntityType')->will($this->returnValue('bundle_entity_type'));
     $this->entityManager->expects($this->at(0))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
     $this->entityManager->expects($this->at(1))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
     $this->entityManager->expects($this->at(2))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
     $this->entityManager->expects($this->at(3))->method('getDefinition')->with('test_entity_type')->willReturn($target_entity_type);
     $this->fieldTypePluginManager->expects($this->any())->method('getDefinition')->with('test_field')->willReturn(['provider' => 'test_module', 'config_dependencies' => ['module' => ['test_module2']], 'class' => '\\Drupal\\Tests\\field\\Unit\\DependencyFieldItem']);
     $this->fieldStorage->expects($this->once())->method('getConfigDependencyName')->will($this->returnValue('field.storage.test_entity_type.test_field'));
     $field = new FieldConfig(array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle', 'field_type' => 'test_field'), $this->entityTypeId);
     $dependencies = $field->calculateDependencies();
     $this->assertContains('field.storage.test_entity_type.test_field', $dependencies['config']);
     $this->assertContains('test.test_entity_type.id', $dependencies['config']);
     $this->assertEquals(['test_module', 'test_module2', 'test_module3'], $dependencies['module']);
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:25,代码来源:FieldConfigEntityUnitTest.php


注:本文中的Drupal\Core\Field\FieldTypePluginManagerInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。