d1a269a6a26c44a79a548d288eec569caa60431b
[yaffs-website] / web / core / modules / field / tests / src / Kernel / TestItemWithDependenciesTest.php
1 <?php
2
3 namespace Drupal\Tests\field\Kernel;
4
5 use Drupal\field\Entity\FieldConfig;
6 use Drupal\field\Entity\FieldStorageConfig;
7
8 /**
9  * Tests the new entity API for the test field with dependencies type.
10  *
11  * @group field
12  */
13 class TestItemWithDependenciesTest extends FieldKernelTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['field_test'];
21
22   /**
23    * The name of the field to use in this test.
24    *
25    * @var string
26    */
27   protected $fieldName = 'field_test';
28
29   /**
30    * Tests that field types can add dependencies to field config entities.
31    */
32   public function testTestItemWithDepenencies() {
33     // Create a 'test_field_with_dependencies' field and storage for validation.
34     FieldStorageConfig::create([
35       'field_name' => $this->fieldName,
36       'entity_type' => 'entity_test',
37       'type' => 'test_field_with_dependencies',
38     ])->save();
39     $field = FieldConfig::create([
40       'entity_type' => 'entity_test',
41       'field_name' => $this->fieldName,
42       'bundle' => 'entity_test',
43     ]);
44     $field->save();
45
46     // Validate that the field configuration entity has the expected
47     // dependencies.
48     $this->assertEqual([
49       'content' => ['node:article:uuid'],
50       'config' => ['field.storage.entity_test.field_test'],
51       'module' => ['entity_test', 'field_test', 'test_module']
52     ], $field->getDependencies());
53   }
54
55 }