public function PermissionsTest::testPermissions in Forward 8
Same name and namespace in other branches
- 8.3 src/Tests/PermissionsTest.php \Drupal\forward\Tests\PermissionsTest::testPermissions()
- 8.2 src/Tests/PermissionsTest.php \Drupal\forward\Tests\PermissionsTest::testPermissions()
Test access to Forward links.
File
- src/
Tests/ PermissionsTest.php, line 15
Class
- PermissionsTest
- Test the permissions.
Namespace
Drupal\forward\TestsCode
public function testPermissions() {
// Users with access content permission cannot change settings.
$this
->drupalLogin($this->webUser);
$this
->drupalGet('admin/config/user-interface/forward');
$this
->assertResponse(403, 'Users with access content permission cannot change settings.');
// Users with access forward permission cannot change settings.
$this
->drupalLogin($this->forwardUser);
$this
->drupalGet('admin/config/user-interface/forward');
$this
->assertResponse(403, 'Users with access forward permission cannot change settings.');
// Users with administer forward permission can change settings.
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/config/user-interface/forward');
$this
->assertResponse(200, 'Users with administer forward permission can change settings.');
// Users without override email address permission cannot change their email address on the Forward form.
$article = $this
->drupalCreateNode(array(
'type' => 'article',
));
$this
->drupalLogin($this->forwardUser);
$this
->drupalGet('/forward/node/' . $article
->id());
$this
->assertNoText(t('Your email address'), 'Users without override email address permission cannot change their email address on the Forward form.');
// Users with override email address permission can change their email address on the Forward form.
$overrideUser = $this
->drupalCreateUser([
'access content',
'access forward',
'override email address',
'override flood control',
]);
$article = $this
->drupalCreateNode(array(
'type' => 'article',
));
$this
->drupalLogin($overrideUser);
$this
->drupalGet('/forward/node/' . $article
->id());
$this
->assertText(t('Your email address'), 'Users with override email address permission can change their email address on the Forward form.');
// Set flood control limit to 1
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/config/user-interface/forward');
$edit = array(
'forward_flood_control_limit' => 1,
);
$this
->drupalPostForm(NULL, $edit, t('Save configuration'));
// Users without override flood control permission cannot do more than 1 forward in an hour.
$this
->drupalLogin($this->forwardUser);
$this
->drupalGet('/forward/node/' . $article
->id());
$edit = array(
'name' => 'Test Forwarder',
'recipient' => 'test@test.com',
'message' => 'This is a test personal message.',
);
$this
->drupalPostForm(NULL, $edit, t('Send Message'));
$this
->drupalGet('/forward/node/' . $article
->id());
$edit = array(
'name' => 'Test Forwarder',
'recipient' => 'test@test.com',
'message' => 'This is a test personal message.',
);
$this
->drupalPostForm(NULL, $edit, t('Send Message'));
$this
->assertNoText(t('Thank you for spreading the word about Drupal.'), 'Users without override flood control permission cannot do more than 1 forward in an hour.');
// Users with override flood control permission can do more than 1 forward in an hour.
$this
->drupalLogin($overrideUser);
$this
->drupalGet('/forward/node/' . $article
->id());
$edit = array(
'name' => 'Test Forwarder',
'recipient' => 'test@test.com',
'message' => 'This is a test personal message.',
);
$this
->drupalPostForm(NULL, $edit, t('Send Message'));
$this
->drupalGet('/forward/node/' . $article
->id());
$edit = array(
'name' => 'Test Forwarder',
'recipient' => 'test@test.com',
'message' => 'This is a test personal message.',
);
$this
->drupalPostForm(NULL, $edit, t('Send Message'));
$this
->assertText(t('Thank you for spreading the word about Drupal.'), 'Users with override flood control permission can do more than 1 forward in an hour.');
}