ConfigEntityFormOverrideTest.php in Zircon Profile 8.0
File
core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php
View source
<?php
namespace Drupal\config\Tests;
use Drupal\simpletest\WebTestBase;
class ConfigEntityFormOverrideTest extends WebTestBase {
public static $modules = array(
'config_test',
);
public function testFormsWithOverrides() {
$this
->drupalLogin($this
->drupalCreateUser([
'administer site configuration',
]));
$original_label = 'Default';
$overridden_label = 'Overridden label';
$edited_label = 'Edited label';
$config_test_storage = $this->container
->get('entity.manager')
->getStorage('config_test');
$settings['config']['config_test.dynamic.dotted.default']['label'] = (object) array(
'value' => $overridden_label,
'required' => TRUE,
);
$this
->writeSettings($settings);
$this
->assertEqual($config_test_storage
->load('dotted.default')
->label(), $overridden_label);
$this
->drupalGet('admin/structure/config_test');
$this
->assertText($original_label);
$this
->assertNoText($overridden_label);
$this
->drupalGet('admin/structure/config_test/manage/dotted.default');
$elements = $this
->xpath('//input[@name="label"]');
$this
->assertIdentical((string) $elements[0]['value'], $original_label);
$this
->assertNoText($overridden_label);
$edit = array(
'label' => $edited_label,
);
$this
->drupalPostForm(NULL, $edit, t('Save'));
$this
->drupalGet('admin/structure/config_test');
$this
->assertNoText($overridden_label);
$this
->assertText($edited_label);
$this
->drupalGet('admin/structure/config_test/manage/dotted.default');
$elements = $this
->xpath('//input[@name="label"]');
$this
->assertIdentical((string) $elements[0]['value'], $edited_label);
$this
->assertEqual($config_test_storage
->load('dotted.default')
->label(), $overridden_label);
}
}