You are here

protected function OverrideNodeOptionsTest::testNodeOptions in Override Node Options 7

Test the 'Authoring information' fieldset.

File

src/Tests/Functional/OverrideNodeOptionsTest.php, line 114
Unit tests for the override_node_options module.

Class

OverrideNodeOptionsTest
Defines a base class for testing the Override Node Options module.

Namespace

Drupal\override_node_options\Tests\Functional

Code

protected function testNodeOptions() {
  $common = array(
    'create page content',
    'edit any page content',
  );
  $template = array(
    'override %s published option',
    'override %s promote to front page option',
    'override %s sticky option',
    'override %s comment setting option',
  );
  $combinations = self::combinations(array(
    'page',
    'all',
  ), 4);
  $cases = array();
  foreach ($combinations as $combination) {
    $permissions = $common;
    foreach ($combination as $index => $value) {
      $permissions[] = sprintf($template[$index], $value);
    }
    $cases[] = $permissions;
  }
  foreach ($cases as $permissions) {
    $account = $this
      ->drupalCreateUser($permissions);
    $this
      ->drupalLogin($account);
    $fields = array(
      'status' => !$this->node->status,
      'promote' => !$this->node->promote,
      'sticky' => !$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));
}