summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-12-05 14:08:56 +0000
committerAlex Pott2014-12-05 14:08:56 +0000
commitb644bffdc59f0d98c431528b060955f54886e0a6 (patch)
treeee2a92209173ce327ee8007c40d73707da616694
parentca3cc9b8be2a76c3cd82ab12bd6b47d91510678d (diff)
Issue #2385225 by tibbsa: Clean-up editor module test members - ensure property definition and use of camelCase naming convention
-rw-r--r--core/modules/editor/src/Tests/EditorAdminTest.php15
-rw-r--r--core/modules/editor/src/Tests/EditorLoadingTest.php44
-rw-r--r--core/modules/editor/src/Tests/EditorSecurityTest.php46
-rw-r--r--core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php10
-rw-r--r--core/modules/editor/src/Tests/QuickEditIntegrationTest.php30
5 files changed, 85 insertions, 60 deletions
diff --git a/core/modules/editor/src/Tests/EditorAdminTest.php b/core/modules/editor/src/Tests/EditorAdminTest.php
index 26fb9d1..e133a26 100644
--- a/core/modules/editor/src/Tests/EditorAdminTest.php
+++ b/core/modules/editor/src/Tests/EditorAdminTest.php
@@ -23,6 +23,13 @@ class EditorAdminTest extends WebTestBase {
*/
public static $modules = array('filter', 'editor');
+ /**
+ * A user with the 'administer filters' permission.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $adminUser;
+
protected function setUp() {
parent::setUp();
@@ -36,14 +43,14 @@ class EditorAdminTest extends WebTestBase {
$filtered_html_format->save();
// Create admin user.
- $this->admin_user = $this->drupalCreateUser(array('administer filters'));
+ $this->adminUser = $this->drupalCreateUser(array('administer filters'));
}
/**
* Tests an existing format without any editors available.
*/
public function testNoEditorAvailable() {
- $this->drupalLogin($this->admin_user);
+ $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
// Ensure the form field order is correct.
@@ -68,7 +75,7 @@ class EditorAdminTest extends WebTestBase {
*/
public function testAddEditorToExistingFormat() {
$this->enableUnicornEditor();
- $this->drupalLogin($this->admin_user);
+ $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
$edit = $this->selectUnicornEditor();
// Configure Unicorn Editor's setting to another value.
@@ -82,7 +89,7 @@ class EditorAdminTest extends WebTestBase {
*/
public function testAddEditorToNewFormat() {
$this->enableUnicornEditor();
- $this->drupalLogin($this->admin_user);
+ $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/content/formats/add');
// Configure the text format name.
$edit = array(
diff --git a/core/modules/editor/src/Tests/EditorLoadingTest.php b/core/modules/editor/src/Tests/EditorLoadingTest.php
index 910f6fa..f0b8877 100644
--- a/core/modules/editor/src/Tests/EditorLoadingTest.php
+++ b/core/modules/editor/src/Tests/EditorLoadingTest.php
@@ -23,6 +23,27 @@ class EditorLoadingTest extends WebTestBase {
*/
public static $modules = array('filter', 'editor', 'editor_test', 'node');
+ /**
+ * An untrusted user, with access to the 'plain_text' format.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $untrustedUser;
+
+ /**
+ * A normal user with additional access to the 'filtered_html' format.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $normalUser;
+
+ /**
+ * A privileged user with additional access to the 'full_html' format.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $privilegedUser;
+
protected function setUp() {
parent::setUp();
@@ -48,13 +69,10 @@ class EditorLoadingTest extends WebTestBase {
'name' => 'Article',
));
- // Create 3 users, each with access to different text formats:
- // - "untrusted": plain_text
- // - "normal": plain_text, filtered_html
- // - "privileged": plain_text, filtered_html, full_html
- $this->untrusted_user = $this->drupalCreateUser(array('create article content', 'edit any article content'));
- $this->normal_user = $this->drupalCreateUser(array('create article content', 'edit any article content', 'use text format filtered_html'));
- $this->privileged_user = $this->drupalCreateUser(array('create article content', 'edit any article content', 'use text format filtered_html', 'use text format full_html'));
+ // Create 3 users, each with access to different text formats.
+ $this->untrustedUser = $this->drupalCreateUser(array('create article content', 'edit any article content'));
+ $this->normalUser = $this->drupalCreateUser(array('create article content', 'edit any article content', 'use text format filtered_html'));
+ $this->privilegedUser = $this->drupalCreateUser(array('create article content', 'edit any article content', 'use text format filtered_html', 'use text format full_html'));
}
/**
@@ -71,19 +89,19 @@ class EditorLoadingTest extends WebTestBase {
// The normal user:
// - has access to 2 text formats;
// - doesn't have access to the full_html text format, so: no text editor.
- $this->drupalLogin($this->normal_user);
+ $this->drupalLogin($this->normalUser);
$this->drupalGet('node/add/article');
list( , $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
$this->assertFalse($editor_settings_present, 'No Text Editor module settings.');
$this->assertFalse($editor_js_present, 'No Text Editor JavaScript.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertTrue(count($format_selector) === 0, 'No text format selector exists on the page because the user only has access to a single format.');
- $this->drupalLogout($this->normal_user);
+ $this->drupalLogout($this->normalUser);
- // The normal user:
+ // The privileged user:
// - has access to 2 text formats (and the fallback format);
// - does have access to the full_html text format, so: Unicorn text editor.
- $this->drupalLogin($this->privileged_user);
+ $this->drupalLogin($this->privilegedUser);
$this->drupalGet('node/add/article');
list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
$expected = array('formats' => array('full_html' => array(
@@ -100,7 +118,7 @@ class EditorLoadingTest extends WebTestBase {
$this->assertTrue(count($format_selector) === 1, 'A single text format selector exists on the page.');
$specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and contains(@class, "editor") and @data-editor-for="edit-body-0-value"]');
$this->assertTrue(count($specific_format_selector) === 1, 'A single text format selector exists on the page and has the "editor" class and a "data-editor-for" attribute with the correct value.');
- $this->drupalLogout($this->privileged_user);
+ $this->drupalLogout($this->privilegedUser);
// Also associate a text editor with the "Plain Text" text format.
$editor = entity_create('editor', array(
@@ -112,7 +130,7 @@ class EditorLoadingTest extends WebTestBase {
// The untrusted user:
// - has access to 1 text format (plain_text);
// - has access to the plain_text text format, so: Unicorn text editor.
- $this->drupalLogin($this->untrusted_user);
+ $this->drupalLogin($this->untrustedUser);
$this->drupalGet('node/add/article');
list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
$expected = array('formats' => array('plain_text' => array(
diff --git a/core/modules/editor/src/Tests/EditorSecurityTest.php b/core/modules/editor/src/Tests/EditorSecurityTest.php
index 6a19d3e..f63fce2 100644
--- a/core/modules/editor/src/Tests/EditorSecurityTest.php
+++ b/core/modules/editor/src/Tests/EditorSecurityTest.php
@@ -51,14 +51,14 @@ class EditorSecurityTest extends WebTestBase {
*
* @var \Drupal\user\UserInterface
*/
- protected $untrusted_user;
+ protected $untrustedUser;
/**
* User with access to Restricted HTML text format with text editor.
*
* @var \Drupal\user\UserInterface
*/
- protected $normal_user;
+ protected $normalUser;
/**
* User with access to Restricted HTML text format, dangerous tags allowed
@@ -66,14 +66,14 @@ class EditorSecurityTest extends WebTestBase {
*
* @var \Drupal\user\UserInterface
*/
- protected $trusted_user;
+ protected $trustedUser;
/**
* User with access to all text formats and text editors.
*
* @var \Drupal\user\UserInterface
*/
- protected $privileged_user;
+ protected $privilegedUser;
protected function setUp() {
parent::setUp();
@@ -176,22 +176,22 @@ class EditorSecurityTest extends WebTestBase {
// - "privileged": restricted_without_editor, restricted_with_editor,
// restricted_plus_dangerous_tag_with_editor,
// unrestricted_without_editor and unrestricted_with_editor
- $this->untrusted_user = $this->drupalCreateUser(array(
+ $this->untrustedUser = $this->drupalCreateUser(array(
'create article content',
'edit any article content',
'use text format restricted_without_editor',
));
- $this->normal_user = $this->drupalCreateUser(array(
+ $this->normalUser = $this->drupalCreateUser(array(
'create article content',
'edit any article content',
'use text format restricted_with_editor',
));
- $this->trusted_user = $this->drupalCreateUser(array(
+ $this->trustedUser = $this->drupalCreateUser(array(
'create article content',
'edit any article content',
'use text format restricted_plus_dangerous_tag_with_editor',
));
- $this->privileged_user = $this->drupalCreateUser(array(
+ $this->privilegedUser = $this->drupalCreateUser(array(
'create article content',
'edit any article content',
'use text format restricted_without_editor',
@@ -204,11 +204,11 @@ class EditorSecurityTest extends WebTestBase {
// Create an "article" node for each possible text format, with the same
// sample content, to do our tests on.
$samples = array(
- array('author' => $this->untrusted_user->id(), 'format' => 'restricted_without_editor'),
- array('author' => $this->normal_user->id(), 'format' => 'restricted_with_editor'),
- array('author' => $this->trusted_user->id(), 'format' => 'restricted_plus_dangerous_tag_with_editor'),
- array('author' => $this->privileged_user->id(), 'format' => 'unrestricted_without_editor'),
- array('author' => $this->privileged_user->id(), 'format' => 'unrestricted_with_editor'),
+ array('author' => $this->untrustedUser->id(), 'format' => 'restricted_without_editor'),
+ array('author' => $this->normalUser->id(), 'format' => 'restricted_with_editor'),
+ array('author' => $this->trustedUser->id(), 'format' => 'restricted_plus_dangerous_tag_with_editor'),
+ array('author' => $this->privilegedUser->id(), 'format' => 'unrestricted_without_editor'),
+ array('author' => $this->privilegedUser->id(), 'format' => 'unrestricted_with_editor'),
);
foreach ($samples as $sample) {
$this->drupalCreateNode(array(
@@ -234,8 +234,8 @@ class EditorSecurityTest extends WebTestBase {
// No text editor => no XSS filtering.
'value' => self::$sampleContent,
'users' => array(
- $this->untrusted_user,
- $this->privileged_user,
+ $this->untrustedUser,
+ $this->privilegedUser,
),
),
array(
@@ -244,8 +244,8 @@ class EditorSecurityTest extends WebTestBase {
// Text editor => XSS filtering.
'value' => self::$sampleContentSecured,
'users' => array(
- $this->normal_user,
- $this->privileged_user,
+ $this->normalUser,
+ $this->privilegedUser,
),
),
array(
@@ -254,8 +254,8 @@ class EditorSecurityTest extends WebTestBase {
// Text editor => XSS filtering.
'value' => self::$sampleContentSecuredEmbedAllowed,
'users' => array(
- $this->trusted_user,
- $this->privileged_user,
+ $this->trustedUser,
+ $this->privilegedUser,
),
),
array(
@@ -264,7 +264,7 @@ class EditorSecurityTest extends WebTestBase {
// No text editor => no XSS filtering.
'value' => self::$sampleContent,
'users' => array(
- $this->privileged_user,
+ $this->privilegedUser,
),
),
array(
@@ -273,7 +273,7 @@ class EditorSecurityTest extends WebTestBase {
// Text editor, no security filter => no XSS filtering.
'value' => self::$sampleContent,
'users' => array(
- $this->privileged_user,
+ $this->privilegedUser,
),
),
);
@@ -389,7 +389,7 @@ class EditorSecurityTest extends WebTestBase {
// - switch to every other text format/editor
// - assert the XSS-filtered values that we get from the server
$value_original_attribute = String::checkPlain(self::$sampleContent);
- $this->drupalLogin($this->privileged_user);
+ $this->drupalLogin($this->privilegedUser);
foreach ($expected as $case) {
$this->drupalGet('node/' . $case['node_id'] . '/edit');
@@ -422,7 +422,7 @@ class EditorSecurityTest extends WebTestBase {
*/
function testEditorXssFilterOverride() {
// First: the Standard text editor XSS filter.
- $this->drupalLogin($this->normal_user);
+ $this->drupalLogin($this->normalUser);
$this->drupalGet('node/2/edit');
$dom_node = $this->xpath('//textarea[@id="edit-body-0-value"]');
$this->assertIdentical(self::$sampleContentSecured, (string) $dom_node[0], 'The value was filtered by the Standard text editor XSS filter.');
diff --git a/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php b/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php
index cce6e04..c4b81ea 100644
--- a/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php
+++ b/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php
@@ -29,7 +29,7 @@ class QuickEditIntegrationLoadingTest extends WebTestBase {
*
* @var array
*/
- protected static $basic_permissions = array('access content', 'create article content', 'use text format filtered_html', 'access contextual links');
+ protected static $basicPermissions = array('access content', 'create article content', 'use text format filtered_html', 'access contextual links');
protected function setUp() {
parent::setUp();
@@ -74,9 +74,9 @@ class QuickEditIntegrationLoadingTest extends WebTestBase {
// - the 'access in-place editing' permission
// - the 'edit any article content' permission (necessary to edit node 1)
$users = array(
- $this->drupalCreateUser(static::$basic_permissions),
- $this->drupalCreateUser(array_merge(static::$basic_permissions, array('edit any article content'))),
- $this->drupalCreateUser(array_merge(static::$basic_permissions, array('access in-place editing')))
+ $this->drupalCreateUser(static::$basicPermissions),
+ $this->drupalCreateUser(array_merge(static::$basicPermissions, array('edit any article content'))),
+ $this->drupalCreateUser(array_merge(static::$basicPermissions, array('access in-place editing')))
);
// Now test with each of the 3 users with insufficient permissions.
@@ -98,7 +98,7 @@ class QuickEditIntegrationLoadingTest extends WebTestBase {
* Test loading of untransformed text when a user does have access to it.
*/
public function testUserWithPermission() {
- $user = $this->drupalCreateUser(array_merge(static::$basic_permissions, array('edit any article content', 'access in-place editing')));
+ $user = $this->drupalCreateUser(array_merge(static::$basicPermissions, array('edit any article content', 'access in-place editing')));
$this->drupalLogin($user);
$this->drupalGet('node/1');
diff --git a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php
index ee43da0..28b0f4b 100644
--- a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php
+++ b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php
@@ -62,7 +62,7 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
*
* @var string
*/
- protected $field_name;
+ protected $fieldName;
protected function setUp() {
parent::setUp();
@@ -71,9 +71,9 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
$this->installSchema('system', 'url_alias');
// Create a field.
- $this->field_name = 'field_textarea';
+ $this->fieldName = 'field_textarea';
$this->createFieldWithStorage(
- $this->field_name, 'text', 1, 'Long text field',
+ $this->fieldName, 'text', 1, 'Long text field',
// Instance settings.
array(),
// Widget type & settings.
@@ -132,22 +132,22 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
// Create an entity with values for this text field.
$entity = entity_create('entity_test');
- $entity->{$this->field_name}->value = 'Hello, world!';
- $entity->{$this->field_name}->format = 'filtered_html';
+ $entity->{$this->fieldName}->value = 'Hello, world!';
+ $entity->{$this->fieldName}->format = 'filtered_html';
$entity->save();
// Editor selection w/ cardinality 1, text format w/o associated text editor.
- $this->assertEqual('form', $this->getSelectedEditor($entity->id(), $this->field_name), "With cardinality 1, and the filtered_html text format, the 'form' editor is selected.");
+ $this->assertEqual('form', $this->getSelectedEditor($entity->id(), $this->fieldName), "With cardinality 1, and the filtered_html text format, the 'form' editor is selected.");
// Editor selection w/ cardinality 1, text format w/ associated text editor.
- $entity->{$this->field_name}->format = 'full_html';
+ $entity->{$this->fieldName}->format = 'full_html';
$entity->save();
- $this->assertEqual('editor', $this->getSelectedEditor($entity->id(), $this->field_name), "With cardinality 1, and the full_html text format, the 'editor' editor is selected.");
+ $this->assertEqual('editor', $this->getSelectedEditor($entity->id(), $this->fieldName), "With cardinality 1, and the full_html text format, the 'editor' editor is selected.");
// Editor selection with text processing, cardinality >1
$this->fields->field_textarea_field_storage->cardinality = 2;
$this->fields->field_textarea_field_storage->save();
- $this->assertEqual('form', $this->getSelectedEditor($entity->id(), $this->field_name), "With cardinality >1, and both items using the full_html text format, the 'form' editor is selected.");
+ $this->assertEqual('form', $this->getSelectedEditor($entity->id(), $this->fieldName), "With cardinality >1, and both items using the full_html text format, the 'form' editor is selected.");
}
/**
@@ -161,13 +161,13 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
// Create an entity with values for the field.
$entity = entity_create('entity_test');
- $entity->{$this->field_name}->value = 'Test';
- $entity->{$this->field_name}->format = 'full_html';
+ $entity->{$this->fieldName}->value = 'Test';
+ $entity->{$this->fieldName}->format = 'full_html';
$entity->save();
$entity = entity_load('entity_test', $entity->id());
// Verify metadata.
- $items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($this->field_name);
+ $items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($this->fieldName);
$metadata = $this->metadataGenerator->generateFieldMetadata($items, 'default');
$expected = array(
'access' => TRUE,
@@ -199,15 +199,15 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
public function testGetUntransformedTextCommand() {
// Create an entity with values for the field.
$entity = entity_create('entity_test');
- $entity->{$this->field_name}->value = 'Test';
- $entity->{$this->field_name}->format = 'full_html';
+ $entity->{$this->fieldName}->value = 'Test';
+ $entity->{$this->fieldName}->format = 'full_html';
$entity->save();
$entity = entity_load('entity_test', $entity->id());
// Verify AJAX response.
$controller = new EditorController();
$request = new Request();
- $response = $controller->getUntransformedText($entity, $this->field_name, LanguageInterface::LANGCODE_NOT_SPECIFIED, 'default');
+ $response = $controller->getUntransformedText($entity, $this->fieldName, LanguageInterface::LANGCODE_NOT_SPECIFIED, 'default');
$expected = array(
array(
'command' => 'editorGetUntransformedText',