You are here

public function SimpleTestExampleTest::testSimpleTestExampleMenu in Examples for Developers 8

Test SimpleTest Example menu and page.

Enable SimpleTest Example and see if it can successfully return its main page and if there is a link to the simpletest_example in the Tools menu.

File

testing_example/src/Tests/SimpleTestExampleTest.php, line 60

Class

SimpleTestExampleTest
Ensure that the simpletest_example content type provided functions properly.

Namespace

Drupal\testing_example\Tests

Code

public function testSimpleTestExampleMenu() {
  $url = Url::fromRoute('testing_example.simpletest_description');

  //
  // Test for a link to the simpletest_example in the Tools menu.
  $this
    ->drupalGet('');
  $this
    ->assertResponse(200, 'The Home page is available.');
  $this
    ->assertLinkByHref($url
    ->getInternalPath());

  // Verify that anonymous can access the simpletest_examples page.
  $this
    ->drupalGet($url);
  $this
    ->assertResponse(200, 'The SimpleTest Example description page is available.');
}