當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FieldConfig::calculateDependencies方法代碼示例

本文整理匯總了PHP中Drupal\field\Entity\FieldConfig::calculateDependencies方法的典型用法代碼示例。如果您正苦於以下問題:PHP FieldConfig::calculateDependencies方法的具體用法?PHP FieldConfig::calculateDependencies怎麽用?PHP FieldConfig::calculateDependencies使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\field\Entity\FieldConfig的用法示例。


在下文中一共展示了FieldConfig::calculateDependencies方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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->any())->method('getDefinition')->with('test_entity_type')->will($this->returnValue($target_entity_type));
     $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['entity']);
     $this->assertContains('test.test_entity_type.id', $dependencies['entity']);
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:20,代碼來源:FieldConfigEntityUnitTest.php

示例3: 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:aWEBoLabs,項目名稱:taxi,代碼行數:20,代碼來源:FieldConfigEntityUnitTest.php


注:本文中的Drupal\field\Entity\FieldConfig::calculateDependencies方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。