You are here

protected function ExampleFunctionalTest::setUp in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/testing_example/tests/src/Functional/ExampleFunctionalTest.php \Drupal\Tests\testing_example\Functional\ExampleFunctionalTest::setUp()

The setUp() method is run before every other test method, so commonalities should go here.

Overrides ExamplesBrowserTestBase::setUp

File

testing_example/tests/src/Functional/ExampleFunctionalTest.php, line 52

Class

ExampleFunctionalTest
Class ExampleFunctionalTest.

Namespace

Drupal\Tests\testing_example\Functional

Code

protected function setUp() {
  parent::setUp();

  // Create users.
  $this->adminUser = $this
    ->drupalCreateUser([
    'access administration pages',
    'view the administration theme',
    'administer permissions',
    'administer nodes',
    'administer content types',
  ]);
  $this->authUser = $this
    ->drupalCreateUser([], 'authuser');

  // We have to create a content type because testing uses the 'testing'
  // profile, which has no content types by default.
  // Although we could have visited admin pages and pushed buttons to create
  // the content type, there happens to be function we can use in this case.
  $this
    ->createContentType([
    'type' => 'test_content_type',
  ]);
}