You are here

function AlterTest::testExecutionOrder in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Form/AlterTest.php \Drupal\system\Tests\Form\AlterTest::testExecutionOrder()

Tests execution order of hook_form_alter() and hook_form_FORM_ID_alter().

File

core/modules/system/src/Tests/Form/AlterTest.php, line 30
Contains \Drupal\system\Tests\Form\AlterTest.

Class

AlterTest
Tests hook_form_alter() and hook_form_FORM_ID_alter().

Namespace

Drupal\system\Tests\Form

Code

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 = array(
    '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->content, array()));
  $this
    ->assert(strpos($content, implode(' ', $expected)) !== FALSE, 'Form alter hooks executed in the expected order.');
}