You are here

protected function OverrideNodeOptionsTest::testNodeAuthor in Override Node Options 7

Test the 'Authoring information' fieldset.

File

src/Tests/Functional/OverrideNodeOptionsTest.php, line 189
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 testNodeAuthor() {
  $specific_user = $this
    ->drupalCreateUser(array(
    'create page content',
    'edit any page content',
    'override page authored on option',
    'override page authored by option',
  ));
  $general_user = $this
    ->drupalCreateUser(array(
    'create page content',
    'edit any page content',
    'override all authored on option',
    'override all authored by option',
  ));
  foreach (array(
    $specific_user,
    $general_user,
  ) as $account) {
    $this
      ->drupalLogin($account);
    $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));
}