class AlterTest
Same name in this branch
- 9 core/modules/system/tests/src/Functional/Common/AlterTest.php \Drupal\Tests\system\Functional\Common\AlterTest
- 9 core/tests/Drupal/KernelTests/Core/Database/AlterTest.php \Drupal\KernelTests\Core\Database\AlterTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Kernel/Common/AlterTest.php \Drupal\Tests\system\Kernel\Common\AlterTest
- 11.x core/modules/system/tests/src/Functional/Form/AlterTest.php \Drupal\Tests\system\Functional\Form\AlterTest
- 11.x core/tests/Drupal/KernelTests/Core/Database/AlterTest.php \Drupal\KernelTests\Core\Database\AlterTest
- 10 core/modules/system/tests/src/Kernel/Common/AlterTest.php \Drupal\Tests\system\Kernel\Common\AlterTest
- 10 core/modules/system/tests/src/Functional/Form/AlterTest.php \Drupal\Tests\system\Functional\Form\AlterTest
- 10 core/tests/Drupal/KernelTests/Core/Database/AlterTest.php \Drupal\KernelTests\Core\Database\AlterTest
- 8.9.x core/modules/system/tests/src/Functional/Form/AlterTest.php \Drupal\Tests\system\Functional\Form\AlterTest
- 8.9.x core/modules/system/tests/src/Functional/Common/AlterTest.php \Drupal\Tests\system\Functional\Common\AlterTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/AlterTest.php \Drupal\KernelTests\Core\Database\AlterTest
Tests hook_form_alter() and hook_form_FORM_ID_alter().
@group Form
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\Form\AlterTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of AlterTest
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ AlterTest.php, line 13
Namespace
Drupal\Tests\system\Functional\FormView source
class AlterTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'block',
'form_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests execution order of hook_form_alter() and hook_form_FORM_ID_alter().
*/
public function testExecutionOrder() {
$this->drupalGet('form-test/alter');
// Ensure that the order is first by module, then for a given module, the
// id-specific one after the generic one.
$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.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.