DomainGetResponseTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Drupal\Tests\domain\Functional;
  3. /**
  4. * Tests domain record HTTP response.
  5. *
  6. * @group domain
  7. */
  8. class DomainGetResponseTest extends DomainTestBase {
  9. /**
  10. * Tests that a domain response is proper.
  11. */
  12. public function testDomainResponse() {
  13. // No domains should exist.
  14. $this->domainTableIsEmpty();
  15. // Create a new domain programmatically.
  16. $this->domainCreateTestDomains();
  17. // Check the created domain based on its known id value.
  18. $key = 'example_com';
  19. /** @var \Drupal\domain\Entity\Domain $domain */
  20. $domain = \Drupal::entityTypeManager()->getStorage('domain')->load($key);
  21. // Our testing server should be able to access the test PNG file.
  22. $this->assert($domain->getResponse() == 200, 'Server returned a 200 response.');
  23. // Now create a bad domain.
  24. $values = [
  25. 'hostname' => 'foo.bar',
  26. 'id' => 'foo_bar',
  27. 'name' => 'Foo',
  28. ];
  29. $domain = \Drupal::entityTypeManager()->getStorage('domain')->create($values);
  30. $domain->save();
  31. $this->assert($domain->getResponse() == 500, 'Server test returned a 500 response.');
  32. }
  33. }