AlterTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/Form/AlterTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Form;
use Drupal\Component\Utility\Xss;
use Drupal\Tests\BrowserTestBase;
class AlterTest extends BrowserTestBase {
public static $modules = [
'block',
'form_test',
];
protected $defaultTheme = 'stark';
public function testExecutionOrder() {
$this
->drupalGet('form-test/alter');
$expected = [
'block_form_form_test_alter_form_alter() executed.',
'form_test_form_alter() executed.',
'form_test_form_form_test_alter_form_alter() executed.',
'system_form_form_test_alter_form_alter() executed.',
];
$content = preg_replace('/\\s+/', ' ', Xss::filter($this
->getSession()
->getPage()
->getContent(), []));
$this
->assertStringContainsString(implode(' ', $expected), $content, 'Form alter hooks executed in the expected order.');
}
}