diff --git a/override_node_options.module b/override_node_options.module index c557338..03a59c6 100644 --- a/override_node_options.module +++ b/override_node_options.module @@ -266,7 +266,7 @@ function override_node_options_form_alter(&$form, &$form_state, $form_id) { // Add access to the 'Comment settings' fieldset. if (module_exists('comment') && isset($form['comment_settings'])) { - $form['comment_settings']['#access'] |= user_access('override ' . $node->type . ' comment setting option'); + $form['comment_settings']['#access'] |= user_access('override ' . $node->type . ' comment setting option') || user_access('override all comment setting option'); } // @todo Remove when http://drupal.org/node/683630 is fixed. diff --git a/override_node_options.test b/override_node_options.test index 9ca1d79..9f74f1a 100644 --- a/override_node_options.test +++ b/override_node_options.test @@ -10,8 +10,14 @@ */ class OverrideNodeOptionsTestCase extends DrupalWebTestCase { + /** + * @var stdClass + */ protected $normalUser; - protected $adminUser; + + /** + * @var stdClass + */ protected $node; /** @@ -30,6 +36,7 @@ class OverrideNodeOptionsTestCase extends DrupalWebTestCase { */ public function setUp() { parent::setUp('override_node_options'); + $this->normalUser = $this->drupalCreateUser(array('create page content', 'edit any page content')); $this->node = $this->drupalCreateNode(); } @@ -83,7 +90,7 @@ class OverrideNodeOptionsTestCase extends DrupalWebTestCase { * Test the 'Authoring information' fieldset. */ protected function testNodeOptions() { - $this->adminUser = $this->drupalCreateUser(array( + $specificUser = $this->drupalCreateUser(array( 'create page content', 'edit any page content', 'override page published option', @@ -91,16 +98,28 @@ class OverrideNodeOptionsTestCase extends DrupalWebTestCase { 'override page sticky option', 'override page comment setting option', )); - $this->drupalLogin($this->adminUser); - $fields = array( - 'status' => (bool) !$this->node->status, - 'promote' => (bool) !$this->node->promote, - 'sticky' => (bool) !$this->node->sticky, - 'comment' => COMMENT_NODE_OPEN, - ); - $this->drupalPost('node/' . $this->node->nid . '/edit', $fields, t('Save')); - $this->assertNodeFieldsUpdated($this->node, $fields); + $generalUser = $this->drupalCreateUser(array( + 'create page content', + 'edit any page content', + 'override all published option', + 'override all promote to front page option', + 'override all sticky option', + 'override all comment setting option', + )); + + foreach (array($specificUser, $generalUser) as $account) { + $this->drupalLogin($account); + + $fields = array( + 'status' => (bool) !$this->node->status, + 'promote' => (bool) !$this->node->promote, + 'sticky' => (bool) !$this->node->sticky, + 'comment' => COMMENT_NODE_OPEN, + ); + $this->drupalPost('node/' . $this->node->nid . '/edit', $fields, t('Save')); + $this->assertNodeFieldsUpdated($this->node, $fields); + } $this->drupalLogin($this->normalUser); $this->assertNodeFieldsNoAccess($this->node, array_keys($fields)); @@ -110,18 +129,30 @@ class OverrideNodeOptionsTestCase extends DrupalWebTestCase { * Test the 'Revision information' fieldset. */ protected function testNodeRevisions() { - $this->adminUser = $this->drupalCreateUser(array( + $specificUser = $this->drupalCreateUser(array( 'create page content', 'edit any page content', 'override page revision option', )); - $this->drupalLogin($this->adminUser); - $fields = array( - 'revision' => TRUE, - ); - $this->drupalPost('node/' . $this->node->nid . '/edit', $fields, t('Save')); - $this->assertNodeFieldsUpdated($this->node, array('vid' => $this->node->vid + 1)); + $generalUser = $this->drupalCreateUser(array( + 'create page content', + 'edit any page content', + 'override all revision option', + )); + + foreach (array($specificUser, $generalUser) as $account) { + $this->drupalLogin($account); + + // Ensure that we have the latest node data. + $node = node_load($this->node->nid, NULL, TRUE); + + $fields = array( + 'revision' => TRUE, + ); + $this->drupalPost('node/' . $node->nid . '/edit', $fields, t('Save')); + $this->assertNodeFieldsUpdated($node, array('vid' => $node->vid + 1)); + } $this->drupalLogin($this->normalUser); $this->assertNodeFieldsNoAccess($this->node, array_keys($fields)); @@ -131,27 +162,37 @@ class OverrideNodeOptionsTestCase extends DrupalWebTestCase { * Test the 'Authoring information' fieldset. */ protected function testNodeAuthor() { - $this->adminUser = $this->drupalCreateUser(array( + $specificUser = $this->drupalCreateUser(array( 'create page content', 'edit any page content', 'override page authored on option', 'override page authored by option', )); - $this->drupalLogin($this->adminUser); - $this->drupalPost('node/' . $this->node->nid . '/edit', array('name' => 'invalid-user'), t('Save')); - $this->assertText('The username invalid-user does not exist.'); + $generalUser = $this->drupalCreateUser(array( + 'create page content', + 'edit any page content', + 'override all authored on option', + 'override all authored by option', + )); - $this->drupalPost('node/' . $this->node->nid . '/edit', array('date' => 'invalid-date'), t('Save')); - $this->assertText('You have to specify a valid date.'); + foreach (array($specificUser, $generalUser) as $account) { + $this->drupalLogin($account); - $time = time() + 500; - $fields = array( - 'name' => '', - 'date' => format_date($time, 'custom', 'Y-m-d H:i:s O'), - ); - $this->drupalPost('node/' . $this->node->nid . '/edit', $fields, t('Save')); - $this->assertNodeFieldsUpdated($this->node, array('uid' => 0, 'created' => $time)); + $this->drupalPost('node/' . $this->node->nid . '/edit', array('name' => 'invalid-user'), t('Save')); + $this->assertText('The username invalid-user does not exist.'); + + $this->drupalPost('node/' . $this->node->nid . '/edit', array('date' => 'invalid-date'), t('Save')); + $this->assertText('You have to specify a valid date.'); + + $time = time() + 500; + $fields = array( + 'name' => '', + 'date' => format_date($time, 'custom', 'Y-m-d H:i:s O'), + ); + $this->drupalPost('node/' . $this->node->nid . '/edit', $fields, t('Save')); + $this->assertNodeFieldsUpdated($this->node, array('uid' => 0, 'created' => $time)); + } $this->drupalLogin($this->normalUser); $this->assertNodeFieldsNoAccess($this->node, array_keys($fields));