Skip to content
Snippets Groups Projects
Commit c974cff8 authored by Rob Loach's avatar Rob Loach
Browse files

Updates from latest in Drupal 8.x

parent 2e683e2f
Branches master
No related tags found
No related merge requests found
......@@ -30,10 +30,10 @@ class PhpAccessTest extends PhpTestBase {
// Make sure that the PHP code shows up as text.
$this->drupalGet('node/' . $node->nid);
$this->assertText('print', t('PHP code was not evaluated.'));
$this->assertText('print', 'PHP code was not evaluated.');
// Make sure that user doesn't have access to filter.
$this->drupalGet('node/' . $node->nid . '/edit');
$this->assertNoRaw('<option value="' . $this->php_code_format->format . '">', t('PHP code format not available.'));
$this->assertNoRaw('<option value="' . $this->php_code_format->format . '">', 'PHP code format not available.');
}
}
......@@ -40,10 +40,10 @@ class PhpFilterTest extends PhpTestBase {
$langcode = LANGUAGE_NOT_SPECIFIED;
$edit["body[$langcode][0][format]"] = $this->php_code_format->format;
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$this->assertRaw(t('Basic page %title has been updated.', array('%title' => $node->title)), t('PHP code filter turned on.'));
$this->assertRaw(t('Basic page %title has been updated.', array('%title' => $node->label())), 'PHP code filter turned on.');
// Make sure that the PHP code shows up as text.
$this->assertNoText('print "SimpleTest PHP was executed!"', t("PHP code isn't displayed."));
$this->assertText('SimpleTest PHP was executed!', t('PHP code has been evaluated.'));
$this->assertNoText('print "SimpleTest PHP was executed!"', "PHP code isn't displayed.");
$this->assertText('SimpleTest PHP was executed!', 'PHP code has been evaluated.');
}
}
......@@ -12,11 +12,19 @@ use Drupal\simpletest\WebTestBase;
/**
* Defines a base PHP test case class.
*/
class PhpTestBase extends WebTestBase {
abstract class PhpTestBase extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('php');
protected $php_code_format;
function setUp() {
parent::setUp('php');
parent::setUp();
// Create Basic page node type.
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
......@@ -28,20 +36,20 @@ class PhpTestBase extends WebTestBase {
// 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.'));
$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, t('PHP code filter is enabled.'));
$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', t('PHP code text format was created.'));
$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, t('Anonymous users do not have access to PHP code format.'));
$this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', FALSE, t('Authenticated users do not have access to PHP code format.'));
$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.');
}
/**
......
......@@ -138,6 +138,7 @@ else {
function php_filter_info() {
$filters['php_code'] = array(
'title' => t('PHP evaluator'),
'type' => FILTER_TYPE_MARKUP_LANGUAGE,
'description' => t('Executes a piece of PHP code. The usage of this filter should be restricted to administrators only!'),
'process callback' => 'php_eval',
'tips callback' => '_php_filter_tips',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment