1 simpletest_example.test public SimpleTestExampleTestCase::testSimpleTestExampleEdit()

Create a simpletest_example node and then see if our user can edit it.

File

modules/examples/simpletest_example/tests/simpletest_example.test, line 63
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 testSimpleTestExampleEdit() {
  $settings = array(
    'type' => 'simpletest_example',
    'title' => $this->randomName(32),
    'body' => array(LANGUAGE_NONE => array(array($this->randomName(64)))),
  );
  $node = $this->backdropCreateNode($settings);

  // For debugging, we might output the node structure with $this->verbose()
  // It would only be output if the testing settings had 'verbose' set.
  $this->verbose('Node created: ' . var_export($node, TRUE));

  // We'll run this test normally, but not on the testbot, as it would
  // indicate that the examples module was failing tests.
  if (!$this->runningOnTestbot()) {
    // The debug() statement will output information into the test results.
    // It can also be used in Backdrop anywhere in code and will come out
    // as a backdrop_set_message().
    debug('We are not running on the PIFR testing server, so will go ahead and catch the failure.');
    $this->backdropGet("node/{$node->nid}/edit");
    // Make sure we don't get a 401 unauthorized response:
    $this->assertResponse(200, 'User is allowed to edit the content.');

    // Looking for title text in the page to determine whether we were
    // successful opening edit form.
    $this->assertText(t("@title", array('@title' => $settings['title'])), "Found title in edit form");
  }
}