本文整理汇总了PHP中Drupal\field\Entity\FieldStorageConfig::calculateDependencies方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldStorageConfig::calculateDependencies方法的具体用法?PHP FieldStorageConfig::calculateDependencies怎么用?PHP FieldStorageConfig::calculateDependencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\field\Entity\FieldStorageConfig
的用法示例。
在下文中一共展示了FieldStorageConfig::calculateDependencies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']);
}
示例2: testCalculateDependencies
/**
* @covers ::calculateDependencies
*/
public function testCalculateDependencies()
{
// Create a mock entity type for FieldStorageConfig.
$fieldStorageConfigentityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$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->at(0))->method('getDefinition')->with('field_storage_config')->will($this->returnValue($fieldStorageConfigentityType));
$this->entityManager->expects($this->at(1))->method('getDefinition')->with($attached_entity_type_id)->will($this->returnValue($attached_entity_type));
$this->entityManager->expects($this->at(2))->method('getDefinition')->with('field_storage_config')->will($this->returnValue($fieldStorageConfigentityType));
$field_storage = new FieldStorageConfig(array('entity_type' => $attached_entity_type_id, 'field_name' => 'test_field', 'type' => 'test_field_type', 'module' => 'test_module'));
$dependencies = $field_storage->calculateDependencies();
$this->assertContains('test_module', $dependencies['module']);
$this->assertContains('entity_provider_module', $dependencies['module']);
}