You are here

public function ConfigActionsModuleTest::testEnable in Config Actions 8

Test enabling module.

File

tests/src/Kernel/ConfigActionsModuleTest.php, line 61

Class

ConfigActionsModuleTest
test the ConfigActions module

Namespace

Drupal\Tests\config_actions\Kernel

Code

public function testEnable() {

  // Test that the field storage config got created.
  $field_storage = $this
    ->getConfig('field.storage.node.myproject_image');
  $this
    ->assertEquals('myproject_image', $field_storage['field_name'], 'Field storage has correct field_name.');
  $this
    ->assertEquals('node.myproject_image', $field_storage['id'], 'Field storage has correct id.');

  // Test that the field instance config got created.
  $field_instance = $this
    ->getConfig('field.field.node.article.myproject_image');
  $this
    ->assertEquals('myproject_image', $field_instance['field_name'], 'Field instance has correct field base.');
  $this
    ->assertEquals('node.article.myproject_image', $field_instance['id'], 'Field instance has correct id.');
  $this
    ->assertEquals([
    'field.storage.node.myproject_image',
    'node.type.article',
  ], $field_instance['dependencies']['config'], 'Field instance has correct config dependencies.');

  // Test that creating a article node actually has this new field.
  // Cannot do this from KernelTest.

  //$node = $this->drupalCreateNode(array('type' => 'article'));

  //$this->assertEquals('myproject_image', $node->myproject_image->getName(), 'Article node has correct image field.');

  // Test the override of the short date label.
  $date_config = $this
    ->getConfig('core.date_format.short');
  $this
    ->assertEquals('Test short date', $date_config['label']);
}