diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php index 8dd2ab6..dceec15 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php @@ -19,6 +19,41 @@ class NodeAccessFieldTest extends NodeTestBase { */ public static $modules = array('node_access_test', 'field_ui'); + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * An adminstrative user with content administration permissions. + * + * @var object|false + */ + protected $contentAdminUser; + + /** + * + * + * @var + */ + protected $field; + + /** + * + * + * @var + */ + protected $field_name; + + /** + * + * + * @var + */ + protected $instance; + public static function getInfo() { return array( 'name' => 'Node access and fields', @@ -33,8 +68,8 @@ public function setUp() { node_access_rebuild(); // Create some users. - $this->admin_user = $this->drupalCreateUser(array('access content', 'bypass node access')); - $this->content_admin_user = $this->drupalCreateUser(array('access content', 'administer content types')); + $this->adminUser = $this->drupalCreateUser(array('access content', 'bypass node access')); + $this->contentAdminUser = $this->drupalCreateUser(array('access content', 'administer content types')); // Add a custom field to the page content type. $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); @@ -58,12 +93,12 @@ function testNodeAccessAdministerField() { $node = $this->drupalCreateNode(array($this->field_name => $field_data)); // Log in as the administrator and confirm that the field value is present. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet("node/{$node->nid}"); $this->assertText($value, 'The saved field value is visible to an administrator.'); // Log in as the content admin and try to view the node. - $this->drupalLogin($this->content_admin_user); + $this->drupalLogin($this->contentAdminUser); $this->drupalGet("node/{$node->nid}"); $this->assertText('Access denied', 'Access is denied for the content admin.'); @@ -78,7 +113,7 @@ function testNodeAccessAdministerField() { ); // Log in as the administrator. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); // Confirm that the existing node still has the correct field value. $this->drupalGet("node/{$node->nid}"); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php index bf8f845..9971691 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php @@ -21,6 +21,13 @@ class NodeAccessPagerTest extends WebTestBase { */ public static $modules = array('node_access_test', 'comment', 'forum'); + /** + * An anonymous user. + * + * @var object|false + */ + protected $webUser; + public static function getInfo() { return array( 'name' => 'Node access pagination', @@ -33,7 +40,7 @@ public function setUp() { parent::setUp(); node_access_rebuild(); - $this->web_user = $this->drupalCreateUser(array('access content', 'access comments', 'node test view')); + $this->webUser = $this->drupalCreateUser(array('access content', 'access comments', 'node test view')); } /** @@ -57,7 +64,7 @@ public function testCommentPager() { $comment->save(); } - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // View the node page. With the default 50 comments per page there should // be two pages (0, 1) but no third (2) page. @@ -96,7 +103,7 @@ public function testForumPager() { // View the general discussion forum page. With the default 25 nodes per // page there should be two pages for 30 nodes, no more. - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); $this->drupalGet('forum/' . $tid); $this->assertRaw('page=1'); $this->assertNoRaw('page=2'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php index 3c02765..2dd2c28 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php @@ -11,6 +11,35 @@ * Test node administration page functionality. */ class NodeAdminTest extends NodeTestBase { + + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * The first web user. + * + * @var object|false + */ + protected $webUser1; + + /** + * The second web user. + * + * @var object|false + */ + protected $webUser2; + + /** + * The third web user. + * + * @var object|false + */ + protected $webUser3; + public static function getInfo() { return array( 'name' => 'Node administration', @@ -27,17 +56,17 @@ function setUp() { // correctly. user_role_revoke_permissions(DRUPAL_AUTHENTICATED_RID, array('view own unpublished content')); - $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'access content overview', 'administer nodes', 'bypass node access')); - $this->base_user_1 = $this->drupalCreateUser(array('access content overview')); - $this->base_user_2 = $this->drupalCreateUser(array('access content overview', 'view own unpublished content')); - $this->base_user_3 = $this->drupalCreateUser(array('access content overview', 'bypass node access')); + $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'access content overview', 'administer nodes', 'bypass node access')); + $this->webUser1 = $this->drupalCreateUser(array('access content overview')); + $this->webUser2 = $this->drupalCreateUser(array('access content overview', 'view own unpublished content')); + $this->webUser3 = $this->drupalCreateUser(array('access content overview', 'bypass node access')); } /** * Tests that the table sorting works on the content admin pages. */ function testContentAdminSort() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); foreach (array('dd', 'aa', 'DD', 'bb', 'cc', 'CC', 'AA', 'BB') as $prefix) { $this->drupalCreateNode(array('title' => $prefix . $this->randomName(6))); } @@ -79,12 +108,12 @@ function testContentAdminSort() { * @see TaxonomyNodeFilterTestCase */ function testContentAdminPages() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $nodes['published_page'] = $this->drupalCreateNode(array('type' => 'page')); $nodes['published_article'] = $this->drupalCreateNode(array('type' => 'article')); - $nodes['unpublished_page_1'] = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->base_user_1->uid, 'status' => 0)); - $nodes['unpublished_page_2'] = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->base_user_2->uid, 'status' => 0)); + $nodes['unpublished_page_1'] = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->webUser1->uid, 'status' => 0)); + $nodes['unpublished_page_2'] = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->webUser2->uid, 'status' => 0)); // Verify view, edit, and delete links for any content. $this->drupalGet('admin/content'); @@ -123,7 +152,7 @@ function testContentAdminPages() { // Verify no operation links are displayed for regular users. $this->drupalLogout(); - $this->drupalLogin($this->base_user_1); + $this->drupalLogin($this->webUser1); $this->drupalGet('admin/content'); $this->assertResponse(200); $this->assertLinkByHref('node/' . $nodes['published_page']->nid); @@ -143,7 +172,7 @@ function testContentAdminPages() { // Verify unpublished content is displayed with permission. $this->drupalLogout(); - $this->drupalLogin($this->base_user_2); + $this->drupalLogin($this->webUser2); $this->drupalGet('admin/content'); $this->assertResponse(200); $this->assertLinkByHref('node/' . $nodes['unpublished_page_2']->nid); @@ -161,7 +190,7 @@ function testContentAdminPages() { // Verify node access can be bypassed. $this->drupalLogout(); - $this->drupalLogin($this->base_user_3); + $this->drupalLogin($this->webUser3); $this->drupalGet('admin/content'); $this->assertResponse(200); foreach ($nodes as $node) { diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php index edcb007..d29dc2f 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php @@ -19,6 +19,20 @@ class NodeBlockFunctionalTest extends NodeTestBase { */ public static $modules = array('block'); + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + public static function getInfo() { return array( 'name' => 'Node blocks', @@ -31,15 +45,15 @@ function setUp() { parent::setUp(); // Create users and test node. - $this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer nodes', 'administer blocks')); - $this->web_user = $this->drupalCreateUser(array('access content', 'create article content')); + $this->adminUser = $this->drupalCreateUser(array('administer content types', 'administer nodes', 'administer blocks')); + $this->webUser = $this->drupalCreateUser(array('access content', 'create article content')); } /** * Test the recent comments block. */ function testRecentNodeBlock() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); // Disallow anonymous users to view content. user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( @@ -66,7 +80,7 @@ function testRecentNodeBlock() { $this->assertText(t('No content available.'), 'Block with "No content available." found.'); // Add some test nodes. - $default_settings = array('uid' => $this->web_user->uid, 'type' => 'article'); + $default_settings = array('uid' => $this->webUser->uid, 'type' => 'article'); $node1 = $this->drupalCreateNode($default_settings); $node2 = $this->drupalCreateNode($default_settings); $node3 = $this->drupalCreateNode($default_settings); @@ -92,7 +106,7 @@ function testRecentNodeBlock() { $this->assertNoText($block['title'], 'Block was not found.'); // Test that only the 2 latest nodes are shown. - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); $this->assertNoText($node1->label(), 'Node not found in block.'); $this->assertText($node2->label(), 'Node found in block.'); $this->assertText($node3->label(), 'Node found in block.'); @@ -102,7 +116,7 @@ function testRecentNodeBlock() { // Set the number of recent nodes to show to 10. $this->drupalLogout(); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $block = array( 'node_recent_block_count' => 10, ); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php index 2333dd9..00d360f 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php @@ -19,24 +19,28 @@ class NodeEntityFieldQueryAlterTest extends NodeTestBase { */ public static $modules = array('node_access_test'); - public static function getInfo() { - return array( - 'name' => 'Node entity query alter', - 'description' => 'Test that node access entity queries are properly altered by the node module.', - 'group' => 'Node', - ); - } - /** * User with permission to view content. + * + * @var object|false */ protected $accessUser; /** * User without permission to view content. + * + * @var object|false */ protected $noAccessUser; + public static function getInfo() { + return array( + 'name' => 'Node entity query alter', + 'description' => 'Test that node access entity queries are properly altered by the node module.', + 'group' => 'Node', + ); + } + function setUp() { parent::setUp(); node_access_rebuild(); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php index 299a00c..5c0fc84 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php @@ -21,24 +21,28 @@ class NodeQueryAlterTest extends NodeTestBase { */ public static $modules = array('node_access_test'); - public static function getInfo() { - return array( - 'name' => 'Node query alter', - 'description' => 'Test that node access queries are properly altered by the node module.', - 'group' => 'Node', - ); - } - /** * User with permission to view content. + * + * @var object|false */ protected $accessUser; /** * User without permission to view content. + * + * @var object|false */ protected $noAccessUser; + public static function getInfo() { + return array( + 'name' => 'Node query alter', + 'description' => 'Test that node access queries are properly altered by the node module.', + 'group' => 'Node', + ); + } + function setUp() { parent::setUp(); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php index 1880d4f..66d1f32 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php @@ -19,7 +19,12 @@ class NodeTitleTest extends NodeTestBase { */ public static $modules = array('comment'); - protected $admin_user; + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; public static function getInfo() { return array( @@ -32,16 +37,21 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer nodes', 'create article content', 'create page content', 'post comments')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array( + 'administer nodes', + 'create article content', + 'create page content', + 'post comments', + )); + $this->drupalLogin($this->adminUser); } /** - * Create one node and test if the node title has the correct value. + * Creates one node and test if the node title has the correct value. */ function testNodeTitle() { // Create "Basic page" content with title. - // Add the node to the frontpage so we can test if teaser links are clickable. + // Add node to the frontpage so we can test if teaser links are clickable. $settings = array( 'title' => $this->randomName(8), 'promote' => 1, diff --git a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php index 8d4e0fe..c753922 100644 --- a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php @@ -8,8 +8,20 @@ namespace Drupal\node\Tests; class PageEditTest extends NodeTestBase { - protected $web_user; - protected $admin_user; + + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; public static function getInfo() { return array( @@ -22,15 +34,15 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->web_user = $this->drupalCreateUser(array('edit own page content', 'create page content')); - $this->admin_user = $this->drupalCreateUser(array('bypass node access', 'administer nodes')); + $this->adminUser = $this->drupalCreateUser(array('bypass node access', 'administer nodes')); + $this->webUser = $this->drupalCreateUser(array('edit own page content', 'create page content')); } /** - * Check node edit functionality. + * Checks node edit functionality. */ function testPageEdit() { - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); $langcode = LANGUAGE_NOT_SPECIFIED; $title_key = "title"; @@ -70,8 +82,8 @@ function testPageEdit() { $this->assertText($edit[$body_key], 'Body displayed.'); // Login as a second administrator user. - $second_web_user = $this->drupalCreateUser(array('administer nodes', 'edit any page content')); - $this->drupalLogin($second_web_user); + $second_webUser = $this->drupalCreateUser(array('administer nodes', 'edit any page content')); + $this->drupalLogin($second_webUser); // Edit the same node, creating a new revision. $this->drupalGet("node/$node->nid/edit"); $edit = array(); @@ -94,10 +106,10 @@ function testPageEdit() { } /** - * Check changing node authored by fields. + * Checks changing node authored by fields. */ function testPageAuthoredBy() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); // Create node to edit. $langcode = LANGUAGE_NOT_SPECIFIED; @@ -109,7 +121,7 @@ function testPageAuthoredBy() { // Check that the node was authored by the currently logged in user. $node = $this->drupalGetNodeByTitle($edit['title']); - $this->assertIdentical($node->uid, $this->admin_user->uid, 'Node authored by admin user.'); + $this->assertIdentical($node->uid, $this->adminUser->uid, 'Node authored by admin user.'); // Try to change the 'authored by' field to an invalid user name. $edit = array( @@ -127,13 +139,13 @@ function testPageAuthoredBy() { // Change the authored by field to another user's name (that is not // logged in). - $edit['name'] = $this->web_user->name; + $edit['name'] = $this->webUser->name; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $node = node_load($node->nid, TRUE); - $this->assertIdentical($node->uid, $this->web_user->uid, 'Node authored by normal user.'); + $this->assertIdentical($node->uid, $this->webUser->uid, 'Node authored by normal user.'); // Check that normal users cannot change the authored by information. - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); $this->drupalGet('node/' . $node->nid . '/edit'); $this->assertNoFieldByName('name'); } diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php index b359f37..2c4a7b9 100644 --- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php +++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php @@ -21,7 +21,12 @@ class OpenIDFunctionalTest extends OpenIDTestBase { */ public static $modules = array('openid_test'); - protected $web_user; + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; public static function getInfo() { return array( @@ -35,14 +40,14 @@ function setUp() { parent::setUp(); // User doesn't need special permissions; only the ability to log in. - $this->web_user = $this->drupalCreateUser(array()); + $this->webUser = $this->drupalCreateUser(array()); } /** - * Test discovery of OpenID Provider Endpoint via Yadis and HTML. + * Tests discovery of OpenID Provider Endpoint via Yadis and HTML. */ function testDiscovery() { - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // The User-supplied Identifier entered by the user may indicate the URL of // the OpenID Provider Endpoint in various ways, as described in OpenID @@ -130,10 +135,10 @@ function testDiscovery() { } /** - * Test login using OpenID. + * Tests login using OpenID. */ function testLogin() { - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // Use a User-supplied Identity that is the URL of an XRDS document. $identity = url('openid-test/yadis/xrds', array('absolute' => TRUE)); @@ -141,7 +146,7 @@ function testLogin() { $response = variable_get('openid_test_hook_openid_response_response'); $account = variable_get('openid_test_hook_openid_response_account'); $this->assertEqual($response['openid.claimed_id'], $identity, 'hook_openid_response() was invoked.'); - $this->assertEqual($account->uid, $this->web_user->uid, 'Proper user object passed to hook_openid_response().'); + $this->assertEqual($account->uid, $this->webUser->uid, 'Proper user object passed to hook_openid_response().'); $this->drupalLogout(); @@ -153,7 +158,7 @@ function testLogin() { $response = variable_get('openid_test_hook_openid_response_response'); $account = variable_get('openid_test_hook_openid_response_account'); $this->assertEqual($response['openid.claimed_id'], $identity, 'hook_openid_response() was invoked.'); - $this->assertEqual($account->uid, $this->web_user->uid, 'Proper user object passed to hook_openid_response().'); + $this->assertEqual($account->uid, $this->webUser->uid, 'Proper user object passed to hook_openid_response().'); $this->drupalLogout(); @@ -186,11 +191,11 @@ function testLogin() { } /** - * Test login using OpenID during maintenance mode. + * Tests login using OpenID during maintenance mode. */ function testLoginMaintenanceMode() { - $this->web_user = $this->drupalCreateUser(array('access site in maintenance mode')); - $this->drupalLogin($this->web_user); + $this->webUser = $this->drupalCreateUser(array('access site in maintenance mode')); + $this->drupalLogin($this->webUser); // Use a User-supplied Identity that is the URL of an XRDS document. $identity = url('openid-test/yadis/xrds', array('absolute' => TRUE)); @@ -219,10 +224,10 @@ function testLoginMaintenanceMode() { } /** - * Test deleting an OpenID identity from a user's profile. + * Tests deleting an OpenID identity from a user's profile. */ function testDelete() { - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // Add identity to user's profile. $identity = url('openid-test/yadis/xrds', array('absolute' => TRUE)); @@ -238,14 +243,14 @@ function testDelete() { } /** - * Test that a blocked user cannot log in. + * Tests that a blocked user cannot log in. */ function testBlockedUserLogin() { // Use a User-supplied Identity that is the URL of an XRDS document. $identity = url('openid-test/yadis/xrds', array('absolute' => TRUE)); // Log in and add an OpenID Identity to the account. - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); $this->addIdentity($identity); $this->drupalLogout(); @@ -255,18 +260,18 @@ function testBlockedUserLogin() { $this->drupalGet('admin/people'); $edit = array( 'operation' => 'block', - 'accounts[' . $this->web_user->uid . ']' => TRUE, + 'accounts[' . $this->webUser->uid . ']' => TRUE, ); $this->drupalPost('admin/people', $edit, t('Update')); $this->assertRaw('The update has been performed.', 'Account was blocked.'); $this->drupalLogout(); $this->submitLoginForm($identity); - $this->assertRaw(t('The username %name has not been activated or is blocked.', array('%name' => $this->web_user->name)), 'User login was blocked.'); + $this->assertRaw(t('The username %name has not been activated or is blocked.', array('%name' => $this->webUser->name)), 'User login was blocked.'); } /** - * Add OpenID identity to user's profile. + * Tests adding OpenID identity to user's profile. * * @param $identity * The User-supplied Identifier. @@ -283,7 +288,7 @@ function addIdentity($identity, $version = 2, $local_id = 'http://example.com/xr variable_set('openid_test_identity', $local_id); $edit = array('openid_identifier' => $identity); - $this->drupalPost('user/' . $this->web_user->uid . '/openid', $edit, t('Add an OpenID')); + $this->drupalPost('user/' . $this->webUser->uid . '/openid', $edit, t('Add an OpenID')); if ($claimed_id === FALSE) { $this->assertRaw(t('Sorry, that is not a valid OpenID. Ensure you have spelled your ID correctly.'), 'Invalid identity was rejected.'); @@ -306,7 +311,7 @@ function addIdentity($identity, $version = 2, $local_id = 'http://example.com/xr } /** - * Add OpenID identity, changed by the following redirects, to user's profile. + * Tests adding OpenID identity, changed by the following redirects, to user's profile. * * According to OpenID Authentication 2.0, section 7.2.4, URL Identifiers MUST * be further normalized by following redirects when retrieving their content diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php index 691c537..43cd4c1 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -19,6 +19,13 @@ class PathLanguageTest extends PathTestBase { */ public static $modules = array('path', 'locale', 'translation'); + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + public static function getInfo() { return array( 'name' => 'Path aliases with translated nodes', @@ -31,8 +38,16 @@ function setUp() { parent::setUp(); // Create and login user. - $this->web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'translate all content', 'access administration pages')); - $this->drupalLogin($this->web_user); + $this->webUser = $this->drupalCreateUser(array( + 'access administration pages', + 'administer languages', + 'administer url aliases', + 'create page content', + 'create url aliases', + 'edit any page content', + 'translate all content', + )); + $this->drupalLogin($this->webUser); // Enable French language. $edit = array(); @@ -109,7 +124,7 @@ function testAliasTranslation() { // Change user language preference. $edit = array('preferred_langcode' => 'fr'); - $this->drupalPost("user/{$this->web_user->uid}/edit", $edit, t('Save')); + $this->drupalPost("user/{$this->webUser->uid}/edit", $edit, t('Save')); // Check that the English alias works. In this situation French is the // current UI and content language, while URL language is English (since we diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php index 8efc02c..d349dfc 100644 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php +++ b/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php @@ -7,7 +7,32 @@ namespace Drupal\poll\Tests; +/** + * Checks usre poll vote capability. + */ class PollVoteCheckHostnameTest extends PollTestBase { + + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * The first web visitor. + * + * @var object|false + */ + protected $webUser1; + + /** + * The second web visitor. + * + * @var object|false + */ + protected $webUser2; + public static function getInfo() { return array( 'name' => 'User poll vote capability.', @@ -20,8 +45,8 @@ function setUp() { parent::setUp(); // Create and login user. - $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'create poll content')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer permissions', 'create poll content')); + $this->drupalLogin($this->adminUser); // Allow anonymous users to vote on polls. user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( @@ -44,8 +69,8 @@ function setUp() { $this->drupalLogout(); // Create web users. - $this->web_user1 = $this->drupalCreateUser(array('access content', 'vote on polls', 'cancel own vote')); - $this->web_user2 = $this->drupalCreateUser(array('access content', 'vote on polls')); + $this->webUser1 = $this->drupalCreateUser(array('access content', 'vote on polls', 'cancel own vote')); + $this->webUser2 = $this->drupalCreateUser(array('access content', 'vote on polls')); } /** @@ -56,7 +81,7 @@ function setUp() { */ function testHostnamePollVote() { // Login User1. - $this->drupalLogin($this->web_user1); + $this->drupalLogin($this->webUser1); $edit = array( 'choice' => '1', @@ -64,13 +89,13 @@ function testHostnamePollVote() { // User1 vote on Poll. $this->drupalPost('node/' . $this->poll_nid, $edit, t('Vote')); - $this->assertText(t('Your vote was recorded.'), format_string('%user vote was recorded.', array('%user' => $this->web_user1->name))); + $this->assertText(t('Your vote was recorded.'), format_string('%user vote was recorded.', array('%user' => $this->webUser1->name))); $this->assertText(t('Total votes: @votes', array('@votes' => 1)), 'Vote count updated correctly.'); // Check to make sure User1 cannot vote again. $this->drupalGet('node/' . $this->poll_nid); $elements = $this->xpath('//input[@value="Vote"]'); - $this->assertTrue(empty($elements), format_string("%user is not able to vote again.", array('%user' => $this->web_user1->name))); + $this->assertTrue(empty($elements), format_string("%user is not able to vote again.", array('%user' => $this->webUser1->name))); $elements = $this->xpath('//input[@value="Cancel your vote"]'); $this->assertTrue(!empty($elements), "'Cancel your vote' button appears."); @@ -99,11 +124,11 @@ function testHostnamePollVote() { $this->assertTrue(!empty($elements), "'Cancel your vote' button appears."); // Login User2. - $this->drupalLogin($this->web_user2); + $this->drupalLogin($this->webUser2); // User2 vote on poll. $this->drupalPost('node/' . $this->poll_nid, $edit, t('Vote')); - $this->assertText(t('Your vote was recorded.'), format_string('%user vote was recorded.', array('%user' => $this->web_user2->name))); + $this->assertText(t('Your vote was recorded.'), format_string('%user vote was recorded.', array('%user' => $this->webUser2->name))); $this->assertText(t('Total votes: @votes', array('@votes' => 3)), 'Vote count updated correctly.'); $elements = $this->xpath('//input[@value="Cancel your vote"]'); $this->assertTrue(empty($elements), "'Cancel your vote' button does not appear."); @@ -124,7 +149,7 @@ function testHostnamePollVote() { $this->drupalGet('node/' . $this->poll_nid); $this->assertEqual($this->drupalGetHeader('x-drupal-cache'), 'MISS', 'Page was cacheable but was not in the cache.'); $this->drupalPost(NULL, $edit, t('Vote')); - $this->assertText(t('Your vote was recorded.'), format_string('%user vote was recorded.', array('%user' => $this->web_user2->name))); + $this->assertText(t('Your vote was recorded.'), format_string('%user vote was recorded.', array('%user' => $this->webUser2->name))); $this->assertText(t('Total votes: @votes', array('@votes' => 4)), 'Vote count updated correctly.'); $elements = $this->xpath('//input[@value="Cancel your vote"]'); $this->assertTrue(!empty($elements), "'Cancel your vote' button appears."); @@ -140,12 +165,12 @@ function testHostnamePollVote() { $this->assertTrue(empty($elements), "'Cancel your vote' button does not appear."); // Login User1. - $this->drupalLogin($this->web_user1); + $this->drupalLogin($this->webUser1); // Check to make sure User1 still cannot vote even after hostname changed. $this->drupalGet('node/' . $this->poll_nid); $elements = $this->xpath('//input[@value="Vote"]'); - $this->assertTrue(empty($elements), format_string("%user is not able to vote again.", array('%user' => $this->web_user1->name))); + $this->assertTrue(empty($elements), format_string("%user is not able to vote again.", array('%user' => $this->webUser1->name))); $elements = $this->xpath('//input[@value="Cancel your vote"]'); $this->assertTrue(!empty($elements), "'Cancel your vote' button appears."); } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php index bb712b6..b2c730c 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php @@ -21,6 +21,20 @@ class CommentAttributesTest extends CommentTestBase { */ public static $modules = array('comment', 'rdf', 'rdf_test'); + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + public static function getInfo() { return array( 'name' => 'RDF comment mapping', @@ -32,8 +46,18 @@ public static function getInfo() { public function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer permissions', 'administer blocks')); - $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'access user profiles')); + $this->adminUser = $this->drupalCreateUser(array( + 'administer blocks', + 'administer comments', + 'administer content types', + 'administer permissions', + )); + $this->web_user = $this->drupalCreateUser(array( + 'access comments', + 'access user profiles', + 'create article content', + 'post comments', + )); // Enables anonymous user comments. user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php index cb35b06..1e6f31b 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php @@ -29,8 +29,14 @@ class SearchCommentCountToggleTest extends SearchTestBase { // Requires node types, comment config, filter formats. protected $profile = 'standard'; - protected $searching_user; - protected $searchable_nodes; + /** + * A searching user. + * + * @var object|false + */ + protected $searchingUser; + + protected $searchableNodes; public static function getInfo() { return array( @@ -44,16 +50,21 @@ function setUp() { parent::setUp(); // Create searching user. - $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); + $this->searchingUser = $this->drupalCreateUser(array( + 'access comments', + 'access content', + 'search content', + 'skip comment approval', + )); // Create initial nodes. $node_params = array('type' => 'article', 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'SearchCommentToggleTestCase')))); - $this->searchable_nodes['1 comment'] = $this->drupalCreateNode($node_params); - $this->searchable_nodes['0 comments'] = $this->drupalCreateNode($node_params); + $this->searchableNodes['1 comment'] = $this->drupalCreateNode($node_params); + $this->searchableNodes['0 comments'] = $this->drupalCreateNode($node_params); // Login with sufficient privileges. - $this->drupalLogin($this->searching_user); + $this->drupalLogin($this->searchingUser); // Create a comment array $edit_comment = array(); @@ -63,7 +74,7 @@ function setUp() { $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][format]'] = $filtered_html_format_id; // Post comment to the test node with comment - $this->drupalPost('comment/reply/' . $this->searchable_nodes['1 comment']->nid, $edit_comment, t('Save')); + $this->drupalPost('comment/reply/' . $this->searchableNodes['1 comment']->nid, $edit_comment, t('Save')); // First update the index. This does the initial processing. node_update_index(); @@ -89,20 +100,20 @@ function testSearchCommentCountToggle() { $this->assertText(t('1 comment'), t('Non-empty comment count displays for nodes with comment status set to Open')); // Test comment count display for nodes with comment status set to Closed - $this->searchable_nodes['0 comments']->comment = COMMENT_NODE_CLOSED; - node_save($this->searchable_nodes['0 comments']); - $this->searchable_nodes['1 comment']->comment = COMMENT_NODE_CLOSED; - node_save($this->searchable_nodes['1 comment']); + $this->searchableNodes['0 comments']->comment = COMMENT_NODE_CLOSED; + node_save($this->searchableNodes['0 comments']); + $this->searchableNodes['1 comment']->comment = COMMENT_NODE_CLOSED; + node_save($this->searchableNodes['1 comment']); $this->drupalPost('', $edit, t('Search')); $this->assertNoText(t('0 comments'), t('Empty comment count does not display for nodes with comment status set to Closed')); $this->assertText(t('1 comment'), t('Non-empty comment count displays for nodes with comment status set to Closed')); // Test comment count display for nodes with comment status set to Hidden - $this->searchable_nodes['0 comments']->comment = COMMENT_NODE_HIDDEN; - node_save($this->searchable_nodes['0 comments']); - $this->searchable_nodes['1 comment']->comment = COMMENT_NODE_HIDDEN; - node_save($this->searchable_nodes['1 comment']); + $this->searchableNodes['0 comments']->comment = COMMENT_NODE_HIDDEN; + node_save($this->searchableNodes['0 comments']); + $this->searchableNodes['1 comment']->comment = COMMENT_NODE_HIDDEN; + node_save($this->searchableNodes['1 comment']); $this->drupalPost('', $edit, t('Search')); $this->assertNoText(t('0 comments'), t('Empty comment count does not display for nodes with comment status set to Hidden')); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php index 8df2e99..c4bc575 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php @@ -8,7 +8,7 @@ namespace Drupal\search\Tests; /** - * Test integration searching comments. + * Tests integration searching comments. */ class SearchCommentTest extends SearchTestBase { @@ -21,7 +21,12 @@ class SearchCommentTest extends SearchTestBase { protected $profile = 'standard'; - protected $admin_user; + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; public static function getInfo() { return array( @@ -45,12 +50,12 @@ function setUp() { 'skip comment approval', 'access comments', ); - $this->admin_user = $this->drupalCreateUser($permissions); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser($permissions); + $this->drupalLogin($this->adminUser); } /** - * Verify that comments are rendered using proper format in search results. + * Verifies that comments are rendered using proper format in search results. */ function testSearchResultsComment() { $comment_body = 'Test comment body'; @@ -106,7 +111,7 @@ function testSearchResultsComment() { $this->assertNoRaw(check_plain($edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]']), t('HTML in comment body is not escaped.')); // Hide comments. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $node->comment = 0; $node->save(); @@ -120,12 +125,12 @@ function testSearchResultsComment() { } /** - * Verify access rules for comment indexing with different permissions. + * Verifies access rules for comment indexing with different permissions. */ function testSearchResultsCommentAccess() { $comment_body = 'Test comment body'; $this->comment_subject = 'Test comment subject'; - $this->admin_role = $this->admin_user->roles; + $this->admin_role = $this->adminUser->roles; unset($this->admin_role[DRUPAL_AUTHENTICATED_RID]); $this->admin_role = key($this->admin_role); @@ -146,7 +151,7 @@ function testSearchResultsCommentAccess() { $this->setRolePermissions(DRUPAL_ANONYMOUS_RID, TRUE); $this->assertCommentAccess(TRUE, 'Anon user has search permission and access comments permission, comments should be indexed'); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet('admin/people/permissions'); // Disable search access for authenticated user to test admin user. @@ -178,7 +183,7 @@ function testSearchResultsCommentAccess() { } /** - * Set permissions for role. + * Sets permissions for role. */ function setRolePermissions($rid, $access_comments = FALSE, $search_content = TRUE) { $permissions = array( @@ -189,7 +194,7 @@ function setRolePermissions($rid, $access_comments = FALSE, $search_content = TR } /** - * Update search index and search for comment. + * Updaste search index and searches for comment. */ function assertCommentAccess($assume_access, $message) { // Invoke search index update. @@ -214,7 +219,7 @@ function assertCommentAccess($assume_access, $message) { } /** - * Verify that 'add new comment' does not appear in search results or index. + * Verifies that 'add new comment' does not appear in search results or index. */ function testAddNewComment() { // Create a node with a short body. diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php index 7c123a0..fff2835 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php @@ -19,8 +19,14 @@ class SearchConfigSettingsFormTest extends SearchTestBase { */ public static $modules = array('block', 'search_extra_type'); - public $search_user; - public $search_node; + /** + * A search-enabled user. + * + * @var object|false + */ + protected $searchUser; + + public $searchNode; public static function getInfo() { return array( @@ -34,12 +40,20 @@ function setUp() { parent::setUp(); // Login as a user that can create and search content. - $this->search_user = $this->drupalCreateUser(array('search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks')); - $this->drupalLogin($this->search_user); + $this->searchUser = $this->drupalCreateUser(array( + 'access user profiles', + 'administer blocks', + 'administer nodes', + 'administer search', + 'administer users', + 'bypass node access', + 'search content', + )); + $this->drupalLogin($this->searchUser); // Add a single piece of content and index it. $node = $this->drupalCreateNode(); - $this->search_node = $node; + $this->searchNode = $node; // Link the node to itself to test that it's only indexed once. The content // also needs the word "pizza" so we can use it as the search keyword. $langcode = LANGUAGE_NOT_SPECIFIED; @@ -57,7 +71,7 @@ function setUp() { } /** - * Verify the search settings form. + * Verifies the search settings form. */ function testSearchSettingsPage() { @@ -86,7 +100,7 @@ function testSearchSettingsPage() { } /** - * Verify that you can disable individual search modules. + * Verifies that you can disable individual search modules. */ function testSearchModuleDisabling() { // Array of search modules to test: 'path' is the search path, 'title' is @@ -97,13 +111,13 @@ function testSearchModuleDisabling() { 'path' => 'node', 'title' => 'Content', 'keys' => 'pizza', - 'text' => $this->search_node->label(), + 'text' => $this->searchNode->label(), ), 'user' => array( 'path' => 'user', 'title' => 'User', - 'keys' => $this->search_user->name, - 'text' => $this->search_user->mail, + 'keys' => $this->searchUser->name, + 'text' => $this->searchUser->mail, ), 'search_extra_type' => array( 'path' => 'dummy_path', diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php index 87414fa..92065e9 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php @@ -19,6 +19,13 @@ class SearchKeywordsConditionsTest extends SearchTestBase { */ public static $modules = array('comment', 'search_extra_type'); + /** + * A search-enabled user. + * + * @var object|false + */ + protected $searchingUser; + public static function getInfo() { return array( 'name' => 'Keywords and conditions', @@ -31,16 +38,21 @@ function setUp() { parent::setUp(); // Create searching user. - $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); + $this->searchingUser = $this->drupalCreateUser(array( + 'access comments', + 'access content', + 'search content', + 'skip comment approval', + )); // Login with sufficient privileges. - $this->drupalLogin($this->searching_user); + $this->drupalLogin($this->searchingUser); // Test with all search modules enabled. config('search.settings')->set('active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type'))->save(); menu_router_rebuild(); } /** - * Verify the kewords are captured and conditions respected. + * Verifies the key words are captured and conditions respected. */ function testSearchKeyswordsConditions() { // No keys, not conditions - no results. diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php index 19c94cb..5c5b0a2 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php @@ -19,7 +19,12 @@ class SearchNodeAccessTest extends SearchTestBase { */ public static $modules = array('node_access_test'); - public $test_user; + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; public static function getInfo() { return array( @@ -34,8 +39,12 @@ function setUp() { node_access_rebuild(); // Create a test user and log in. - $this->test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search')); - $this->drupalLogin($this->test_user); + $this->webUser = $this->drupalCreateUser(array( + 'access content', + 'search content', + 'use advanced search', + )); + $this->drupalLogin($this->webUser); } /** diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php index 39cf650..c52ddd9 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php @@ -11,7 +11,14 @@ * Tests that numbers can be searched, with more complex matching. */ class SearchNumberMatchingTest extends SearchTestBase { - protected $test_user; + + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + protected $numbers; protected $nodes; @@ -26,8 +33,13 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); - $this->drupalLogin($this->test_user); + $this->webUser = $this->drupalCreateUser(array( + 'access content', + 'access site reports', + 'administer nodes', + 'search content', + )); + $this->drupalLogin($this->webUser); // Define a group of numbers that should all match each other -- // numbers with internal punctuation should match each other, as well diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php index dd119b9..8bff841 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php @@ -11,7 +11,14 @@ * Tests that numbers can be searched. */ class SearchNumbersTest extends SearchTestBase { - protected $test_user; + + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + protected $numbers; protected $nodes; @@ -26,8 +33,13 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); - $this->drupalLogin($this->test_user); + $this->webUser = $this->drupalCreateUser(array( + 'access content', + 'access site reports', + 'administer nodes', + 'search content', + )); + $this->drupalLogin($this->webUser); // Create content with various numbers in it. // Note: 50 characters is the current limit of the search index's word diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php index df72d2b..270b601 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php @@ -19,7 +19,12 @@ class SearchPageOverrideTest extends SearchTestBase { */ public static $modules = array('search_extra_type'); - public $search_user; + /** + * A search-enabled user. + * + * @var object|false + */ + protected $searchUser; public static function getInfo() { return array( @@ -33,8 +38,8 @@ function setUp() { parent::setUp(); // Login as a user that can create and search content. - $this->search_user = $this->drupalCreateUser(array('search content', 'administer search')); - $this->drupalLogin($this->search_user); + $this->searchUser = $this->drupalCreateUser(array('search content', 'administer search')); + $this->drupalLogin($this->searchUser); // Enable the extra type module for searching. config('search.settings')->set('active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type'))->save(); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php index 03b9619..4d60c3a 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php @@ -11,7 +11,13 @@ * Tests the bike shed text on no results page, and text on the search page. */ class SearchPageTextTest extends SearchTestBase { - protected $searching_user; + + /** + * A search-enabled user. + * + * @var object|false + */ + protected $searchUser; public static function getInfo() { return array( @@ -25,14 +31,14 @@ function setUp() { parent::setUp(); // Create user. - $this->searching_user = $this->drupalCreateUser(array('search content', 'access user profiles')); + $this->searchUser = $this->drupalCreateUser(array('search content', 'access user profiles')); } /** * Tests the failed search text, and various other text on the search page. */ function testSearchText() { - $this->drupalLogin($this->searching_user); + $this->drupalLogin($this->searchUser); $this->drupalGet('search/node'); $this->assertText(t('Enter your keywords')); $this->assertText(t('Search')); @@ -46,7 +52,7 @@ function testSearchText() { $this->assertText(t('Search')); $this->assertTitle($title, 'Search page title is correct'); - $edit['keys'] = $this->searching_user->name; + $edit['keys'] = $this->searchUser->name; $this->drupalPost('search/user', $edit, t('Search')); $this->assertText(t('Search')); $this->assertTitle($title, 'Search page title is correct'); diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php index 9efc6ce..4e02a65 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php @@ -29,7 +29,7 @@ function testShortcutSetAdd() { $new_set = $this->generateShortcutSet($this->randomName(10)); $sets = shortcut_sets(); $this->assertTrue(isset($sets[$new_set->set_name]), 'Successfully created a shortcut set.'); - $this->drupalGet('user/' . $this->admin_user->uid . '/shortcuts'); + $this->drupalGet('user/' . $this->adminUser->uid . '/shortcuts'); $this->assertText($new_set->title, 'Generated shortcut set was listed as a choice on the user account page.'); } @@ -41,9 +41,9 @@ function testShortcutSetSwitchOwn() { // Attempt to switch the default shortcut set to the newly created shortcut // set. - $this->drupalPost('user/' . $this->admin_user->uid . '/shortcuts', array('set' => $new_set->set_name), t('Change set')); + $this->drupalPost('user/' . $this->adminUser->uid . '/shortcuts', array('set' => $new_set->set_name), 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->set_name == $current_set->set_name, 'Successfully switched own shortcut set.'); } @@ -53,8 +53,8 @@ function testShortcutSetSwitchOwn() { function testShortcutSetAssign() { $new_set = $this->generateShortcutSet($this->randomName(10)); - 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->set_name == $current_set->set_name, "Successfully switched another user's shortcut set."); } @@ -66,8 +66,8 @@ function testShortcutSetSwitchCreate() { 'set' => 'new', 'new' => $this->randomName(10), ); - $this->drupalPost('user/' . $this->admin_user->uid . '/shortcuts', $edit, t('Change set')); - $current_set = shortcut_current_displayed_set($this->admin_user); + $this->drupalPost('user/' . $this->adminUser->uid . '/shortcuts', $edit, t('Change set')); + $current_set = shortcut_current_displayed_set($this->adminUser); $this->assertNotEqual($current_set->set_name, $this->set->set_name, 'A shortcut set can be switched to at the same time as it is created.'); $this->assertEqual($current_set->title, $edit['new'], 'The new set is correctly assigned to the user.'); } @@ -77,9 +77,9 @@ function testShortcutSetSwitchCreate() { */ function testShortcutSetSwitchNoSetName() { $edit = array('set' => 'new'); - $this->drupalPost('user/' . $this->admin_user->uid . '/shortcuts', $edit, t('Change set')); + $this->drupalPost('user/' . $this->adminUser->uid . '/shortcuts', $edit, t('Change set')); $this->assertText(t('The new set name is required.')); - $current_set = shortcut_current_displayed_set($this->admin_user); + $current_set = shortcut_current_displayed_set($this->adminUser); $this->assertEqual($current_set->set_name, $this->set->set_name, 'Attempting to switch to a new shortcut set without providing a set name does not succeed.'); } @@ -128,10 +128,10 @@ function testShortcutSetRenameAlreadyExists() { function testShortcutSetUnassign() { $new_set = $this->generateShortcutSet($this->randomName(10)); - 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->set_name == $default_set->set_name, "Successfully unassigned another user's shortcut set."); } @@ -162,7 +162,7 @@ function testShortcutSetCreateWithSetName() { $new_set = $this->generateShortcutSet($random_name, TRUE, $random_name); $sets = shortcut_sets(); $this->assertTrue(isset($sets[$random_name]), 'Successfully created a shortcut set with a defined set name.'); - $this->drupalGet('user/' . $this->admin_user->uid . '/shortcuts'); + $this->drupalGet('user/' . $this->adminUser->uid . '/shortcuts'); $this->assertText($new_set->title, 'Generated shortcut set was listed as a choice on the user account page.'); } } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php index 8c94435..899e82c 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php @@ -24,16 +24,22 @@ /** * User with permission to administer shortcuts. + * + * @var object|false */ - protected $admin_user; + protected $adminUser; /** * User with permission to use shortcuts, but not administer them. + * + * @var object|false */ - protected $shortcut_user; + protected $shortcutUser; /** * Generic node used for testing. + * + * @var object */ protected $node; @@ -66,16 +72,23 @@ 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')); - $this->shortcut_user = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets')); + $this->adminUser = $this->drupalCreateUser(array( + 'access content overview', + 'access toolbar', + 'administer shortcuts', + 'create article content', + 'create page content', + 'view the administration theme', + )); + $this->shortcutUser = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets')); // 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 = shortcut_set_load(SHORTCUT_DEFAULT_SET_NAME); - shortcut_set_assign_user($this->set, $this->admin_user); + shortcut_set_assign_user($this->set, $this->adminUser); } /** diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/InstallationProfileModuleTestsTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/InstallationProfileModuleTestsTest.php index 5af5c0d..0157f5d 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/InstallationProfileModuleTestsTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/InstallationProfileModuleTestsTest.php @@ -22,6 +22,13 @@ class InstallationProfileModuleTestsTest extends WebTestBase { public static $modules = array('simpletest'); /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** * Use the Testing profile. * * The Testing profile contains drupal_system_listing_compatible_test.test, @@ -46,8 +53,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer unit tests')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer unit tests')); + $this->drupalLogin($this->adminUser); } /** diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/OtherInstallationProfileModuleTestsTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/OtherInstallationProfileModuleTestsTest.php index 7f01be2..ca3a219 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/OtherInstallationProfileModuleTestsTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/OtherInstallationProfileModuleTestsTest.php @@ -34,6 +34,13 @@ class OtherInstallationProfileModuleTestsTest extends WebTestBase { */ protected $profile = 'minimal'; + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + public static function getInfo() { return array( 'name' => 'Other Installation profiles', @@ -45,8 +52,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer unit tests')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer unit tests')); + $this->drupalLogin($this->adminUser); } /** diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php index 6824e34..a2923e4 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php @@ -24,18 +24,17 @@ class StatisticsAdminTest extends WebTestBase { /** * A user that has permission to administer and access statistics. * - * @var object|FALSE - * - * A fully loaded user object, or FALSE if user creation failed. + * @var object|false + * A fully loaded user object, or FALSE if user creation failed. */ - protected $privileged_user; + protected $privilegedUser; /** * A page node for which to check access statistics. * * @var object */ - protected $test_node; + protected $testNode; public static function getInfo() { return array( @@ -52,9 +51,14 @@ function setUp() { if ($this->profile != 'standard') { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); } - $this->privileged_user = $this->drupalCreateUser(array('access statistics', 'administer statistics', 'view post access counter', 'create page content')); - $this->drupalLogin($this->privileged_user); - $this->test_node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->privileged_user->uid)); + $this->privilegedUser = $this->drupalCreateUser(array( + 'access statistics', + 'administer statistics', + 'create page content', + 'view post access counter', + )); + $this->drupalLogin($this->privilegedUser); + $this->testNode = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->privilegedUser->uid)); } /** @@ -77,9 +81,9 @@ function testStatisticsSettings() { $this->assertTrue($config->get('count_content_views'), 'Count content view log is enabled.'); // Hit the node. - $this->drupalGet('node/' . $this->test_node->nid); + $this->drupalGet('node/' . $this->testNode->nid); // Manually calling statistics.php, simulating ajax behavior. - $nid = $this->test_node->nid; + $nid = $this->testNode->nid; $post = http_build_query(array('nid' => $nid)); $headers = array('Content-Type' => 'application/x-www-form-urlencoded'); global $base_url; @@ -91,11 +95,11 @@ function testStatisticsSettings() { // Hit the node again (the counter is incremented after the hit, so // "1 view" will actually be shown when the node is hit the second time). - $this->drupalGet('node/' . $this->test_node->nid); + $this->drupalGet('node/' . $this->testNode->nid); drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000)); $this->assertText('1 view', 'Node is viewed once.'); - $this->drupalGet('node/' . $this->test_node->nid); + $this->drupalGet('node/' . $this->testNode->nid); drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000)); $this->assertText('2 views', 'Node is viewed 2 times.'); } @@ -106,9 +110,9 @@ function testStatisticsSettings() { function testDeleteNode() { config('statistics.settings')->set('count_content_views', 1)->save(); - $this->drupalGet('node/' . $this->test_node->nid); + $this->drupalGet('node/' . $this->testNode->nid); // Manually calling statistics.php, simulating ajax behavior. - $nid = $this->test_node->nid; + $nid = $this->testNode->nid; $post = http_build_query(array('nid' => $nid)); $headers = array('Content-Type' => 'application/x-www-form-urlencoded'); global $base_url; @@ -117,16 +121,16 @@ function testDeleteNode() { $result = db_select('node_counter', 'n') ->fields('n', array('nid')) - ->condition('n.nid', $this->test_node->nid) + ->condition('n.nid', $this->testNode->nid) ->execute() ->fetchAssoc(); - $this->assertEqual($result['nid'], $this->test_node->nid, 'Verifying that the node counter is incremented.'); + $this->assertEqual($result['nid'], $this->testNode->nid, 'Verifying that the node counter is incremented.'); - node_delete($this->test_node->nid); + node_delete($this->testNode->nid); $result = db_select('node_counter', 'n') ->fields('n', array('nid')) - ->condition('n.nid', $this->test_node->nid) + ->condition('n.nid', $this->testNode->nid) ->execute() ->fetchAssoc(); $this->assertFalse($result, 'Verifying that the node counter is deleted.'); @@ -139,10 +143,10 @@ function testDeleteUser() { config('statistics.settings')->set('access_log.enabled', 1)->save(); variable_set('user_cancel_method', 'user_cancel_delete'); - $this->drupalLogout($this->privileged_user); + $this->drupalLogout($this->privilegedUser); $account = $this->drupalCreateUser(array('access content', 'cancel account')); $this->drupalLogin($account); - $this->drupalGet('node/' . $this->test_node->nid); + $this->drupalGet('node/' . $this->testNode->nid); $account = user_load($account->uid, TRUE); @@ -174,20 +178,20 @@ function testExpiredLogs() { ->save(); variable_set('statistics_day_timestamp', 8640000); - $this->drupalGet('node/' . $this->test_node->nid); + $this->drupalGet('node/' . $this->testNode->nid); // Manually calling statistics.php, simulating ajax behavior. - $nid = $this->test_node->nid; + $nid = $this->testNode->nid; $post = http_build_query(array('nid' => $nid)); $headers = array('Content-Type' => 'application/x-www-form-urlencoded'); global $base_url; $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php'; drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000)); - $this->drupalGet('node/' . $this->test_node->nid); + $this->drupalGet('node/' . $this->testNode->nid); drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000)); $this->assertText('1 view', 'Node is viewed once.'); $this->drupalGet('admin/reports/pages'); - $this->assertText('node/' . $this->test_node->nid, 'Hit URL found.'); + $this->assertText('node/' . $this->testNode->nid, 'Hit URL found.'); // statistics_cron() will subtract // statistics.settings:accesslog.max_lifetime config from REQUEST_TIME in @@ -197,11 +201,11 @@ function testExpiredLogs() { $this->cronRun(); $this->drupalGet('admin/reports/pages'); - $this->assertNoText('node/' . $this->test_node->nid, 'No hit URL found.'); + $this->assertNoText('node/' . $this->testNode->nid, 'No hit URL found.'); $result = db_select('node_counter', 'nc') ->fields('nc', array('daycount')) - ->condition('nid', $this->test_node->nid, '=') + ->condition('nid', $this->testNode->nid, '=') ->execute() ->fetchField(); $this->assertFalse($result, 'Daycounter is zero.'); diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsBlockVisitorsTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsBlockVisitorsTest.php index 4657d10..952468b 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsBlockVisitorsTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsBlockVisitorsTest.php @@ -28,7 +28,7 @@ function testIPAddressBlocking() { // Verify the IP address from accesslog appears on the top visitors page // and that a 'ban IP address' link is displayed. - $this->drupalLogin($this->blocking_user); + $this->drupalLogin($this->adminUser); $this->drupalGet('admin/reports/visitors'); $this->assertText($test_ip_address, 'IP address found.'); $this->assertText(t('ban IP address'), 'Ban IP link displayed'); diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php index 7a6a79a..4444785 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php @@ -25,6 +25,14 @@ class StatisticsLoggingTest extends WebTestBase { */ public static $modules = array('statistics', 'block'); + /** + * A user that has permission to create and access content. + * + * @var object|false + * A fully loaded user object, or FALSE if user creation failed. + */ + protected $webUser; + public static function getInfo() { return array( 'name' => 'Statistics logging tests', @@ -41,10 +49,10 @@ function setUp() { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); } - $this->auth_user = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content')); + $this->webUser = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content')); // Ensure we have a node page to access. - $this->node = $this->drupalCreateNode(array('title' => $this->randomName(255), 'uid' => $this->auth_user->uid)); + $this->node = $this->drupalCreateNode(array('title' => $this->randomName(255), 'uid' => $this->webUser->uid)); // Enable page caching. $config = config('system.performance'); @@ -100,7 +108,7 @@ function testLogging() { $this->assertIdentical($node_counter['totalcount'], '2'); // Test logging from authenticated users - $this->drupalLogin($this->auth_user); + $this->drupalLogin($this->webUser); $this->drupalGet($path); // Manually calling statistics.php, simulating ajax behavior. drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000)); diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php index 80e6c38..31993cb 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php @@ -71,7 +71,7 @@ function testAccessLogging() { */ function testPopularContentBlock() { // Visit a node to have something show up in the block. - $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->blocking_user->uid)); + $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->adminUser->uid)); $this->drupalGet('node/' . $node->nid); // Manually calling statistics.php, simulating ajax behavior. $nid = $node->nid; diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTestBase.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTestBase.php index 2ed8b6f..87c1145 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTestBase.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTestBase.php @@ -21,6 +21,13 @@ */ public static $modules = array('node', 'block', 'ban', 'statistics'); + /** + * An administrative user. + * + * @var object|false + */ + protected $adminUser; + function setUp() { parent::setUp(); @@ -30,7 +37,7 @@ function setUp() { } // Create user. - $this->blocking_user = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser(array( 'access administration pages', 'access site reports', 'access statistics', @@ -39,7 +46,7 @@ function setUp() { 'administer statistics', 'administer users', )); - $this->drupalLogin($this->blocking_user); + $this->drupalLogin($this->adminUser); // Enable access logging. config('statistics.settings') diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/FormValuesTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/FormValuesTest.php index 7950e59..c67b141 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Ajax/FormValuesTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/FormValuesTest.php @@ -8,9 +8,17 @@ namespace Drupal\system\Tests\Ajax; /** - * Test that $form_state['values'] is properly delivered to $ajax['callback']. + * Tests that $form_state['values'] is properly delivered to $ajax['callback']. */ class FormValuesTest extends AjaxTestBase { + + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + public static function getInfo() { return array( 'name' => 'AJAX command form values', @@ -22,12 +30,12 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->web_user = $this->drupalCreateUser(array('access content')); - $this->drupalLogin($this->web_user); + $this->webUser = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($this->webUser); } /** - * Create a simple form, then POST to system/ajax to change to it. + * Creates a simple form, then POST to system/ajax to change to it. */ function testSimpleAjaxFormValue() { // Verify form values of a select element. diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php index cffa6b7..f3fcec8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php @@ -21,6 +21,13 @@ class MultiFormTest extends AjaxTestBase { protected $profile = 'standard'; + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + public static function getInfo() { return array( 'name' => 'AJAX multi form', @@ -48,12 +55,12 @@ function setUp() { field_create_instance($instance); // Login a user who can create 'page' nodes. - $this->web_user = $this->drupalCreateUser(array('create page content')); - $this->drupalLogin($this->web_user); + $this->webUser = $this->drupalCreateUser(array('create page content')); + $this->drupalLogin($this->webUser); } /** - * Test that a page with the 'page_node_form' included twice works correctly. + * Tests that a page with the 'page_node_form' included twice works correctly. */ function testMultiForm() { // HTML IDs for elements within the field are potentially modified with diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php index b61987e..06f6562 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -48,12 +48,12 @@ function setUp() { } /** - * Test admin-defined formats in format_date(). + * Tests admin-defined formats in format_date(). */ function testAdminDefinedFormatDate() { // Create an admin user. - $this->admin_user = $this->drupalCreateUser(array('administer site configuration')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer site configuration')); + $this->drupalLogin($admin_user); // Add new date format. $admin_date_format = 'j M y'; diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index fa443f6..26db564 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -25,6 +25,17 @@ class EntityFieldTest extends WebTestBase { */ public static $modules = array('entity_test'); + protected $entityName; + + /** + * An entity user. + * + * @var object|false + */ + protected $entityUser; + + protected $entityFieldText; + public static function getInfo() { return array( 'name' => 'Entity Field API', @@ -39,18 +50,18 @@ public static function getInfo() { * @return \Drupal\Core\Entity\EntityInterface */ protected function createTestEntity() { - $this->entity_name = $this->randomName(); - $this->entity_user = $this->drupalCreateUser(); - $this->entity_field_text = $this->randomName(); + $this->entityName = $this->randomName(); + $this->entityUser = $this->drupalCreateUser(); + $this->entityFieldText = $this->randomName(); // Pass in the value of the name field when creating. With the user // field we test setting a field after creation. $entity = entity_create('entity_test', array()); - $entity->user_id->value = $this->entity_user->uid; - $entity->name->value = $this->entity_name; + $entity->user_id->value = $this->entityUser->uid; + $entity->name->value = $this->entityName; // Set a value for the test field. - $entity->field_test_text->value = $this->entity_field_text; + $entity->field_test_text->value = $this->entityFieldText; return $entity; } @@ -65,9 +76,9 @@ public function testReadWrite() { $this->assertTrue($entity->name instanceof FieldInterface, 'Field implements interface'); $this->assertTrue($entity->name[0] instanceof FieldItemInterface, 'Field item implements interface'); - $this->assertEqual($this->entity_name, $entity->name->value, 'Name value can be read.'); - $this->assertEqual($this->entity_name, $entity->name[0]->value, 'Name value can be read through list access.'); - $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $this->entity_name)), 'Plain field value returned.'); + $this->assertEqual($this->entityName, $entity->name->value, 'Name value can be read.'); + $this->assertEqual($this->entityName, $entity->name[0]->value, 'Name value can be read through list access.'); + $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $this->entityName)), 'Plain field value returned.'); // Change the name. $new_name = $this->randomName(); @@ -83,8 +94,8 @@ public function testReadWrite() { $this->assertTrue($entity->user_id instanceof FieldInterface, 'Field implements interface'); $this->assertTrue($entity->user_id[0] instanceof FieldItemInterface, 'Field item implements interface'); - $this->assertEqual($this->entity_user->uid, $entity->user_id->value, 'User id can be read.'); - $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name, 'User name can be read.'); + $this->assertEqual($this->entityUser->uid, $entity->user_id->value, 'User id can be read.'); + $this->assertEqual($this->entityUser->name, $entity->user_id->entity->name, 'User name can be read.'); // Change the assigned user by entity. $new_user = $this->drupalCreateUser(); @@ -152,28 +163,28 @@ public function testReadWrite() { $this->assertEqual(language_default(), $entity->langcode->language, 'Language object can be read.'); // Access the text field and test updating. - $this->assertEqual($entity->field_test_text->value, $this->entity_field_text, 'Text field can be read.'); + $this->assertEqual($entity->field_test_text->value, $this->entityFieldText, 'Text field can be read.'); $new_text = $this->randomName(); $entity->field_test_text->value = $new_text; $this->assertEqual($entity->field_test_text->value, $new_text, 'Updated text field can be read.'); // Test creating the entity by passing in plain values. - $this->entity_name = $this->randomName(); - $name_item[0]['value'] = $this->entity_name; - $this->entity_user = $this->drupalCreateUser(); - $user_item[0]['value'] = $this->entity_user->uid; - $this->entity_field_text = $this->randomName(); - $text_item[0]['value'] = $this->entity_field_text; + $this->entityName = $this->randomName(); + $name_item[0]['value'] = $this->entityName; + $this->entityUser = $this->drupalCreateUser(); + $user_item[0]['value'] = $this->entityUser->uid; + $this->entityFieldText = $this->randomName(); + $text_item[0]['value'] = $this->entityFieldText; $entity = entity_create('entity_test', array( 'name' => $name_item, 'user_id' => $user_item, 'field_test_text' => $text_item, )); - $this->assertEqual($this->entity_name, $entity->name->value, 'Name value can be read.'); - $this->assertEqual($this->entity_user->uid, $entity->user_id->value, 'User id can be read.'); - $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name, 'User name can be read.'); - $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, 'Text field can be read.'); + $this->assertEqual($this->entityName, $entity->name->value, 'Name value can be read.'); + $this->assertEqual($this->entityUser->uid, $entity->user_id->value, 'User id can be read.'); + $this->assertEqual($this->entityUser->name, $entity->user_id->entity->name, 'User name can be read.'); + $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, 'Text field can be read.'); // Test copying field values. $entity2 = $this->createTestEntity(); @@ -248,9 +259,9 @@ public function testSave() { $this->assertTrue(is_string($entity->uuid->value), 'UUID value can be read.'); $this->assertEqual(LANGUAGE_NOT_SPECIFIED, $entity->langcode->value, 'Language code can be read.'); $this->assertEqual(language_load(LANGUAGE_NOT_SPECIFIED), $entity->langcode->language, 'Language object can be read.'); - $this->assertEqual($this->entity_user->uid, $entity->user_id->value, 'User id can be read.'); - $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name, 'User name can be read.'); - $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, 'Text field can be read.'); + $this->assertEqual($this->entityUser->uid, $entity->user_id->value, 'User id can be read.'); + $this->assertEqual($this->entityUser->name, $entity->user_id->entity->name, 'User name can be read.'); + $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, 'Text field can be read.'); } /** @@ -348,8 +359,8 @@ public function testDataStructureInterfaces() { $target_strings = array( $entity->uuid->value, LANGUAGE_NOT_SPECIFIED, - $this->entity_name, - $this->entity_field_text, + $this->entityName, + $this->entityFieldText, // Field format. NULL, ); diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php index 9d4c439..443b267 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php @@ -36,8 +36,8 @@ function setUp() { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - $this->web_user = $this->drupalCreateUser(array('access content')); - $this->drupalLogin($this->web_user); + $web_user = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($web_user); } /** @@ -85,8 +85,8 @@ function testPreserveFormActionAfterAJAX() { field_create_instance($instance); // Log in a user who can create 'page' nodes. - $this->web_user = $this->drupalCreateUser(array('create page content')); - $this->drupalLogin($this->web_user); + $web_user = $this->drupalCreateUser(array('create page content')); + $this->drupalLogin($web_user); // Get the form for adding a 'page' node. Submit an "add another item" Ajax // submission and verify it worked by ensuring the updated page has two text diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/StorageTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/StorageTest.php index 2b1daf9..86ba6cb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/StorageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/StorageTest.php @@ -38,8 +38,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->web_user = $this->drupalCreateUser(array('access content')); - $this->drupalLogin($this->web_user); + $web_user = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($web_user); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php index 5c0ab5f..3ec5ae4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php @@ -19,8 +19,22 @@ class BreadcrumbTest extends MenuTestBase { */ public static $modules = array('menu_test'); + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + protected $profile = 'standard'; + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + public static function getInfo() { return array( 'name' => 'Breadcrumbs', @@ -33,8 +47,8 @@ function setUp() { parent::setUp(); $perms = array_keys(module_invoke_all('permission')); - $this->admin_user = $this->drupalCreateUser($perms); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser($perms); + $this->drupalLogin($this->adminUser); // This test puts menu links in the Navigation menu and then tests for // their presence on the page, so we need to ensure that the Navigation @@ -380,50 +394,50 @@ function testBreadCrumbs() { // Verify breadcrumb on user pages (without menu link) for anonymous user. $trail = $home; $this->assertBreadcrumb('user', $trail, t('Log in')); - $this->assertBreadcrumb('user/' . $this->admin_user->uid, $trail, $this->admin_user->name); + $this->assertBreadcrumb('user/' . $this->adminUser->uid, $trail, $this->adminUser->name); // Verify breadcrumb on user pages (without menu link) for registered users. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $trail = $home; - $this->assertBreadcrumb('user', $trail, $this->admin_user->name); - $this->assertBreadcrumb('user/' . $this->admin_user->uid, $trail, $this->admin_user->name); + $this->assertBreadcrumb('user', $trail, $this->adminUser->name); + $this->assertBreadcrumb('user/' . $this->adminUser->uid, $trail, $this->adminUser->name); $trail += array( - 'user/' . $this->admin_user->uid => $this->admin_user->name, + 'user/' . $this->adminUser->uid => $this->adminUser->name, ); - $this->assertBreadcrumb('user/' . $this->admin_user->uid . '/edit', $trail, $this->admin_user->name); + $this->assertBreadcrumb('user/' . $this->adminUser->uid . '/edit', $trail, $this->adminUser->name); // Create a second user to verify breadcrumb on user pages again. - $this->web_user = $this->drupalCreateUser(array( - 'administer users', + $this->webUser = $this->drupalCreateUser(array( 'access user profiles', + 'administer users', )); - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // Verify correct breadcrumb and page title on another user's account pages // (without menu link). $trail = $home; - $this->assertBreadcrumb('user/' . $this->admin_user->uid, $trail, $this->admin_user->name); + $this->assertBreadcrumb('user/' . $this->adminUser->uid, $trail, $this->adminUser->name); $trail += array( - 'user/' . $this->admin_user->uid => $this->admin_user->name, + 'user/' . $this->adminUser->uid => $this->adminUser->name, ); - $this->assertBreadcrumb('user/' . $this->admin_user->uid . '/edit', $trail, $this->admin_user->name); + $this->assertBreadcrumb('user/' . $this->adminUser->uid . '/edit', $trail, $this->adminUser->name); // Verify correct breadcrumb and page title when viewing own user account // pages (without menu link). $trail = $home; - $this->assertBreadcrumb('user/' . $this->web_user->uid, $trail, $this->web_user->name); + $this->assertBreadcrumb('user/' . $this->webUser->uid, $trail, $this->webUser->name); $trail += array( - 'user/' . $this->web_user->uid => $this->web_user->name, + 'user/' . $this->webUser->uid => $this->webUser->name, ); $tree = array( 'user' => t('My account'), ); - $this->assertBreadcrumb('user/' . $this->web_user->uid . '/edit', $trail, $this->web_user->name, $tree); + $this->assertBreadcrumb('user/' . $this->webUser->uid . '/edit', $trail, $this->webUser->name, $tree); - // Add a Navigation menu links for 'user' and $this->admin_user. + // Add a Navigation menu links for 'user' and $this->adminUser. // Although it may be faster to manage these links via low-level API // functions, there's a lot that can go wrong in doing so. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $edit = array( 'link_title' => 'User', 'link_path' => 'user', @@ -435,8 +449,8 @@ function testBreadCrumbs() { ))->fetchAssoc(); $edit = array( - 'link_title' => $this->admin_user->name . ' link', - 'link_path' => 'user/' . $this->admin_user->uid, + 'link_title' => $this->adminUser->name . ' link', + 'link_path' => 'user/' . $this->adminUser->uid, ); $this->drupalPost("admin/structure/menu/manage/$menu/add", $edit, t('Save')); $link_admin_user = db_query('SELECT * FROM {menu_links} WHERE link_title = :title AND link_path = :href', array( @@ -454,13 +468,13 @@ function testBreadCrumbs() { $tree = array( $link_admin_user['link_path'] => $link_admin_user['link_title'], ); - $this->assertBreadcrumb('user/' . $this->admin_user->uid, $trail, $link_admin_user['link_title'], $tree); + $this->assertBreadcrumb('user/' . $this->adminUser->uid, $trail, $link_admin_user['link_title'], $tree); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $trail += array( $link_admin_user['link_path'] => $link_admin_user['link_title'], ); - $this->assertBreadcrumb('user/' . $this->admin_user->uid . '/edit', $trail, $link_admin_user['link_title'], $tree, FALSE); + $this->assertBreadcrumb('user/' . $this->adminUser->uid . '/edit', $trail, $link_admin_user['link_title'], $tree, FALSE); // Move 'user/%' below 'user' and verify again. $edit = array( @@ -480,20 +494,20 @@ function testBreadCrumbs() { $tree += array( $link_admin_user['link_path'] => $link_admin_user['link_title'], ); - $this->assertBreadcrumb('user/' . $this->admin_user->uid, $trail, $link_admin_user['link_title'], $tree); + $this->assertBreadcrumb('user/' . $this->adminUser->uid, $trail, $link_admin_user['link_title'], $tree); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $trail += array( $link_admin_user['link_path'] => $link_admin_user['link_title'], ); - $this->assertBreadcrumb('user/' . $this->admin_user->uid . '/edit', $trail, $link_admin_user['link_title'], $tree, FALSE); + $this->assertBreadcrumb('user/' . $this->adminUser->uid . '/edit', $trail, $link_admin_user['link_title'], $tree, FALSE); // Create an only slightly privileged user being able to access site reports // but not administration pages. - $this->web_user = $this->drupalCreateUser(array( + $this->webUser = $this->drupalCreateUser(array( 'access site reports', )); - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // Verify that we can access recent log entries, there is a corresponding // page title, and that the breadcrumb is empty (because the user is not diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php index eac8546..eafbe69 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php @@ -19,6 +19,13 @@ class TrailTest extends MenuTestBase { */ public static $modules = array('block', 'menu_test'); + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + public static function getInfo() { return array( 'name' => 'Active trail', @@ -30,8 +37,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'access administration pages')); + $this->drupalLogin($this->adminUser); // This test puts menu links in the Navigation menu and then tests for // their presence on the page, so we need to ensure that the Navigation diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php index c53d225..b203f88 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php @@ -11,6 +11,7 @@ * Tests module dependency functionality. */ class DependencyTest extends ModuleTestBase { + public static function getInfo() { return array( 'name' => 'Module dependencies', diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php index f691e7a..a5cad4c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php @@ -11,6 +11,7 @@ * Tests functionality for enabling and disabling modules. */ class EnableDisableTest extends ModuleTestBase { + public static function getInfo() { return array( 'name' => 'Enable/disable modules', diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/HookRequirementsTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/HookRequirementsTest.php index 1572f5d..3c962ba 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/HookRequirementsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/HookRequirementsTest.php @@ -11,6 +11,7 @@ * Tests failure of hook_requirements('install'). */ class HookRequirementsTest extends ModuleTestBase { + public static function getInfo() { return array( 'name' => 'Requirements hook failure', @@ -20,7 +21,7 @@ public static function getInfo() { } /** - * Assert that a module cannot be installed if it fails hook_requirements(). + * Asserts that a module cannot be installed if it fails hook_requirements(). */ function testHookRequirementsFailure() { $this->assertModules(array('requirements1_test'), FALSE); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php index 75070a9..c9ad0ce 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php @@ -13,6 +13,7 @@ * Unit tests for the module API. */ class ModuleApiTest extends WebTestBase { + // Requires Standard profile modules/dependencies. protected $profile = 'standard'; @@ -87,7 +88,7 @@ protected function assertModuleList(Array $expected_values, $condition) { } /** - * Test module_implements() caching. + * Tests module_implements() caching. */ function testModuleImplements() { // Clear the cache. @@ -97,8 +98,8 @@ function testModuleImplements() { $this->assertTrue(cache('bootstrap')->get('module_implements'), 'The module implements cache is populated after requesting a page.'); // Test again with an authenticated user. - $this->user = $this->drupalCreateUser(); - $this->drupalLogin($this->user); + $user = $this->drupalCreateUser(); + $this->drupalLogin($user); cache('bootstrap')->delete('module_implements'); $this->drupalGet(''); $this->assertTrue(cache('bootstrap')->get('module_implements'), 'The module implements cache is populated after requesting a page.'); @@ -116,7 +117,7 @@ function testModuleImplements() { } /** - * Test that module_invoke() can load a hook defined in hook_hook_info(). + * Tests that module_invoke() can load a hook defined in hook_hook_info(). */ function testModuleInvoke() { module_enable(array('module_test'), FALSE); @@ -126,7 +127,7 @@ function testModuleInvoke() { } /** - * Test that module_invoke_all() can load a hook defined in hook_hook_info(). + * Tests that module_invoke_all() can load a hook defined in hook_hook_info(). */ function testModuleInvokeAll() { module_enable(array('module_test'), FALSE); @@ -136,7 +137,7 @@ function testModuleInvokeAll() { } /** - * Test that a menu item load function can invoke hooks defined in hook_hook_info(). + * Tests that a menu item load function can invoke hooks defined in hook_hook_info(). * * We test this separately from testModuleInvokeAll(), because menu item load * functions execute early in the request handling. @@ -149,7 +150,7 @@ function testModuleInvokeAllDuringLoadFunction() { } /** - * Test dependency resolution. + * Tests dependency resolution. */ function testDependencyResolution() { // Enable the test module, and make sure that other modules we are testing diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php index fcfc39f..ad07379 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php @@ -23,17 +23,22 @@ */ public static $modules = array('system_test'); - protected $admin_user; + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer modules')); + $this->drupalLogin($this->adminUser); } /** - * Assert there are tables that begin with the specified base table name. + * Asserts there are tables that begin with the specified base table name. * * @param $base_table * Beginning of table name to look for. @@ -51,7 +56,7 @@ function assertTableCount($base_table, $count = TRUE) { } /** - * Assert that all tables defined in a module's hook_schema() exist. + * Asserts that all tables defined in a module's hook_schema() exist. * * @param $module * The name of the module. @@ -68,7 +73,7 @@ function assertModuleTablesExist($module) { } /** - * Assert that none of the tables defined in a module's hook_schema() exist. + * Asserts that none of the tables defined in a module's hook_schema() exist. * * @param $module * The name of the module. @@ -131,7 +136,7 @@ function assertNoModuleConfig($module) { } /** - * Assert the list of modules are enabled or disabled. + * Asserts the list of modules are enabled or disabled. * * @param $modules * Module list to check. @@ -152,7 +157,8 @@ function assertModules(array $modules, $enabled) { } /** - * Verify a log entry was entered for a module's status change. + * Verifies a log entry was entered for a module's status change. + * * Called in the same way of the expected original watchdog() execution. * * @param $type diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/RequiredTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/RequiredTest.php index 1de4535..d1a7066 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/RequiredTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/RequiredTest.php @@ -11,6 +11,7 @@ * Test required modules functionality. */ class RequiredTest extends ModuleTestBase { + public static function getInfo() { return array( 'name' => 'Required modules', @@ -20,7 +21,7 @@ public static function getInfo() { } /** - * Assert that core required modules cannot be disabled. + * Asserts that core required modules cannot be disabled. */ function testDisableRequired() { $module_info = system_get_info('module'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php index e328712..53c4a83 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php @@ -28,7 +28,7 @@ public static function getInfo() { } /** - * Test version dependencies. + * Tests version dependencies. */ function testModuleVersions() { $dependencies = array( diff --git a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php index 0804339..9403d28 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php @@ -40,10 +40,10 @@ function setUp() { watchdog('pager_test', $this->randomString(), array(), WATCHDOG_DEBUG); } - $this->admin_user = $this->drupalCreateUser(array( + $admin_user = $this->drupalCreateUser(array( 'access site reports', )); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($admin_user); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php b/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php index 135f69a..f5cdd73 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php @@ -21,7 +21,12 @@ class AccessDeniedTest extends WebTestBase { */ public static $modules = array('block'); - protected $admin_user; + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; public static function getInfo() { return array( @@ -35,7 +40,7 @@ function setUp() { parent::setUp(); // Create an administrative user. - $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer site configuration', 'administer blocks')); + $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer site configuration', 'administer blocks')); user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access user profiles')); user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access user profiles')); @@ -47,9 +52,9 @@ function testAccessDenied() { $this->assertResponse(403); // Use a custom 403 page. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $edit = array( - 'site_403' => 'user/' . $this->admin_user->uid, + 'site_403' => 'user/' . $this->adminUser->uid, ); $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration')); @@ -62,11 +67,11 @@ function testAccessDenied() { // Logout and check that the user login block is shown on custom 403 pages. $this->drupalLogout(); $this->drupalGet('admin'); - $this->assertText($this->admin_user->name, t('Found the custom 403 page')); + $this->assertText($this->adminUser->name, t('Found the custom 403 page')); $this->assertText(t('User login'), t('Blocks are shown on the custom 403 page')); // Log back in and remove the custom 403 page. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $edit = array( 'site_403' => '', ); @@ -80,15 +85,15 @@ function testAccessDenied() { $this->assertText(t('User login'), t('Blocks are shown on the default 403 page')); // Log back in, set the custom 403 page to /user and remove the block - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); config('system.site')->set('page.403', 'user')->save(); $this->drupalPost('admin/structure/block', array('blocks[user_login][region]' => '-1'), t('Save blocks')); // Check that we can log in from the 403 page. $this->drupalLogout(); $edit = array( - 'name' => $this->admin_user->name, - 'pass' => $this->admin_user->pass_raw, + 'name' => $this->adminUser->name, + 'pass' => $this->adminUser->pass_raw, ); $this->drupalPost('admin/config/system/site-information', $edit, t('Log in')); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/AdminTest.php b/core/modules/system/lib/Drupal/system/Tests/System/AdminTest.php index d87eb44..fd4fcfe 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/AdminTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/AdminTest.php @@ -21,6 +21,20 @@ class AdminTest extends WebTestBase { */ public static $modules = array('locale'); + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + public static function getInfo() { return array( 'name' => 'Administrative pages', @@ -36,12 +50,12 @@ function setUp() { // Create an administrator with all permissions, as well as a regular user // who can only access administration pages and perform some Locale module // administrative tasks, but not all of them. - $this->admin_user = $this->drupalCreateUser(array_keys(module_invoke_all('permission'))); - $this->web_user = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser(array_keys(module_invoke_all('permission'))); + $this->webUser = $this->drupalCreateUser(array( 'access administration pages', 'translate interface', )); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); } /** @@ -76,7 +90,7 @@ function testAdminPages() { // For the administrator, verify that there are links to Locale's primary // configuration pages, but no links to individual sub-configuration // pages. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet($page); $this->assertLinkByHref('admin/config'); $this->assertLinkByHref('admin/config/regional/settings'); @@ -93,7 +107,7 @@ function testAdminPages() { // For a less privileged user, verify that there are no links to Locale's // primary configuration pages, but a link to the translate page exists. - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); $this->drupalGet($page); $this->assertLinkByHref('admin/config'); $this->assertNoLinkByHref('admin/config/regional/settings'); @@ -111,7 +125,7 @@ function testAdminPages() { } /** - * Test compact mode. + * Tests compact mode. */ function testCompactMode() { $this->drupalGet('admin/compact/on'); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php index 6494a4a..0bd1bba 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php @@ -34,8 +34,8 @@ function setUp() { parent::setUp(); // Create admin user and log in admin user. - $this->admin_user = $this->drupalCreateUser(array('administer site configuration')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer site configuration')); + $this->drupalLogin($admin_user); } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php b/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php index d620cce..108f4ba 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php @@ -21,6 +21,8 @@ class FrontPageTest extends WebTestBase { */ public static $modules = array('node', 'system_test'); + protected $nodePath; + public static function getInfo() { return array( 'name' => 'Front page', @@ -33,9 +35,9 @@ function setUp() { parent::setUp(); // Create admin user, log in admin user, and create one node. - $this->admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration')); - $this->drupalLogin($this->admin_user); - $this->node_path = "node/" . $this->drupalCreateNode(array('promote' => 1))->nid; + $admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration')); + $this->drupalLogin($admin_user); + $this->nodePath = "node/" . $this->drupalCreateNode(array('promote' => 1))->nid; // Configure 'node' as front page. config('system.site')->set('page.front', 'node')->save(); @@ -44,14 +46,14 @@ function setUp() { } /** - * Test front page functionality. + * Tests front page functionality. */ function testDrupalIsFrontPage() { $this->drupalGet(''); $this->assertText(t('On front page.'), t('Path is the front page.')); $this->drupalGet('node'); $this->assertText(t('On front page.'), t('Path is the front page.')); - $this->drupalGet($this->node_path); + $this->drupalGet($this->nodePath); $this->assertNoText(t('On front page.'), t('Path is not the front page.')); // Change the front page to an invalid path. @@ -60,7 +62,7 @@ function testDrupalIsFrontPage() { $this->assertText(t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $edit['site_frontpage']))); // Change the front page to a valid path. - $edit['site_frontpage'] = $this->node_path; + $edit['site_frontpage'] = $this->nodePath; $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), t('The front page path has been saved.')); @@ -68,7 +70,7 @@ function testDrupalIsFrontPage() { $this->assertText(t('On front page.'), t('Path is the front page.')); $this->drupalGet('node'); $this->assertNoText(t('On front page.'), t('Path is not the front page.')); - $this->drupalGet($this->node_path); + $this->drupalGet($this->nodePath); $this->assertText(t('On front page.'), t('Path is the front page.')); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php b/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php index e1fd6f6..ee12fe8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php @@ -21,8 +21,19 @@ class MainContentFallbackTest extends WebTestBase { */ public static $modules = array('block', 'system_test'); - protected $admin_user; - protected $web_user; + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; public static function getInfo() { return array( @@ -36,19 +47,19 @@ function setUp() { parent::setUp(); // Create and login admin user. - $this->admin_user = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser(array( 'access administration pages', - 'administer site configuration', 'administer modules', + 'administer site configuration', )); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); // Create a web user. - $this->web_user = $this->drupalCreateUser(array('access user profiles')); + $this->webUser = $this->drupalCreateUser(array('access user profiles')); } /** - * Test availability of main content. + * Tests availability of main content. */ function testMainContentFallback() { $edit = array(); @@ -80,12 +91,12 @@ function testMainContentFallback() { $this->assertNoText(t('Content to test main content fallback'), t('Main content not duplicated.')); // Request a user* page and see if it is displayed. - $this->drupalLogin($this->web_user); - $this->drupalGet('user/' . $this->web_user->uid . '/edit'); + $this->drupalLogin($this->webUser); + $this->drupalGet('user/' . $this->webUser->uid . '/edit'); $this->assertField('mail', t('User interface still available.')); // Enable the block module again. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $edit = array(); $edit['modules[Core][block][enable]'] = 'block'; $this->drupalPost('admin/modules', $edit, t('Save configuration')); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php index c8bee66..06815a0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php @@ -10,7 +10,13 @@ use Drupal\simpletest\WebTestBase; class PageNotFoundTest extends WebTestBase { - protected $admin_user; + + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; public static function getInfo() { return array( @@ -24,24 +30,24 @@ function setUp() { parent::setUp(); // Create an administrative user. - $this->admin_user = $this->drupalCreateUser(array('administer site configuration')); + $this->adminUser = $this->drupalCreateUser(array('administer site configuration')); user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access user profiles')); user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access user profiles')); } function testPageNotFound() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet($this->randomName(10)); $this->assertText(t('Page not found'), t('Found the default 404 page')); // Use a custom 404 page. $edit = array( - 'site_404' => 'user/' . $this->admin_user->uid, + 'site_404' => 'user/' . $this->adminUser->uid, ); $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration')); $this->drupalGet($this->randomName(10)); - $this->assertText($this->admin_user->name, t('Found the custom 404 page')); + $this->assertText($this->adminUser->name, t('Found the custom 404 page')); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php index c0d00c3..2a53b97 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php @@ -18,12 +18,8 @@ class PageTitleFilteringTest extends WebTestBase { */ public static $modules = array('node'); - protected $content_user; - protected $saved_title; + protected $savedTitle; - /** - * Implement getInfo(). - */ public static function getInfo() { return array( 'name' => 'HTML in page titles', @@ -32,25 +28,24 @@ public static function getInfo() { ); } - /** - * Implement setUp(). - */ function setUp() { parent::setUp(); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - $this->content_user = $this->drupalCreateUser(array('create page content', 'access content', 'administer themes', 'administer site configuration')); - $this->drupalLogin($this->content_user); - $this->saved_title = drupal_get_title(); + $content_user = $this->drupalCreateUser(array( + 'access content', + 'administer site configuration', + 'administer themes', + 'create page content', + )); + $this->drupalLogin($content_user); + $this->savedTitle = drupal_get_title(); } - /** - * Reset page title. - */ function tearDown() { // Restore the page title. - drupal_set_title($this->saved_title, PASS_THROUGH); + drupal_set_title($this->savedTitle, PASS_THROUGH); parent::tearDown(); } @@ -82,8 +77,9 @@ function testTitleTags() { $this->drupalGet("node/" . $node->nid); $this->assertText(check_plain($edit["title"]), 'Check to make sure tags in the node title are converted.'); } + /** - * Test if the title of the site is XSS proof. + * Tests if the title of the site is XSS proof. */ function testTitleXSS() { // Set some title with JavaScript and HTML chars to escape. diff --git a/core/modules/system/lib/Drupal/system/Tests/System/SiteMaintenanceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/SiteMaintenanceTest.php index 5925660..149cb4e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/SiteMaintenanceTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/SiteMaintenanceTest.php @@ -21,7 +21,19 @@ class SiteMaintenanceTest extends WebTestBase { */ public static $modules = array('node'); - protected $admin_user; + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * A web user allowed to access site in maintenance mode. + * + * @var object|false + */ + protected $webUser; public static function getInfo() { return array( @@ -38,14 +50,14 @@ function setUp() { config('system.site')->set('page.front', 'node')->save(); // Create a user allowed to access site in maintenance mode. - $this->user = $this->drupalCreateUser(array('access site in maintenance mode')); + $this->webUser = $this->drupalCreateUser(array('access site in maintenance mode')); // Create an administrative user. - $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'access site in maintenance mode')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'access site in maintenance mode')); + $this->drupalLogin($this->adminUser); } /** - * Verify site maintenance mode functionality. + * Verifies site maintenance mode functionality. */ function testSiteMaintenance() { // Turn on maintenance mode. @@ -79,15 +91,15 @@ function testSiteMaintenance() { // Log in user and verify that maintenance mode message is displayed // directly after login. $edit = array( - 'name' => $this->user->name, - 'pass' => $this->user->pass_raw, + 'name' => $this->webUser->name, + 'pass' => $this->webUser->pass_raw, ); $this->drupalPost(NULL, $edit, t('Log in')); $this->assertText($user_message); // Log in administrative user and configure a custom site offline message. $this->drupalLogout(); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet('admin/config/development/maintenance'); $this->assertNoRaw($admin_message, t('Site maintenance mode message not displayed.')); @@ -108,12 +120,12 @@ function testSiteMaintenance() { // Submit password reset form. $edit = array( - 'name' => $this->user->name, + 'name' => $this->webUser->name, ); $this->drupalPost('user/password', $edit, t('E-mail new password')); $mails = $this->drupalGetMails(); - $start = strpos($mails[0]['body'], 'user/reset/'. $this->user->uid); - $path = substr($mails[0]['body'], $start, 66 + strlen($this->user->uid)); + $start = strpos($mails[0]['body'], 'user/reset/'. $this->webUser->uid); + $path = substr($mails[0]['body'], $start, 66 + strlen($this->webUser->uid)); // Log in with temporary login link. $this->drupalPost($path, array(), t('Log in')); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/SystemAuthorizeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/SystemAuthorizeTest.php index 730886d..340883f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/SystemAuthorizeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/SystemAuthorizeTest.php @@ -35,8 +35,8 @@ function setUp() { variable_set('allow_authorize_operations', TRUE); // Create an administrator user. - $this->admin_user = $this->drupalCreateUser(array('administer software updates')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer software updates')); + $this->drupalLogin($admin_user); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php index 3d0188d..45b85b2 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php @@ -34,13 +34,19 @@ function setUp() { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer themes', 'bypass node access', 'administer blocks')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array( + 'access administration pages', + 'administer blocks', + 'administer themes', + 'bypass node access', + 'view the administration theme', + )); + $this->drupalLogin($admin_user); $this->node = $this->drupalCreateNode(); } /** - * Test the theme settings form. + * Tests the theme settings form. */ function testThemeSettings() { // Specify a filesystem path to be used for the logo. @@ -169,7 +175,7 @@ function testThemeSettings() { } /** - * Test the administration theme functionality. + * Tests the administration theme functionality. */ function testAdministrationTheme() { theme_enable(array('seven')); @@ -221,7 +227,7 @@ function testAdministrationTheme() { } /** - * Test switching the default theme. + * Tests switching the default theme. */ function testSwitchDefaultTheme() { // Enable Bartik and set it as the default theme. @@ -241,7 +247,7 @@ function testSwitchDefaultTheme() { } /** - * Test that themes can't be enabled when the base theme or engine is missing. + * Tests that themes cannot be enabled when base theme or engine is missing. */ function testInvalidTheme() { module_enable(array('theme_page_test')); diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/FastTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/FastTest.php index d28e192..b83eda8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/FastTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/FastTest.php @@ -21,6 +21,13 @@ class FastTest extends WebTestBase { */ public static $modules = array('theme_test'); + /** + * A web visitor with permission to access user profiles. + * + * @var object|false + */ + protected $webUser; + public static function getInfo() { return array( 'name' => 'Theme fast initialization', @@ -31,16 +38,16 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->account = $this->drupalCreateUser(array('access user profiles')); + $this->webUser = $this->drupalCreateUser(array('access user profiles')); } /** * Tests access to user autocompletion and verify the correct results. */ function testUserAutocomplete() { - $this->drupalLogin($this->account); - $this->drupalGet('user/autocomplete/' . $this->account->name); - $this->assertRaw($this->account->name); + $this->drupalLogin($this->webUser); + $this->drupalGet('user/autocomplete/' . $this->webUser->name); + $this->assertRaw($this->webUser->name); $this->assertNoText('registry initialized', t('The registry was not initialized')); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Update/UpdateScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Update/UpdateScriptTest.php index 1231af4..148f7e7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Update/UpdateScriptTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Update/UpdateScriptTest.php @@ -21,8 +21,14 @@ class UpdateScriptTest extends WebTestBase { */ public static $modules = array('update_script_test', 'dblog'); - private $update_url; - private $update_user; + private $updateUrl; + + /** + * A web visitor. + * + * @var object|false + */ + private $updateUser; public static function getInfo() { return array( @@ -34,8 +40,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->update_url = $GLOBALS['base_url'] . '/core/update.php'; - $this->update_user = $this->drupalCreateUser(array('administer software updates')); + $this->updateUrl = $GLOBALS['base_url'] . '/core/update.php'; + $this->updateUser = $this->drupalCreateUser(array('administer software updates')); } /** @@ -45,17 +51,17 @@ function testUpdateAccess() { // Try accessing update.php without the proper permission. $regular_user = $this->drupalCreateUser(); $this->drupalLogin($regular_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertResponse(403); // Try accessing update.php as an anonymous user. $this->drupalLogout(); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertResponse(403); // Access the update page with the proper permission. - $this->drupalLogin($this->update_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalLogin($this->updateUser); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertResponse(200); // Access the update page as user 1. @@ -65,7 +71,7 @@ function testUpdateAccess() { $user1->pass = user_hash_password(trim($user1->pass_raw)); db_query("UPDATE {users} SET pass = :pass WHERE uid = :uid", array(':pass' => $user1->pass, ':uid' => $user1->uid)); $this->drupalLogin($user1); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertResponse(200); } @@ -74,11 +80,11 @@ function testUpdateAccess() { */ function testRequirements() { $update_script_test_config = config('update_script_test.settings'); - $this->drupalLogin($this->update_user); + $this->drupalLogin($this->updateUser); // If there are no requirements warnings or errors, we expect to be able to // go through the update process uninterrupted. - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->drupalPost(NULL, array(), t('Continue')); $this->assertText(t('No pending updates.'), t('End of update process was reached.')); // Confirm that all caches were cleared. @@ -92,7 +98,7 @@ function testRequirements() { // successfully. $update_script_test_config->set('requirement_type', REQUIREMENT_WARNING)->save(); drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertText('This is a requirements warning provided by the update_script_test module.'); $this->clickLink('try again'); $this->assertNoText('This is a requirements warning provided by the update_script_test module.'); @@ -103,7 +109,7 @@ function testRequirements() { $this->assertText(t('hook_cache_flush() invoked for update_script_test.module.'), 'Caches were cleared after resolving a requirements warning and applying updates.'); // Now try again without pending updates to make sure that works too. - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertText('This is a requirements warning provided by the update_script_test module.'); $this->clickLink('try again'); $this->assertNoText('This is a requirements warning provided by the update_script_test module.'); @@ -116,7 +122,7 @@ function testRequirements() { // clicking the link to proceed (since the problem that triggered the error // has not been fixed). $update_script_test_config->set('requirement_type', REQUIREMENT_ERROR)->save(); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertText('This is a requirements error provided by the update_script_test module.'); $this->clickLink('try again'); $this->assertText('This is a requirements error provided by the update_script_test module.'); @@ -130,8 +136,8 @@ function testThemeSystem() { // unusual maintenance mode environment, we check that this rebuild did not // put any incorrect information about the themes into the database. $original_theme_data = db_query("SELECT * FROM {system} WHERE type = 'theme' ORDER BY name")->fetchAll(); - $this->drupalLogin($this->update_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalLogin($this->updateUser); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $final_theme_data = db_query("SELECT * FROM {system} WHERE type = 'theme' ORDER BY name")->fetchAll(); $this->assertEqual($original_theme_data, $final_theme_data, t('Visiting update.php does not alter the information about themes stored in the database.')); } @@ -141,8 +147,8 @@ function testThemeSystem() { */ function testNoUpdateFunctionality() { // Click through update.php with 'administer software updates' permission. - $this->drupalLogin($this->update_user); - $this->drupalPost($this->update_url, array(), t('Continue'), array('external' => TRUE)); + $this->drupalLogin($this->updateUser); + $this->drupalPost($this->updateUrl, array(), t('Continue'), array('external' => TRUE)); $this->assertText(t('No pending updates.')); $this->assertNoLink('Administration pages'); $this->clickLink('Front page'); @@ -151,7 +157,7 @@ function testNoUpdateFunctionality() { // Click through update.php with 'access administration pages' permission. $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages')); $this->drupalLogin($admin_user); - $this->drupalPost($this->update_url, array(), t('Continue'), array('external' => TRUE)); + $this->drupalPost($this->updateUrl, array(), t('Continue'), array('external' => TRUE)); $this->assertText(t('No pending updates.')); $this->clickLink('Administration pages'); $this->assertResponse(200); @@ -163,8 +169,8 @@ function testNoUpdateFunctionality() { function testSuccessfulUpdateFunctionality() { drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1); // Click through update.php with 'administer software updates' permission. - $this->drupalLogin($this->update_user); - $this->drupalPost($this->update_url, array(), t('Continue'), array('external' => TRUE)); + $this->drupalLogin($this->updateUser); + $this->drupalPost($this->updateUrl, array(), t('Continue'), array('external' => TRUE)); $this->drupalPost(NULL, array(), t('Apply pending updates')); $this->assertText('Updates were attempted.'); $this->assertLink('site'); @@ -178,7 +184,7 @@ function testSuccessfulUpdateFunctionality() { // 'access site reports' permissions. $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages', 'access site reports')); $this->drupalLogin($admin_user); - $this->drupalPost($this->update_url, array(), t('Continue'), array('external' => TRUE)); + $this->drupalPost($this->updateUrl, array(), t('Continue'), array('external' => TRUE)); $this->drupalPost(NULL, array(), t('Apply pending updates')); $this->assertText('Updates were attempted.'); $this->assertLink('logged'); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/EfqTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/EfqTest.php index 7726dbf..675d1b3 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/EfqTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/EfqTest.php @@ -13,6 +13,9 @@ * Tests the functionality of EntityFieldQuery for taxonomy entities. */ class EfqTest extends TaxonomyTestBase { + + protected $vocabulary; + public static function getInfo() { return array( 'name' => 'Taxonomy EntityFieldQuery', @@ -23,8 +26,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer taxonomy')); + $this->drupalLogin($admin_user); $this->vocabulary = $this->createVocabulary(); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php index d00f373..337e7b8 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php @@ -8,10 +8,17 @@ namespace Drupal\taxonomy\Tests; /** - * Test for legacy node bug. + * Tests for legacy node bug. */ class LegacyTest extends TaxonomyTestBase { + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + protected $profile = 'standard'; public static function getInfo() { @@ -24,12 +31,16 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'administer nodes', 'bypass node access')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array( + 'administer nodes', + 'administer taxonomy', + 'bypass node access', + )); + $this->drupalLogin($this->adminUser); } /** - * Test taxonomy functionality with nodes prior to 1970. + * Tests taxonomy functionality with nodes prior to 1970. */ function testTaxonomyLegacyNode() { // Posts an article with a taxonomy term and a date prior to 1970. diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LoadMultipleTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LoadMultipleTest.php index 657e9b4..e13a9f1 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LoadMultipleTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LoadMultipleTest.php @@ -8,7 +8,7 @@ namespace Drupal\taxonomy\Tests; /** - * Test the taxonomy_term_load_multiple() function. + * Tests the taxonomy_term_load_multiple() function. */ class LoadMultipleTest extends TaxonomyTestBase { @@ -22,12 +22,12 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy')); - $this->drupalLogin($this->taxonomy_admin); + $taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy')); + $this->drupalLogin($taxonomy_admin); } /** - * Create a vocabulary and some taxonomy terms, ensuring they're loaded + * Creates a vocabulary and some taxonomy terms, ensuring they're loaded * correctly using taxonomy_term_load_multiple(). */ function testTaxonomyTermMultipleLoad() { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php index 79998b6..51fe67c 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php @@ -19,6 +19,9 @@ class RssTest extends TaxonomyTestBase { */ public static $modules = array('node', 'field_ui'); + protected $instance; + protected $vocabulary; + public static function getInfo() { return array( 'name' => 'Taxonomy RSS Content.', @@ -30,8 +33,12 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access', 'administer content types')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array( + 'administer content types', + 'administer taxonomy', + 'bypass node access', + )); + $this->drupalLogin($admin_user); $this->vocabulary = $this->createVocabulary(); $field = array( diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php index 6f4dcb2..0be333f 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php @@ -21,6 +21,8 @@ */ public static $modules = array('taxonomy'); + protected $profile; + function setUp() { parent::setUp(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php index 37cbf4e..a183062 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php @@ -19,6 +19,8 @@ class TermFieldMultipleVocabularyTest extends TaxonomyTestBase { */ public static $modules = array('field_test'); + protected $field; + protected $field_name; protected $instance; protected $vocabulary1; protected $vocabulary2; @@ -34,7 +36,11 @@ public static function getInfo() { function setUp() { parent::setUp(); - $web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer taxonomy')); + $web_user = $this->drupalCreateUser(array( + 'access field_test content', + 'administer field_test content', + 'administer taxonomy', + )); $this->drupalLogin($web_user); $this->vocabulary1 = $this->createVocabulary(); $this->vocabulary2 = $this->createVocabulary(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php index 34065e1..e9e3579 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php @@ -21,6 +21,8 @@ class TermFieldTest extends TaxonomyTestBase { */ public static $modules = array('field_test'); + protected $field; + protected $field_name; protected $instance; protected $vocabulary; @@ -71,7 +73,7 @@ function setUp() { } /** - * Test term field validation. + * Tests term field validation. */ function testTaxonomyTermFieldValidation() { // Test valid and invalid values with field_attach_validate(). @@ -100,7 +102,7 @@ function testTaxonomyTermFieldValidation() { } /** - * Test widgets. + * Tests widgets. */ function testTaxonomyTermFieldWidgets() { // Create a term in the vocabulary. diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php index 31d01c5..06398ea 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php @@ -12,6 +12,14 @@ */ class TermIndexTest extends TaxonomyTestBase { + protected $field_1; + protected $field_2; + protected $field_name_1; + protected $field_name_2; + protected $instance_1; + protected $instance_2; + protected $vocabulary; + public static function getInfo() { return array( 'name' => 'Taxonomy term index', @@ -24,8 +32,8 @@ function setUp() { parent::setUp(); // Create an administrative user. - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); + $this->drupalLogin($admin_user); // Create a vocabulary and add two term reference fields to article nodes. $this->vocabulary = $this->createVocabulary(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php index f64cf58..921fe94 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php @@ -16,6 +16,8 @@ class TermLanguageTest extends TaxonomyTestBase { public static $modules = array('language'); + protected $vocabulary; + public static function getInfo() { return array( 'name' => 'Taxonomy term language', @@ -28,8 +30,8 @@ function setUp() { parent::setUp(); // Create an administrative user. - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer taxonomy')); + $this->drupalLogin($admin_user); // Create a vocabulary to which the terms will be assigned. $this->vocabulary = $this->createVocabulary(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index b2603d6..86c3dd5 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -12,6 +12,8 @@ */ class TermTest extends TaxonomyTestBase { + protected $vocabulary; + public static function getInfo() { return array( 'name' => 'Taxonomy term functions and forms', @@ -22,8 +24,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); + $this->drupalLogin($admin_user); $this->vocabulary = $this->createVocabulary(); $field = array( @@ -58,7 +60,7 @@ function setUp() { } /** - * Test terms in a single and multiple hierarchy. + * Tests terms in a single and multiple hierarchy. */ function testTaxonomyTermHierarchy() { // Create two taxonomy terms. @@ -95,7 +97,7 @@ function testTaxonomyTermHierarchy() { } /** - * Test that hook_node_$op implementations work correctly. + * Tests that hook_node_$op implementations work correctly. * * Save & edit a node and assert that taxonomy terms are saved/loaded properly. */ @@ -137,7 +139,7 @@ function testTaxonomyNode() { } /** - * Test term creation with a free-tagging vocabulary from the node form. + * Tests term creation with a free-tagging vocabulary from the node form. */ function testNodeTermCreationAndDeletion() { // Enable tags in the vocabulary. @@ -275,7 +277,7 @@ function testTermAutocompletion() { } /** - * Save, edit and delete a term using the user interface. + * Saves, edits and deletes a term using the user interface. */ function testTermInterface() { $edit = array( @@ -347,7 +349,7 @@ function testTermInterface() { } /** - * Save, edit and delete a term using the user interface. + * Saves, edits and deletes a term using the user interface. */ function testTermReorder() { $this->createTerm($this->vocabulary); @@ -406,7 +408,7 @@ function testTermReorder() { } /** - * Test saving a term with multiple parents through the UI. + * Tests saving a term with multiple parents through the UI. */ function testTermMultipleParentsInterface() { // Add a new term to the vocabulary so that we can have multiple parents. @@ -435,7 +437,7 @@ function testTermMultipleParentsInterface() { } /** - * Test taxonomy_term_load_multiple_by_name(). + * Tests function taxonomy_term_load_multiple_by_name(). */ function testTaxonomyGetTermByName() { $term = $this->createTerm($this->vocabulary); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php index e273c1b..4e5ca9e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php @@ -12,6 +12,10 @@ */ class TokenReplaceTest extends TaxonomyTestBase { + protected $instance; + protected $langcode; + protected $vocabulary; + public static function getInfo() { return array( 'name' => 'Taxonomy token replacement', @@ -22,8 +26,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); + $this->drupalLogin($admin_user); $this->vocabulary = $this->createVocabulary(); $this->langcode = LANGUAGE_NOT_SPECIFIED; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php index f4368b7..9a92b93 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php @@ -28,8 +28,8 @@ function setUp() { parent::setUp(); // Create an administrative user. - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer taxonomy')); + $this->drupalLogin($admin_user); } function testVocabularyLanguage() { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php index 6197fdb..79856d9 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php @@ -12,6 +12,8 @@ */ class VocabularyTest extends TaxonomyTestBase { + protected $vocabulary; + public static function getInfo() { return array( 'name' => 'Taxonomy vocabulary interface', @@ -22,13 +24,13 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer taxonomy')); + $this->drupalLogin($admin_user); $this->vocabulary = $this->createVocabulary(); } /** - * Create, edit and delete a vocabulary via the user interface. + * Creates, edits and deletes a vocabulary via the user interface. */ function testVocabularyInterface() { // Visit the main taxonomy administration page. @@ -105,7 +107,7 @@ function testTaxonomyAdminChangingWeights() { } /** - * Test the vocabulary overview with no vocabularies. + * Tests the vocabulary overview with no vocabularies. */ function testTaxonomyAdminNoVocabularies() { // Delete all vocabularies. @@ -121,7 +123,7 @@ function testTaxonomyAdminNoVocabularies() { } /** - * Deleting a vocabulary. + * Tests deleting a vocabulary. */ function testTaxonomyAdminDeletingVocabulary() { // Create a vocabulary. diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php index 9080ef2..72cf178 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php @@ -12,6 +12,8 @@ */ class VocabularyUnitTest extends TaxonomyTestBase { + protected $vocabulary; + /** * Modules to enable. * @@ -36,7 +38,7 @@ function setUp() { } /** - * Ensure that when an invalid vocabulary vid is loaded, it is possible + * Ensures that when an invalid vocabulary vid is loaded, it is possible * to load the same vid successfully if it subsequently becomes valid. */ function testTaxonomyVocabularyLoadReturnFalse() { @@ -57,7 +59,7 @@ function testTaxonomyVocabularyLoadReturnFalse() { } /** - * Test deleting a taxonomy that contains terms. + * Tests deleting a taxonomy that contains terms. */ function testTaxonomyVocabularyDeleteWithTerms() { // Delete any existing vocabularies. @@ -91,7 +93,7 @@ function testTaxonomyVocabularyDeleteWithTerms() { } /** - * Ensure that the vocabulary static reset works correctly. + * Ensures that the vocabulary static reset works correctly. */ function testTaxonomyVocabularyLoadStaticReset() { $original_vocabulary = taxonomy_vocabulary_load($this->vocabulary->vid); @@ -196,7 +198,7 @@ function testTaxonomyVocabularyChangeMachineName() { } /** - * Test uninstall and reinstall of the taxonomy module. + * Tests uninstall and reinstall of the taxonomy module. */ function testUninstallReinstall() { // Fields and field instances attached to taxonomy term bundles should be diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php index 7cd99cc..52d7582 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php @@ -33,7 +33,7 @@ class TrackerTest extends WebTestBase { * * @var object */ - protected $other_user; + protected $otherUser; public static function getInfo() { return array( @@ -50,7 +50,7 @@ function setUp() { $permissions = array('access comments', 'create page content', 'post comments', 'skip comment approval'); $this->user = $this->drupalCreateUser($permissions); - $this->other_user = $this->drupalCreateUser($permissions); + $this->otherUser = $this->drupalCreateUser($permissions); // Make node preview optional. variable_set('comment_preview_page', 0); @@ -100,12 +100,12 @@ function testTrackerUser() { )); $other_published_no_comment = $this->drupalCreateNode(array( 'title' => $this->randomName(8), - 'uid' => $this->other_user->uid, + 'uid' => $this->otherUser->uid, 'status' => 1, )); $other_published_my_comment = $this->drupalCreateNode(array( 'title' => $this->randomName(8), - 'uid' => $this->other_user->uid, + 'uid' => $this->otherUser->uid, 'status' => 1, )); $comment = array( @@ -147,7 +147,7 @@ function testTrackerNewNodes() { $this->drupalGet('tracker'); $this->assertNoPattern('/' . $title . '.*new/', t('Visited nodes are not flagged as new.')); - $this->drupalLogin($this->other_user); + $this->drupalLogin($this->otherUser); $this->drupalGet('tracker'); $this->assertPattern('/' . $title . '.*new/', t('For another user, new nodes are flagged as such in the tracker listing.')); @@ -175,12 +175,12 @@ function testTrackerNewComments() { // The new comment is automatically viewed by the current user. $this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save')); - $this->drupalLogin($this->other_user); + $this->drupalLogin($this->otherUser); $this->drupalGet('tracker'); $this->assertText('1 new', t('New comments are counted on the tracker listing pages.')); $this->drupalGet('node/' . $node->nid); - // Add another comment as other_user. + // Add another comment as otherUser. $comment = array( 'subject' => $this->randomName(), 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), @@ -213,7 +213,7 @@ function testTrackerCronIndexing() { } // Add a comment to the last node as other user. - $this->drupalLogin($this->other_user); + $this->drupalLogin($this->otherUser); $comment = array( 'subject' => $this->randomName(), 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php index a9fae77..f2e70a3 100644 --- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php +++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php @@ -22,10 +22,31 @@ class TranslationTest extends WebTestBase { */ public static $modules = array('translation', 'translation_test'); - protected $profile = 'standard'; + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; protected $book; + /** + * A user with limited translation permission. + * + * @var object|false + */ + protected $limitedTranslateUser; + + protected $profile = 'standard'; + + /** + * A user with translation permission. + * + * @var object|false + */ + protected $translateUser; + public static function getInfo() { return array( 'name' => 'Translation functionality', @@ -38,11 +59,27 @@ function setUp() { parent::setUp(); // Setup users. - $this->admin_user = $this->drupalCreateUser(array('bypass node access', 'administer nodes', 'administer languages', 'administer content types', 'administer blocks', 'access administration pages', 'translate all content')); - $this->translator = $this->drupalCreateUser(array('create page content', 'edit own page content', 'translate all content')); - $this->limited_translator = $this->drupalCreateUser(array('create page content', 'edit own page content', 'translate own content')); - - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array( + 'access administration pages', + 'administer blocks', + 'administer content types', + 'administer languages', + 'administer nodes', + 'bypass node access', + 'translate all content', + )); + $this->translateUser = $this->drupalCreateUser(array( + 'create page content', + 'edit own page content', + 'translate all content', + )); + $this->limitedTranslateUser = $this->drupalCreateUser(array( + 'create page content', + 'edit own page content', + 'translate own content', + )); + + $this->drupalLogin($this->adminUser); // Add languages. $this->addLanguage('en'); @@ -63,7 +100,7 @@ function setUp() { // Reset static caches in our local language environment. $this->resetCaches(); - $this->drupalLogin($this->translator); + $this->drupalLogin($this->translateUser); } /** @@ -76,11 +113,11 @@ function testContentTranslation() { $node = $this->createPage($node_title, $node_body, 'en'); // Unpublish the original node to check that this has no impact on the // translation overview page, publish it again afterwards. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalPost('node/' . $node->nid . '/edit', array('status' => FALSE), t('Save')); $this->drupalGet('node/' . $node->nid . '/translate'); $this->drupalPost('node/' . $node->nid . '/edit', array('status' => NODE_PUBLISHED), t('Save')); - $this->drupalLogin($this->translator); + $this->drupalLogin($this->translateUser); // Check that the "add translation" link uses a localized path. $languages = language_list(); @@ -143,9 +180,9 @@ function testContentTranslation() { // Leave just one language installed and check that the translation overview // page is still accessible. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalPost('admin/config/regional/language/delete/es', array(), t('Delete')); - $this->drupalLogin($this->translator); + $this->drupalLogin($this->translateUser); $this->drupalGet('node/' . $node->nid . '/translate'); $this->assertRaw(t('Translations of %title', array('%title' => $node->label())), t('Translation overview page available with only one language enabled.')); } @@ -170,21 +207,21 @@ function testLanguageSwitchLinks() { // Unpublish the Spanish translation to check that the related language // switch link is not shown. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $edit = array('status' => FALSE); $this->drupalPost("node/$translation_es->nid/edit", $edit, t('Save')); - $this->drupalLogin($this->translator); + $this->drupalLogin($this->translateUser); $this->assertLanguageSwitchLinks($node, $translation_es, FALSE); // Check that content translation links are shown even when no language // negotiation is configured. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $edit = array('language_interface[enabled][language-url]' => FALSE); $this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings')); $this->resetCaches(); $edit = array('status' => TRUE); $this->drupalPost("node/$translation_es->nid/edit", $edit, t('Save')); - $this->drupalLogin($this->translator); + $this->drupalLogin($this->translateUser); $this->assertLanguageSwitchLinks($node, $translation_es, TRUE, 'node'); } @@ -193,10 +230,10 @@ function testLanguageSwitchLinks() { */ function testLanguageSwitcherBlockIntegration() { // Add Italian to have three items in the language switcher block. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->addLanguage('it'); $this->resetCaches(); - $this->drupalLogin($this->translator); + $this->drupalLogin($this->translateUser); // Create a Basic page in English. $type = 'block-language'; @@ -229,10 +266,10 @@ function testLanguageSwitcherBlockIntegration() { // Disable translation support to check that the language switcher is left // untouched only for new nodes. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $edit = array('node_type_language_hidden' => TRUE, 'node_type_language_translation_enabled' => FALSE); $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); - $this->drupalLogin($this->translator); + $this->drupalLogin($this->translateUser); // Existing translations trigger alterations even if translation support is // disabled. @@ -256,7 +293,7 @@ function testLanguageSwitcherBlockIntegration() { function testTranslateOwnContentRole() { // Create a Basic page in English and its translation in Spanish with user // that has "translate own content" role. - $this->drupalLogin($this->limited_translator); + $this->drupalLogin($this->limitedTranslateUser); $node = $this->createPage($this->randomName(), $this->randomName(), 'en'); $this->assertLinkByHref('node/' . $node->nid . '/translate', 0, t('User with "translate own content" role can see translate link')); $this->drupalGet('node/' . $node->nid . '/translate'); @@ -264,10 +301,10 @@ function testTranslateOwnContentRole() { $translation_es = $this->createTranslation($node, $this->randomName(), $this->randomName(), 'es'); // Create a page as translator user. - $this->drupalLogin($this->translator); + $this->drupalLogin($this->translateUser); $node = $this->createPage($this->randomName(), $this->randomName(), 'en'); // Change to limited_translator and check that translate links aren't shown. - $this->drupalLogin($this->limited_translator); + $this->drupalLogin($this->limitedTranslateUser); $this->assertNoLinkByHref('node/' . $node->nid . '/translate', t('User with "translate own content" role can\'t see translate link')); // Check if user with "translate own content" role can see translate page // from other user's node. diff --git a/core/modules/user/lib/Drupal/user/Tests/UserAutocompleteTest.php b/core/modules/user/lib/Drupal/user/Tests/UserAutocompleteTest.php index d5f1d8a..4f43d77 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserAutocompleteTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserAutocompleteTest.php @@ -13,6 +13,7 @@ * Test user autocompletion. */ class UserAutocompleteTest extends WebTestBase { + public static function getInfo() { return array( 'name' => 'User autocompletion', @@ -21,12 +22,26 @@ public static function getInfo() { ); } + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + function setUp() { parent::setUp(); // Set up two users with different permissions to test access. - $this->unprivileged_user = $this->drupalCreateUser(); - $this->privileged_user = $this->drupalCreateUser(array('access user profiles')); + $this->webUser = $this->drupalCreateUser(); + $this->adminUser = $this->drupalCreateUser(array('access user profiles')); } /** @@ -34,17 +49,17 @@ function setUp() { */ function testUserAutocomplete() { // Check access from unprivileged user, should be denied. - $this->drupalLogin($this->unprivileged_user); - $this->drupalGet('user/autocomplete/' . $this->unprivileged_user->name[0]); + $this->drupalLogin($this->webUser); + $this->drupalGet('user/autocomplete/' . $this->webUser->name[0]); $this->assertResponse(403, t('Autocompletion access denied to user without permission.')); // Check access from privileged user. $this->drupalLogout(); - $this->drupalLogin($this->privileged_user); - $this->drupalGet('user/autocomplete/' . $this->unprivileged_user->name[0]); + $this->drupalLogin($this->adminUser); + $this->drupalGet('user/autocomplete/' . $this->webUser->name[0]); $this->assertResponse(200, t('Autocompletion access allowed.')); // Using first letter of the user's name, make sure the user's full name is in the results. - $this->assertRaw($this->unprivileged_user->name, t('User name found in autocompletion results.')); + $this->assertRaw($this->webUser->name, t('User name found in autocompletion results.')); } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php index 0d12cff..9a4dd11 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php @@ -88,8 +88,8 @@ function testUserCancelUid1() { $user1->pass_raw = $password; // Try to cancel uid 1's account with a different user. - $this->admin_user = $this->drupalCreateUser(array('administer users')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer users')); + $this->drupalLogin($admin_user); $edit = array( 'operation' => 'cancel', 'accounts[1]' => TRUE, diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php index 13eb006..39135c8 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php @@ -10,7 +10,7 @@ use Drupal\simpletest\WebTestBase; /** - * Test user entity callbacks. + * Tests user entity callbacks. */ class UserEntityCallbacksTest extends WebTestBase { @@ -37,7 +37,7 @@ function setUp() { } /** - * Test label callback. + * Tests label callback. */ function testLabelCallback() { $this->assertEqual($this->account->label(), $this->account->name, t('The username should be used as label')); @@ -49,7 +49,7 @@ function testLabelCallback() { } /** - * Test URI callback. + * Tests URI callback. */ function testUriCallback() { $uri = $this->account->uri(); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php index 43f43e3..1601cd4 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php @@ -10,7 +10,14 @@ use Drupal\simpletest\WebTestBase; class UserPermissionsTest extends WebTestBase { - protected $admin_user; + + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + protected $rid; public static function getInfo() { @@ -24,21 +31,27 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'access user profiles', 'administer site configuration', 'administer modules', 'administer users')); + $this->adminUser = $this->drupalCreateUser(array( + 'access user profiles', + 'administer modules', + 'administer permissions', + 'administer site configuration', + 'administer users', + )); // Find the new role ID. - $all_rids = $this->admin_user->roles; + $all_rids = $this->adminUser->roles; unset($all_rids[DRUPAL_AUTHENTICATED_RID]); $this->rid = key($all_rids); } /** - * Change user permissions and check user_access(). + * Changes user permissions and check user_access(). */ function testUserPermissionChanges() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $rid = $this->rid; - $account = $this->admin_user; + $account = $this->adminUser; // Add a permission. $this->assertFalse(user_access('administer nodes', $account), t('User does not have "administer nodes" permission.')); @@ -62,10 +75,10 @@ function testUserPermissionChanges() { } /** - * Test assigning of permissions for the administrator role. + * Tests assigning of permissions for the administrator role. */ function testAdministratorRole() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet('admin/config/people/accounts'); // Set the user's role to be the administrator role. @@ -80,15 +93,15 @@ function testAdministratorRole() { // Aggregator depends on file module, enable that as well. $edit['modules[Core][file][enable]'] = TRUE; $this->drupalPost('admin/modules', $edit, t('Save configuration')); - $this->assertTrue(user_access('administer news feeds', $this->admin_user), t('The permission was automatically assigned to the administrator role')); + $this->assertTrue(user_access('administer news feeds', $this->adminUser), t('The permission was automatically assigned to the administrator role')); } /** - * Verify proper permission changes by user_role_change_permissions(). + * Verifies proper permission changes by user_role_change_permissions(). */ function testUserRoleChangePermissions() { $rid = $this->rid; - $account = $this->admin_user; + $account = $this->adminUser; // Verify current permissions. $this->assertFalse(user_access('administer nodes', $account), t('User does not have "administer nodes" permission.')); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php index 6e0153c..151086c 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php @@ -14,6 +14,14 @@ */ class UserRoleAdminTest extends WebTestBase { + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + public static function getInfo() { return array( 'name' => 'User role administration', @@ -24,14 +32,14 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'administer users')); + $this->adminUser = $this->drupalCreateUser(array('administer permissions', 'administer users')); } /** - * Test adding, renaming and deleting roles. + * Tests adding, renaming and deleting roles. */ function testRoleAdministration() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); // Test adding a role. (In doing so, we use a role name that happens to // correspond to an integer, to test that the role administration pages @@ -74,10 +82,10 @@ function testRoleAdministration() { } /** - * Test user role weight change operation. + * Tests user role weight change operation. */ function testRoleWeightChange() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); // Pick up a random role and get its weight. $rid = array_rand(user_roles()); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php index eaabdd2..5af560b 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php @@ -10,10 +10,16 @@ use Drupal\simpletest\WebTestBase; /** - * Test role assignment. + * Tests role assignment. */ class UserRolesAssignmentTest extends WebTestBase { - protected $admin_user; + + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; public static function getInfo() { return array( @@ -25,8 +31,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'administer users')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer permissions', 'administer users')); + $this->drupalLogin($this->adminUser); } /** @@ -81,7 +87,7 @@ function testCreateUserWithRole() { } /** - * Check role on user object. + * Checks role on user object. * * @param object $account * The user account to check. diff --git a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php index 9ed88ca..777a03a 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php @@ -10,7 +10,7 @@ use Drupal\simpletest\WebTestBase; /** - * Test case for user signatures. + * Tests for user signatures. */ class UserSignatureTest extends WebTestBase { @@ -21,6 +21,24 @@ class UserSignatureTest extends WebTestBase { */ public static $modules = array('comment'); + /** + * An adminstrative user. + * + * @var object|false + */ + protected $adminUser; + + /** + * A web visitor. + * + * @var object|false + */ + protected $webUser; + + protected $formatPlainText; + protected $formatFilteredHtml; + protected $formatFullHtml; + public static function getInfo() { return array( 'name' => 'User signatures', @@ -39,27 +57,27 @@ function setUp() { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); // Prefetch and create text formats. - $this->plain_text_format = filter_format_load('plain_text'); + $this->formatPlainText = filter_format_load('plain_text'); $filtered_html_format = array( 'format' => 'filtered_html', 'name' => 'Filtered HTML', ); - $this->filtered_html_format = (object) $filtered_html_format; - filter_format_save($this->filtered_html_format); + $this->formatFilteredHtml = (object) $filtered_html_format; + filter_format_save($this->formatFilteredHtml); $full_html_format = array( 'format' => 'full_html', 'name' => 'Full HTML', ); - $this->full_html_format = (object) $full_html_format; - filter_format_save($this->full_html_format); + $this->formatFullHtml = (object) $full_html_format; + filter_format_save($this->formatFullHtml); - user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(filter_permission_name($this->filtered_html_format))); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(filter_permission_name($this->formatFilteredHtml))); $this->checkPermissions(array(), TRUE); // Create regular and administrative users. - $this->web_user = $this->drupalCreateUser(array('post comments')); + $this->webUser = $this->drupalCreateUser(array('post comments')); $admin_permissions = array('administer comments'); foreach (filter_formats() as $format) { @@ -67,11 +85,11 @@ function setUp() { $admin_permissions[] = $permission; } } - $this->admin_user = $this->drupalCreateUser($admin_permissions); + $this->adminUser = $this->drupalCreateUser($admin_permissions); } /** - * Test that a user can change their signature format and that it is respected + * Tests that a user can change their signature format and that it is respected * upon display. */ function testUserSignature() { @@ -83,13 +101,13 @@ function testUserSignature() { $this->assertNoText(t('Signature')); // Log in as a regular user and create a signature. - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); $signature_text = "

" . $this->randomName() . "

"; $edit = array( 'signature[value]' => $signature_text, - 'signature[format]' => $this->plain_text_format->format, + 'signature[format]' => $this->formatPlainText->format, ); - $this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Save')); + $this->drupalPost('user/' . $this->webUser->uid . '/edit', $edit, t('Save')); // Verify that values were stored. $this->assertFieldByName('signature[value]', $edit['signature[value]'], 'Submitted signature text found.'); @@ -110,13 +128,13 @@ function testUserSignature() { // Log in as an administrator and edit the comment to use Full HTML, so // that the comment text itself is not filtered at all. - $this->drupalLogin($this->admin_user); - $edit['comment_body[' . $langcode . '][0][format]'] = $this->full_html_format->format; + $this->drupalLogin($this->adminUser); + $edit['comment_body[' . $langcode . '][0][format]'] = $this->formatFullHtml->format; $this->drupalPost('comment/' . $comment_id . '/edit', $edit, t('Save')); // Assert that the signature did not make it through unfiltered. $this->drupalGet('node/' . $node->nid); $this->assertNoRaw($signature_text, 'Unfiltered signature text not found.'); - $this->assertRaw(check_markup($signature_text, $this->plain_text_format->format), 'Filtered signature text found.'); + $this->assertRaw(check_markup($signature_text, $this->formatPlainText->format), 'Filtered signature text found.'); } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php b/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php index 56dbc62..2e14a8c 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php @@ -21,24 +21,28 @@ class UserValidateCurrentPassCustomFormTest extends WebTestBase { */ public static $modules = array('user_form_test'); - public static function getInfo() { - return array( - 'name' => 'User validate current pass custom form', - 'description' => 'Test that user_validate_current_pass is usable on a custom form.', - 'group' => 'User', - ); - } - /** * User with permission to view content. + * + * @var object|false */ protected $accessUser; /** * User permission to administer users. + * + * @var object|false */ protected $adminUser; + public static function getInfo() { + return array( + 'name' => 'User validate current pass custom form', + 'description' => 'Test that user_validate_current_pass is usable on a custom form.', + 'group' => 'User', + ); + } + function setUp() { parent::setUp();