Skip to content
Snippets Groups Projects
Commit 86ced511 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2380411 by areke, hussainweb, GPrince17: Clean-up Text module test...

Issue #2380411 by areke, hussainweb, GPrince17: Clean-up Text module test members - ensure property definition and use of camelCase naming convention
parent 5e83b6c6
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -33,13 +33,18 @@ class StringFieldTest extends WebTestBase { ...@@ -33,13 +33,18 @@ class StringFieldTest extends WebTestBase {
*/ */
public static $modules = array('entity_test'); public static $modules = array('entity_test');
protected $web_user; /**
* A user without any special permissions.
*
* @var \Drupal\user\UserInterface
*/
protected $webUser;
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content')); $this->webUser = $this->drupalCreateUser(array('view test entity', 'administer entity_test content'));
$this->drupalLogin($this->web_user); $this->drupalLogin($this->webUser);
} }
// Test fields. // Test fields.
......
...@@ -18,12 +18,17 @@ ...@@ -18,12 +18,17 @@
*/ */
class TextFieldTest extends StringFieldTest { class TextFieldTest extends StringFieldTest {
protected $admin_user; /**
* A user with relevant administrative privileges.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->admin_user = $this->drupalCreateUser(array('administer filters')); $this->adminUser = $this->drupalCreateUser(array('administer filters'));
} }
// Test fields. // Test fields.
...@@ -106,13 +111,13 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { ...@@ -106,13 +111,13 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
->save(); ->save();
// Disable all text formats besides the plain text fallback format. // Disable all text formats besides the plain text fallback format.
$this->drupalLogin($this->admin_user); $this->drupalLogin($this->adminUser);
foreach (filter_formats() as $format) { foreach (filter_formats() as $format) {
if (!$format->isFallbackFormat()) { if (!$format->isFallbackFormat()) {
$this->drupalPostForm('admin/config/content/formats/manage/' . $format->format . '/disable', array(), t('Disable')); $this->drupalPostForm('admin/config/content/formats/manage/' . $format->format . '/disable', array(), t('Disable'));
} }
} }
$this->drupalLogin($this->web_user); $this->drupalLogin($this->webUser);
// Display the creation form. Since the user only has access to one format, // Display the creation form. Since the user only has access to one format,
// no format selector will be displayed. // no format selector will be displayed.
...@@ -140,7 +145,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { ...@@ -140,7 +145,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
// Create a new text format that does not escape HTML, and grant the user // Create a new text format that does not escape HTML, and grant the user
// access to it. // access to it.
$this->drupalLogin($this->admin_user); $this->drupalLogin($this->adminUser);
$edit = array( $edit = array(
'format' => Unicode::strtolower($this->randomMachineName()), 'format' => Unicode::strtolower($this->randomMachineName()),
'name' => $this->randomMachineName(), 'name' => $this->randomMachineName(),
...@@ -150,10 +155,10 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { ...@@ -150,10 +155,10 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
$format = entity_load('filter_format', $edit['format']); $format = entity_load('filter_format', $edit['format']);
$format_id = $format->format; $format_id = $format->format;
$permission = $format->getPermissionName(); $permission = $format->getPermissionName();
$roles = $this->web_user->getRoles(); $roles = $this->webUser->getRoles();
$rid = $roles[0]; $rid = $roles[0];
user_role_grant_permissions($rid, array($permission)); user_role_grant_permissions($rid, array($permission));
$this->drupalLogin($this->web_user); $this->drupalLogin($this->webUser);
// Display edition form. // Display edition form.
// We should now have a 'text format' selector. // We should now have a 'text format' selector.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment