PHPTestCase::setUp

7 php.test PHPTestCase::setUp()
8 php.test PHPTestCase::setUp()

Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides DrupalWebTestCase::setUp

File

modules/php/php.test, line 14
Tests for php.module.

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', t('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, t('PHP code filter is enabled.'));

  // Verify that the format exists on the administration page.
  $this->drupalGet('admin/config/content/formats');
  $this->assertText('PHP code', t('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[1]', FALSE, t('Anonymous users do not have access to PHP code format.'));
  $this->assertFieldByName('roles[2]', FALSE, t('Authenticated users do not have access to PHP code format.'));
}
Login or register to post comments