class FrontPageLinkTest

Same name in other branches
  1. 3.x modules/testing_example/tests/src/Functional/FrontPageLinkTest.php \Drupal\Tests\testing_example\Functional\FrontPageLinkTest
  2. 4.0.x modules/testing_example/tests/src/Functional/FrontPageLinkTest.php \Drupal\Tests\testing_example\Functional\FrontPageLinkTest

Tests for the existence of links on the front page.

This test declares that the 'standard' profile should be used when installing Drupal. Because the standard profile also specifies which theme to install, Bartik, we don't need to specify a $defaultTheme like we do in other functional tests.

This test is meant to support a Drupalize.me tutorial.

@group testing_example

Hierarchy

  • class \Drupal\Tests\testing_example\Functional\FrontPageLinkTest extends \Drupal\Tests\BrowserTestBase

Expanded class hierarchy of FrontPageLinkTest

See also

\Drupal\Tests\testing_example\Functional\FrontPageLinkDependenciesTest

File

testing_example/tests/src/Functional/FrontPageLinkTest.php, line 21

Namespace

Drupal\Tests\testing_example\Functional
View source
class FrontPageLinkTest extends BrowserTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * {@inheritdoc}
     */
    protected $profile = 'standard';
    
    /**
     * Tests for the existence of a default menu item on the home page.
     *
     * We'll open the home page and look for the Tools menu link called 'Add
     * content.'
     */
    public function testAddContentMenuItem() {
        // Step 1: Log in a user who can add content.
        $this->drupalLogin($this->createUser([
            'create article content',
        ]));
        // Step 2: Visit the home path.
        $this->drupalGet($this->buildUrl(''));
        // Step 3: Look on the page for the 'Add content' link.
        $this->assertSession()
            ->linkExists('Add content');
    }

}

Members

Title Sort descending Modifiers Object type Summary
FrontPageLinkTest::$defaultTheme protected property
FrontPageLinkTest::$profile protected property
FrontPageLinkTest::testAddContentMenuItem public function Tests for the existence of a default menu item on the home page.