ConfigActionsModuleTest.php in Config Actions 8
File
tests/src/Kernel/ConfigActionsModuleTest.php
View source
<?php
namespace Drupal\Tests\config_actions\Kernel;
use Drupal\KernelTests\KernelTestBase;
class ConfigActionsModuleTest extends KernelTestBase {
public static $modules = [
'node',
'system',
'user',
'file',
'image',
'config_actions',
'test_config_actions',
];
protected $strictConfigSchema = FALSE;
protected $configActions;
protected function setUp() {
parent::setUp();
$this->configActions = \Drupal::service('config_actions');
parent::installConfig([
'system',
]);
config_actions_modules_installed([
'test_config_actions',
]);
}
protected function getConfig($id) {
return \Drupal::service('config.factory')
->get($id)
->get();
}
public function testEnable() {
$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.');
$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.');
$date_config = $this
->getConfig('core.date_format.short');
$this
->assertEquals('Test short date', $date_config['label']);
}
}