From 5ed1ed8c8aedf28b7f30a82f18843255f097ef4a Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Thu, 11 Dec 2014 16:53:18 +0100 Subject: [PATCH] Issue #2388009 by hussainweb: Clean-up shortcut module test members - ensure property definition and use of camelCase naming convention --- .../shortcut/src/Tests/ShortcutLinksTest.php | 2 +- .../shortcut/src/Tests/ShortcutSetsTest.php | 28 +++++++++---------- .../shortcut/src/Tests/ShortcutTestBase.php | 18 ++++++++---- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php index dffdd4868b4..d029073c984 100644 --- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php @@ -77,7 +77,7 @@ class ShortcutLinksTest extends ShortcutTestBase { // Login as non admin user, to check that access is checked when creating // shortcuts. - $this->drupalLogin($this->shortcut_user); + $this->drupalLogin($this->shortcutUser); $title = $this->randomMachineName(); $form_data = [ 'title[0][value]' => $title, diff --git a/core/modules/shortcut/src/Tests/ShortcutSetsTest.php b/core/modules/shortcut/src/Tests/ShortcutSetsTest.php index 66713dcb527..34f394dabb9 100644 --- a/core/modules/shortcut/src/Tests/ShortcutSetsTest.php +++ b/core/modules/shortcut/src/Tests/ShortcutSetsTest.php @@ -28,7 +28,7 @@ class ShortcutSetsTest extends ShortcutTestBase { $this->drupalPostForm(NULL, $edit, t('Save')); $new_set = $this->container->get('entity.manager')->getStorage('shortcut_set')->load($edit['id']); $this->assertIdentical($new_set->id(), $edit['id'], 'Successfully created a shortcut set.'); - $this->drupalGet('user/' . $this->admin_user->id() . '/shortcuts'); + $this->drupalGet('user/' . $this->adminUser->id() . '/shortcuts'); $this->assertText($new_set->label(), 'Generated shortcut set was listed as a choice on the user account page.'); } @@ -92,9 +92,9 @@ class ShortcutSetsTest extends ShortcutTestBase { // Attempt to switch the default shortcut set to the newly created shortcut // set. - $this->drupalPostForm('user/' . $this->admin_user->id() . '/shortcuts', array('set' => $new_set->id()), t('Change set')); + $this->drupalPostForm('user/' . $this->adminUser->id() . '/shortcuts', array('set' => $new_set->id()), t('Change set')); $this->assertResponse(200); - $current_set = shortcut_current_displayed_set($this->admin_user); + $current_set = shortcut_current_displayed_set($this->adminUser); $this->assertTrue($new_set->id() == $current_set->id(), 'Successfully switched own shortcut set.'); } @@ -104,8 +104,8 @@ class ShortcutSetsTest extends ShortcutTestBase { function testShortcutSetAssign() { $new_set = $this->generateShortcutSet($this->randomMachineName()); - shortcut_set_assign_user($new_set, $this->shortcut_user); - $current_set = shortcut_current_displayed_set($this->shortcut_user); + shortcut_set_assign_user($new_set, $this->shortcutUser); + $current_set = shortcut_current_displayed_set($this->shortcutUser); $this->assertTrue($new_set->id() == $current_set->id(), "Successfully switched another user's shortcut set."); } @@ -118,8 +118,8 @@ class ShortcutSetsTest extends ShortcutTestBase { 'id' => strtolower($this->randomMachineName()), 'label' => $this->randomString(), ); - $this->drupalPostForm('user/' . $this->admin_user->id() . '/shortcuts', $edit, t('Change set')); - $current_set = shortcut_current_displayed_set($this->admin_user); + $this->drupalPostForm('user/' . $this->adminUser->id() . '/shortcuts', $edit, t('Change set')); + $current_set = shortcut_current_displayed_set($this->adminUser); $this->assertNotEqual($current_set->id(), $this->set->id(), 'A shortcut set can be switched to at the same time as it is created.'); $this->assertEqual($current_set->label(), $edit['label'], 'The new set is correctly assigned to the user.'); } @@ -129,9 +129,9 @@ class ShortcutSetsTest extends ShortcutTestBase { */ function testShortcutSetSwitchNoSetName() { $edit = array('set' => 'new'); - $this->drupalPostForm('user/' . $this->admin_user->id() . '/shortcuts', $edit, t('Change set')); + $this->drupalPostForm('user/' . $this->adminUser->id() . '/shortcuts', $edit, t('Change set')); $this->assertText(t('The new set label is required.')); - $current_set = shortcut_current_displayed_set($this->admin_user); + $current_set = shortcut_current_displayed_set($this->adminUser); $this->assertEqual($current_set->id(), $this->set->id(), 'Attempting to switch to a new shortcut set without providing a set name does not succeed.'); } @@ -167,10 +167,10 @@ class ShortcutSetsTest extends ShortcutTestBase { function testShortcutSetUnassign() { $new_set = $this->generateShortcutSet($this->randomMachineName()); - shortcut_set_assign_user($new_set, $this->shortcut_user); - shortcut_set_unassign_user($this->shortcut_user); - $current_set = shortcut_current_displayed_set($this->shortcut_user); - $default_set = shortcut_default_set($this->shortcut_user); + shortcut_set_assign_user($new_set, $this->shortcutUser); + shortcut_set_unassign_user($this->shortcutUser); + $current_set = shortcut_current_displayed_set($this->shortcutUser); + $default_set = shortcut_default_set($this->shortcutUser); $this->assertTrue($current_set->id() == $default_set->id(), "Successfully unassigned another user's shortcut set."); } @@ -201,7 +201,7 @@ class ShortcutSetsTest extends ShortcutTestBase { $new_set = $this->generateShortcutSet($random_name, $random_name); $sets = ShortcutSet::loadMultiple(); $this->assertTrue(isset($sets[$random_name]), 'Successfully created a shortcut set with a defined set name.'); - $this->drupalGet('user/' . $this->admin_user->id() . '/shortcuts'); + $this->drupalGet('user/' . $this->adminUser->id() . '/shortcuts'); $this->assertText($new_set->label(), 'Generated shortcut set was listed as a choice on the user account page.'); } } diff --git a/core/modules/shortcut/src/Tests/ShortcutTestBase.php b/core/modules/shortcut/src/Tests/ShortcutTestBase.php index 388f5d21901..966891c361d 100644 --- a/core/modules/shortcut/src/Tests/ShortcutTestBase.php +++ b/core/modules/shortcut/src/Tests/ShortcutTestBase.php @@ -26,16 +26,22 @@ abstract class ShortcutTestBase extends WebTestBase { /** * User with permission to administer shortcuts. + * + * @var \Drupal\user\UserInterface */ - protected $admin_user; + protected $adminUser; /** * User with permission to use shortcuts, but not administer them. + * + * @var \Drupal\user\UserInterface */ - protected $shortcut_user; + protected $shortcutUser; /** * Generic node used for testing. + * + * @var \Drupal\node\NodeInterface */ protected $node; @@ -73,16 +79,16 @@ abstract class ShortcutTestBase extends WebTestBase { } // Create users. - $this->admin_user = $this->drupalCreateUser(array('access toolbar', 'administer shortcuts', 'view the administration theme', 'create article content', 'create page content', 'access content overview', 'administer users', 'link to any page')); - $this->shortcut_user = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets', 'access shortcuts', 'access content')); + $this->adminUser = $this->drupalCreateUser(array('access toolbar', 'administer shortcuts', 'view the administration theme', 'create article content', 'create page content', 'access content overview', 'administer users', 'link to any page')); + $this->shortcutUser = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets', 'access shortcuts', 'access content')); // Create a node. $this->node = $this->drupalCreateNode(array('type' => 'article')); // Log in as admin and grab the default shortcut set. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->set = ShortcutSet::load('default'); - shortcut_set_assign_user($this->set, $this->admin_user); + shortcut_set_assign_user($this->set, $this->adminUser); } /**