View source
<?php
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() {
$this
->drupalVariableSet('node_options_story', array(
'status',
'promote',
));
$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),
);
$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),
);
$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');
}
}