diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-09-20 07:32:19 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-09-20 07:32:19 +0000 |
commit | 7cf7f998781c24f0f27218a9ffdcde290e7ec6ec (patch) | |
tree | 4e5b5b95f2dc6d8ddf7a7a3d7a173bfb3428717f /modules/php | |
parent | 3a2eff7145176693eb5ae3cd04b77ccebfa717b7 (diff) | |
download | brdo-7cf7f998781c24f0f27218a9ffdcde290e7ec6ec.tar.gz brdo-7cf7f998781c24f0f27218a9ffdcde290e7ec6ec.tar.bz2 |
- Patch #11218 by David_Rothstein, sun, quicksketch, duncf, awood456, dropcube, mgifford | pwolanin, dww, RobRoy, Crell, webchick, beginner, ray007, bjaspan, chx, Gábor Hojtsy, Steven, Dries, lutegrass, sym, guardian, matt2000, geerlingguy, SeanBannister, matt westgate, com2, praseodym: allow default text formats per role, and integrate text format permissions.
Diffstat (limited to 'modules/php')
-rw-r--r-- | modules/php/php.install | 1 | ||||
-rw-r--r-- | modules/php/php.test | 30 |
2 files changed, 17 insertions, 14 deletions
diff --git a/modules/php/php.install b/modules/php/php.install index aec038d3b..c010fc738 100644 --- a/modules/php/php.install +++ b/modules/php/php.install @@ -19,7 +19,6 @@ function php_install() { $format = db_insert('filter_format') ->fields(array( 'name' => 'PHP code', - 'roles' => '', 'cache' => 0, )) ->execute(); diff --git a/modules/php/php.test b/modules/php/php.test index fa8a69d38..5b995ed6f 100644 --- a/modules/php/php.test +++ b/modules/php/php.test @@ -5,6 +5,8 @@ * Base PHP test case class. */ class PHPTestCase extends DrupalWebTestCase { + protected $php_code_format; + function setUp() { parent::setUp('php'); @@ -12,9 +14,14 @@ class PHPTestCase extends DrupalWebTestCase { $admin_user = $this->drupalCreateUser(array('administer filters')); $this->drupalLogin($admin_user); - // Confirm that the PHP filter is #3. - $this->drupalGet('admin/config/content/formats/3'); - $this->assertText('PHP code', t('On PHP code filter page.')); + // Confirm that the PHP code text format was inserted as the newest format + // on the site. + $newest_format_id = db_query("SELECT MAX(format) FROM {filter_format}")->fetchField(); + $newest_format = filter_format_load($newest_format_id); + $this->assertEqual($newest_format->name, 'PHP code', t('PHP code text format was created.')); + + // Store the format ID of the PHP code text format for later use. + $this->php_code_format = $newest_format_id; } /** @@ -43,15 +50,12 @@ class PHPFilterTestCase extends PHPTestCase { * Make sure that the PHP filter evaluates PHP code when used. */ function testPHPFilter() { - // Setup PHP filter. - $edit = array(); - $edit['roles[2]'] = TRUE; // Set authenticated users to have permission to use filter. - $this->drupalPost(NULL, $edit, 'Save configuration'); - $this->assertText(t('The text format settings have been updated.'), t('PHP format available to authenticated users.')); - - // Create node with PHP filter enabled. - $web_user = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content')); + // Log in as a user with permission to use the PHP code text format. + $php_code_permission = filter_permission_name(filter_format_load($this->php_code_format)); + $web_user = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content', $php_code_permission)); $this->drupalLogin($web_user); + + // Create a node with PHP code in it. $node = $this->createNodeWithCode(); // Make sure that the PHP code shows up as text. @@ -61,7 +65,7 @@ class PHPFilterTestCase extends PHPTestCase { // Change filter to PHP filter and see that PHP code is evaluated. $edit = array(); $langcode = FIELD_LANGUAGE_NONE; - $edit["body[$langcode][0][value_format]"] = 3; + $edit["body[$langcode][0][value_format]"] = $this->php_code_format; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->assertRaw(t('Page %title has been updated.', array('%title' => $node->title)), t('PHP code filter turned on.')); @@ -98,6 +102,6 @@ class PHPAccessTestCase extends PHPTestCase { // Make sure that user doesn't have access to filter. $this->drupalGet('node/' . $node->nid . '/edit'); - $this->assertNoFieldByName('body_format', '3', t('Format not available.')); + $this->assertNoRaw('<option value="' . $this->php_code_format . '">', t('PHP code format not available.')); } } |