DomainNegotiatorTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Drupal\Tests\domain\Functional;
  3. use Drupal\Core\Session\AccountInterface;
  4. /**
  5. * Tests the domain negotiation manager.
  6. *
  7. * @group domain
  8. */
  9. class DomainNegotiatorTest extends DomainTestBase {
  10. /**
  11. * Modules to enable.
  12. *
  13. * @var array
  14. */
  15. public static $modules = ['domain', 'domain_test', 'block'];
  16. /**
  17. * Tests the handling of an inbound request.
  18. */
  19. public function testDomainNegotiator() {
  20. // No domains should exist.
  21. $this->domainTableIsEmpty();
  22. // Create four new domains programmatically.
  23. $this->domainCreateTestDomains(4);
  24. // Since we cannot read the service request, we place a block
  25. // which shows the current domain information.
  26. $this->drupalPlaceBlock('domain_server_block');
  27. // To get around block access, let the anon user view the block.
  28. user_role_grant_permissions(AccountInterface::ANONYMOUS_ROLE, ['view domain information']);
  29. // Test the response of the default home page.
  30. foreach (\Drupal::entityTypeManager()->getStorage('domain')->loadMultiple() as $domain) {
  31. $this->drupalGet($domain->getPath());
  32. $this->assertRaw($domain->label(), 'Loaded the proper domain.');
  33. }
  34. }
  35. }