You are here

public function SimpleTestExampleTestCase::testSimpleTestExampleEdit in Examples for Developers 6

Same name and namespace in other branches
  1. 7 simpletest_example/simpletest_example.test \SimpleTestExampleTestCase::testSimpleTestExampleEdit()

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

File

simpletest_example/simpletest_example.test, line 58
An example of SimpleTest tests to accompany the tutorial at http://drupal.org/node/395012.

Class

SimpleTestExampleTestCase
Tests the SimpleTest Example module's content type.

Code

public function testSimpleTestExampleEdit() {
  $settings = array(
    'type' => 'simpletest_example',
    'title' => $this
      ->randomName(32),
    'body' => $this
      ->randomName(64),
  );
  $node = $this
    ->drupalCreateNode($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));
  if (!$this
    ->runningOnTestbot()) {

    // Make sure we don't get a 401 unauthorized response when editing.
    $this
      ->drupalGet("node/{$node->nid}/edit");
    $this
      ->assertResponse(200, t('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");
  }
}