You are here

story_edit.test in SimpleTest 6

File

tests/story_edit.test
View source
<?php

/*
 * Written by Corni for the Google Highly Open Participation Contest.
 * Credits go to the coder of the page_creation.test
 */

/**
* Test file for story_edit
*/
class StoryEditTest extends DrupalTestCase {
  function get_info() {
    return array(
      'name' => 'Story edit test',
      'desc' => t('We want a working edit for storys, uh?'),
      'group' => 'Node Tests',
    );
  }
  function testStoryEdit() {

    /* Prepare settings */
    $this
      ->drupalVariableSet('node_options_story', array(
      'status',
      'promote',
    ));

    /* Prepare a user to do the stuff */
    $web_user = $this
      ->drupalCreateUserRolePerm(array(
      'edit own story content',
      'create story content',
    ));
    $this
      ->drupalLoginUser($web_user);
    $edit = array(
      'title' => '!SimpleTest! test title' . $this
        ->randomName(20),
      'body' => '!SimpleTest! test body' . $this
        ->randomName(200),
    );

    //Create the page to edit
    $this
      ->drupalPost('node/add/story', $edit, 'Save');
    $node = node_load(array(
      'title' => $edit['title'],
    ));
    $this
      ->assertNotNull($node, 'Node found in database');
    $this
      ->clickLink('Edit');
    $editurl = url("node/{$node->nid}/edit", array(
      'absolute' => true,
    ));
    $acturl = $this->_browser
      ->getURL();
    $this
      ->assertEqual($editurl, $acturl);
    $this
      ->assertWantedText(t('Edit'), 'Edit text is here');
    $this
      ->assertWantedText(t($edit['title']), 'Hello, the random title');
    $this
      ->assertWantedText(t($edit['body']), 'test is over, the body\'s still there');
    $edit = array(
      'title' => '!SimpleTest! test title' . $this
        ->randomName(20),
      'body' => '!SimpleTest! test body' . $this
        ->randomName(200),
    );

    //edit the content of the page
    $this
      ->drupalPost("node/{$node->nid}/edit", $edit, 'Save');
    $this
      ->assertWantedText(t($edit['title']), 'Hello, the random title');
    $this
      ->assertWantedText(t($edit['body']), 'test is over, the body\'s still there');
  }

}

Classes

Namesort descending Description
StoryEditTest Test file for story_edit