From 7cf7f998781c24f0f27218a9ffdcde290e7ec6ec Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 20 Sep 2009 07:32:19 +0000 Subject: =?UTF-8?q?-=20Patch=20#11218=20by=20David=5FRothstein,=20sun,=20q?= =?UTF-8?q?uicksketch,=20duncf,=20awood456,=20dropcube,=20mgifford=20|=20p?= =?UTF-8?q?wolanin,=20dww,=20RobRoy,=20Crell,=20webchick,=20beginner,=20ra?= =?UTF-8?q?y007,=20bjaspan,=20chx,=20G=C3=A1bor=20Hojtsy,=20Steven,=20Drie?= =?UTF-8?q?s,=20lutegrass,=20sym,=20guardian,=20matt2000,=20geerlingguy,?= =?UTF-8?q?=20SeanBannister,=20matt=20westgate,=20com2,=20praseodym:=20all?= =?UTF-8?q?ow=20default=20text=20formats=20per=20role,=20and=20integrate?= =?UTF-8?q?=20text=20format=20permissions.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/php/php.install | 1 - modules/php/php.test | 30 +++++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'modules/php') 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('