You are here

public function SimpleTestExampleMockModuleTest::testSimpleTestExampleMockModule in Examples for Developers 8

Test modifications made by our mock module.

We create a simpletest_example node and then see if our submodule operated on it.

File

testing_example/src/Tests/SimpleTestExampleMockModuleTest.php, line 53

Class

SimpleTestExampleMockModuleTest
Demonstrate SimpleTest with a mock module.

Namespace

Drupal\testing_example\Tests

Code

public function testSimpleTestExampleMockModule() {

  // Create a user.
  $test_user = $this
    ->drupalCreateUser([
    'access content',
  ]);

  // Log them in.
  $this
    ->drupalLogin($test_user);

  // Set up some content.
  $settings = [
    'type' => 'testing_example',
    'title' => $this
      ->randomMachineName(32),
  ];

  // Create the content node.
  $node = $this
    ->drupalCreateNode($settings);

  // View the node.
  $this
    ->drupalGet('node/' . $node
    ->id());

  // Check that our module did it's thing.
  $this
    ->assertText('The test module did its thing.', 'Found evidence of test module.');
}