Commit 5ed1ed8c authored by alexpott's avatar alexpott

Issue #2388009 by hussainweb: Clean-up shortcut module test members - ensure...

Issue #2388009 by hussainweb: Clean-up shortcut module test members - ensure property definition and use of camelCase naming convention
parent 4615f8c3
......@@ -77,7 +77,7 @@ public function testShortcutLinkAdd() {
// 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,
......
......@@ -28,7 +28,7 @@ function testShortcutSetAdd() {
$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 @@ function testShortcutSetSwitchOwn() {
// 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 @@ function testShortcutSetSwitchOwn() {
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 @@ function testShortcutSetSwitchCreate() {
'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 @@ function testShortcutSetSwitchCreate() {
*/
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 @@ function testShortcutSetRenameAlreadyExists() {
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 @@ function testShortcutSetCreateWithSetName() {
$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.');
}
}
......@@ -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 @@ protected function setUp() {
}
// 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);
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment