function PHPTestCase::setUp
Overrides DrupalWebTestCase::setUp
File
-
modules/
php/ php.test, line 14
Class
- PHPTestCase
- Defines a base PHP test case class.
Code
function setUp() {
parent::setUp('php');
// Create and login admin user.
$admin_user = $this->drupalCreateUser(array(
'administer filters',
));
$this->drupalLogin($admin_user);
// Verify that the PHP code text format was inserted.
$php_format_id = 'php_code';
$this->php_code_format = filter_format_load($php_format_id);
$this->assertEqual($this->php_code_format->name, 'PHP code', 'PHP code text format was created.');
// Verify that the format has the PHP code filter enabled.
$filters = filter_list_format($php_format_id);
$this->assertTrue($filters['php_code']->status, 'PHP code filter is enabled.');
// Verify that the format exists on the administration page.
$this->drupalGet('admin/config/content/formats');
$this->assertText('PHP code', 'PHP code text format was created.');
// Verify that anonymous and authenticated user roles do not have access.
$this->drupalGet('admin/config/content/formats/' . $php_format_id);
$this->assertFieldByName('roles[' . DRUPAL_ANONYMOUS_RID . ']', FALSE, 'Anonymous users do not have access to PHP code format.');
$this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', FALSE, 'Authenticated users do not have access to PHP code format.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.