DomainConfigHookTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Drupal\Tests\domain_config\Functional;
  3. use Drupal\Tests\BrowserTestBase;
  4. /**
  5. * Tests the domain config system.
  6. *
  7. * @group domain_config
  8. */
  9. class DomainConfigHookTest extends BrowserTestBase {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static $modules = [
  14. 'domain',
  15. // See module info file for description of what this module does.
  16. 'domain_config_hook_test',
  17. ];
  18. /**
  19. * Test to ensure a domain_config_hook_test_user_login() does not run.
  20. *
  21. * This test serves as a control to show the domain_config_hook_test module
  22. * functions correctly on it's own. Only when you add the domain_config
  23. * module, does it fail.
  24. */
  25. public function testHookRuns() {
  26. $this->drupalGet('user/login');
  27. $user = $this->drupalCreateUser([]);
  28. $edit = ['name' => $user->getUserName(), 'pass' => $user->passRaw];
  29. $this->drupalPostForm(NULL, $edit, t('Log in'));
  30. $test = \Drupal::state()->get('domain_config_test__user_login', NULL);
  31. // When this test passes, it means domain_config_hook_test_user_login was
  32. // not run.
  33. $this->assertNull($test, 'The hook_user_login state message is set.');
  34. }
  35. }