simple_access.test in Simple Access 8.3
Same filename and directory in other branches
Tests to check that simple access is working correctly.
File
simple_access.testView source
<?php
/**
* @file
* Tests to check that simple access is working correctly.
*/
/**
* Test Owner permissions.
*/
class SimpleAccessOwnerTestCase extends DrupalWebTestCase {
/**
* {@inheritdoc}
*/
public function getInfo() {
return [
'name' => t('Check owner permissions'),
'description' => t('Test different owner permissions and make sure access is correct'),
'group' => t('Simple Access'),
];
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp('simple_access');
$this->node_type = $this
->drupalCreateContentType();
node_access_rebuild();
}
/**
* Test if owner can edit content.
*/
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');
}
}
Classes
Name | Description |
---|---|
SimpleAccessOwnerTestCase | Test Owner permissions. |