1 simpletest_example.test public SimpleTestExampleTestCase::setUp()

Set up the test environment.

This method is called once per test method, before the test is executed. It gives you a chance to control the setup of the test environment.

If you need a different test environment, then you should create another test class which overloads BackdropWebTestCase::setUp() differently.

Overrides BackdropWebTestCase::setUp

See also

BackdropWebTestCase::setUp()

File

modules/examples/simpletest_example/tests/simpletest_example.test, line 37
An example of simpletest tests.

Class

SimpleTestExampleTestCase
The SimpleTestExampleTestCase is a functional test case, meaning that it actually exercises a particular sequence of actions through the web UI. The majority of core test cases are done this way, but the SimpleTest suite also provides unit tests as…

Code

public function setUp() {
  // We call parent::setUp() with the list of modules we want to enable.
  // This can be an array or just a list of arguments.
  parent::setUp('simpletest_example');
  // Create and log in our user. The user has the arbitrary privilege
  // 'extra special edit any simpletest_example' which is provided by
  // our module to grant access.
  $this->privilegedUser = $this->backdropCreateUser(array('create simpletest_example content', 'extra special edit any simpletest_example'));
  $this->backdropLogin($this->privilegedUser);
}