Commit ac581679 authored by webchick's avatar webchick
Browse files

#681940 by chx: Fixed Multistep node forms cant change the basic options. (with tests)

parent 90b08f2b
......@@ -86,7 +86,10 @@ function node_object_prepare($node) {
// If this is a new node, fill in the default values.
if (!isset($node->nid)) {
foreach (array('status', 'promote', 'sticky') as $key) {
$node->$key = (int) in_array($key, $node_options);
// Multistep node forms might have filled in something already.
if (!isset($node->$key)) {
$node->$key = (int) in_array($key, $node_options);
}
}
global $user;
$node->uid = $user->uid;
......
......@@ -1276,3 +1276,39 @@ class NodeBlockFunctionalTest extends DrupalWebTestCase {
$this->assertText($node4->title, t('Node found in block.'));
}
}
/**
* Test multistep node forms basic options.
*/
class MultiStepNodeFormBasicOptionsTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Multistep node form basic options',
'description' => 'Test the persistence of basic options through multiple steps.',
'group' => 'Node',
);
}
function setUp() {
parent::setUp('poll');
$web_user = $this->drupalCreateUser(array('administer nodes', 'create poll content'));
$this->drupalLogin($web_user);
}
/**
* Change the default values of basic options to ensure they persist.
*/
function testMultiStepNodeFormBasicOptions() {
$edit = array(
'title' => 'a',
'status' => FALSE,
'promote' => FALSE,
'sticky' => 1,
'choice[new:0][chtext]' => 'a',
'choice[new:1][chtext]' => 'a',
);
$this->drupalPost('node/add/poll', $edit, t('More choices'));
$this->assertNoFieldChecked('edit-status', 'status stayed unchecked');
$this->assertNoFieldChecked('edit-promote', 'promote stayed unchecked');
$this->assertFieldChecked('edit-sticky', 'sticky stayed checked');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment