public function AccessFilterTestCase::testOperations in Access Filter 7
Test standard operations.
File
- ./
access_filter.test, line 39 - Tests for access_filter.module
Class
- AccessFilterTestCase
- @file Tests for access_filter.module
Code
public function testOperations() {
// Test user permissions.
$this
->drupalLogin($this->normalUser);
$this
->drupalGet('admin/config/people/access_filter');
$this
->assertResponse(403);
$this
->drupalLogin($this->privilegedUser);
$this
->drupalGet('admin/config/people/access_filter');
$this
->assertResponse(200);
// Create a filter.
$edit = array();
$edit['name'] = $this
->randomName(16);
$edit['status'] = 1;
$edit['paths'] = 'D:node/1';
$edit['rules'] = 'A:*';
$this
->drupalPost('admin/config/people/access_filter/add', $edit, t('Save'));
$this
->assertText($edit['name']);
// Load the created filter.
$filter = $this
->loadFilterByName($edit['name']);
$this
->assertTrue($filter, 'Access filter has created surely.');
// Edit the filter.
$edit['rules'] = 'D:*';
$this
->drupalPost('admin/config/people/access_filter/' . $filter->fid . '/edit', $edit, t('Save'));
$this
->assertText($edit['name']);
// Delete the filter.
$this
->drupalPost('admin/config/people/access_filter/' . $filter->fid . '/delete', array(), t('Delete'));
$this
->assertText($edit['name']);
$this
->assertFalse($this
->loadFilterByName($edit['name']), 'Access filter has been deleted surely.');
}