TestItemWithDependenciesTest.php in Drupal 8        
                          
                  
                        
  
  
  
  
File
  core/modules/field/tests/src/Kernel/TestItemWithDependenciesTest.php
  
    View source  
  <?php
namespace Drupal\Tests\field\Kernel;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
class TestItemWithDependenciesTest extends FieldKernelTestBase {
  
  public static $modules = [
    'field_test',
  ];
  
  protected $fieldName = 'field_test';
  
  public function testTestItemWithDepenencies() {
    
    FieldStorageConfig::create([
      'field_name' => $this->fieldName,
      'entity_type' => 'entity_test',
      'type' => 'test_field_with_dependencies',
    ])
      ->save();
    $field = FieldConfig::create([
      'entity_type' => 'entity_test',
      'field_name' => $this->fieldName,
      'bundle' => 'entity_test',
    ]);
    $field
      ->save();
    
    $this
      ->assertEqual([
      'content' => [
        'node:article:uuid',
      ],
      'config' => [
        'field.storage.entity_test.field_test',
      ],
      'module' => [
        'entity_test',
        'field_test',
        'test_module',
      ],
    ], $field
      ->getDependencies());
  }
}