You are here

public function SimpleAccessOwnerTestCase::testSimpleAccessOwnerCanEdit in Simple Access 8.3

Same name and namespace in other branches
  1. 6.2 simple_access.test \SimpleAccessOwnerTestCase::testSimpleAccessOwnerCanEdit()
  2. 7.2 simple_access.test \SimpleAccessOwnerTestCase::testSimpleAccessOwnerCanEdit()

Test if owner can edit content.

File

./simple_access.test, line 39
Tests to check that simple access is working correctly.

Class

SimpleAccessOwnerTestCase
Test Owner permissions.

Code

public function testSimpleAccessOwnerCanEdit() {
  $account = $this
    ->drupalCreateUser();
  $n1 = $this
    ->drupalCreateNode([
    'type' => $this->node_type,
    'uid' => $account->uid,
    'status' => 1,
    'simple_access_owner' => [
      'sa_view' => 1,
    ],
  ]);
  $n2 = $this
    ->drupalCreateNode([
    'type' => $this->node_type,
    'uid' => $account->uid,
    'status' => 1,
    'simple_access_owner' => [
      'sa_view' => 1,
      'sa_update' => 1,
    ],
  ]);
  $n1 = node_load($n1->nid);
  $n1->status = 1;
  $this
    ->assertFalse(node_access('update', $n1, $account), t("Owner doesn't have edit access to content"), 'Access');
  $n2 = node_load($n2->nid);
  $n2->status = 1;
  $this
    ->assertTrue(node_access('update', $n2, $account), t('Owner has edit access to content'), 'Access');
}