function StoryEditTest::testStoryEdit in SimpleTest 6
File
- tests/
story_edit.test, line 16
Class
- StoryEditTest
- Test file for story_edit
Code
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');
}