diff --git a/core/modules/user/lib/Drupal/user/Tests/UserAdminListingTest.php b/core/modules/user/lib/Drupal/user/Tests/UserAdminListingTest.php index e1e20e6..3662671 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserAdminListingTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserAdminListingTest.php @@ -34,39 +34,39 @@ public function testUserListing() { // Create a bunch of users. $accounts = array(); for ($i = 0; $i < 3; $i++) { - $account = $this->drupalCreateUser(); - $accounts[$account->name] = $account; + $account = $this->drupalCreateUser()->getNGEntity(); + $accounts[$account->label()] = $account; } // Create a blocked user. - $account = $this->drupalCreateUser(); + $account = $this->drupalCreateUser()->getNGEntity(); $account->status = 0; $account->save(); - $accounts[$account->name] = $account; + $accounts[$account->label()] = $account; // Create a user at a certain timestamp. - $account = $this->drupalCreateUser(); + $account = $this->drupalCreateUser()->getNGEntity(); $account->created = 1363219200; $account->save(); - $accounts[$account->name] = $account; - $timestamp_user = $account->name; + $accounts[$account->label()] = $account; + $timestamp_user = $account->label(); $rid_1 = $this->drupalCreateRole(array(), 'custom_role_1', 'custom_role_1'); $rid_2 = $this->drupalCreateRole(array(), 'custom_role_2', 'custom_role_2'); - $account = $this->drupalCreateUser(); - $account->roles[$rid_1] = $rid_1; - $account->roles[$rid_2] = $rid_2; + $account = $this->drupalCreateUser()->getNGEntity(); + $account->addRole($rid_1); + $account->addRole($rid_2); $account->save(); - $accounts[$account->name] = $account; - $role_account_name = $account->name; + $accounts[$account->label()] = $account; + $role_account_name = $account->label(); // Create an admin user and look at the listing. - $admin_user = $this->drupalCreateUser(array('administer users')); - $accounts[$admin_user->name] = $admin_user; + $admin_user = $this->drupalCreateUser(array('administer users'))->getNGEntity(); + $accounts[$admin_user->label()] = $admin_user; - $accounts['admin'] = user_load('1'); + $accounts['admin'] = entity_load('user', 1); - $this->drupalLogin($admin_user); + $this->drupalLogin($admin_user->getBCEntity()); $this->drupalGet('admin/people'); $this->assertResponse(200, 'The admin user has access to the user admin listing.'); @@ -91,13 +91,13 @@ public function testUserListing() { $this->assertFalse(array_diff(array_keys($result_accounts), array_keys($accounts)), 'Ensure all accounts are listed.'); foreach ($result_accounts as $name => $values) { - $this->assertEqual($values['status'] == t('active'), $accounts[$name]->status, 'Ensure the status is displayed properly.'); + $this->assertEqual($values['status'] == t('active'), $accounts[$name]->status->value, 'Ensure the status is displayed properly.'); } $expected_roles = array('custom_role_1', 'custom_role_2'); $this->assertEqual($result_accounts[$role_account_name]['roles'], $expected_roles, 'Ensure roles are listed properly.'); - $this->assertEqual($result_accounts[$timestamp_user]['member_for'], format_interval(REQUEST_TIME - $accounts[$timestamp_user]->created), 'Ensure the right member time is displayed.'); + $this->assertEqual($result_accounts[$timestamp_user]['member_for'], format_interval(REQUEST_TIME - $accounts[$timestamp_user]->created->value), 'Ensure the right member time is displayed.'); } } diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php index d51a6b6..b408bd5 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php @@ -37,11 +37,11 @@ public function testBulkForm() { $this->drupalGet('test-user-bulk-form'); $elements = $this->xpath('//select[@id="edit-action"]//option'); - $this->assertIdentical(count($elements), count($this->container->get('module_handler')->invokeAll('user_operations')), 'All user operations are found.'); + $this->assertIdentical(count($elements), 5, 'All user operations are found.'); // Test submitting the page with no selection. $edit = array( - 'action' => 'block', + 'action' => 'user_block_user_action', ); $this->drupalPost(NULL, $edit, t('Apply')); // @todo Validation errors are only shown on page refresh. @@ -49,41 +49,41 @@ public function testBulkForm() { $this->assertText(t('No users selected.')); // Assign a role to a user. - $account = $this->users[0]; + $account = entity_load('user', $this->users[0]->id()); $roles = user_role_names(TRUE); unset($roles[DRUPAL_AUTHENTICATED_RID]); $role = key($roles); - $this->assertTrue(!isset($account->roles[$role]), 'The user currently does not have a custom role.'); + $this->assertFalse($account->hasRole($role), 'The user currently does not have a custom role.'); $edit = array( 'user_bulk_form[1]' => TRUE, - 'action' => 'add_role-' . $role, + 'action' => 'user_add_role_action.' . $role, ); $this->drupalPost(NULL, $edit, t('Apply')); // Re-load the user and check their roles. $account = entity_load('user', $account->id(), TRUE); - $this->assertTrue(isset($account->roles[$role]), 'The user now has the custom role.'); + $this->assertTrue($account->hasRole($role), 'The user now has the custom role.'); $edit = array( 'user_bulk_form[1]' => TRUE, - 'action' => 'remove_role-' . $role, + 'action' => 'user_remove_role_action.' . $role, ); $this->drupalPost(NULL, $edit, t('Apply')); // Re-load the user and check their roles. $account = entity_load('user', $account->id(), TRUE); - $this->assertTrue(!isset($account->roles[$role]), 'The user no longer has the custom role.'); + $this->assertFalse($account->hasRole($role), 'The user no longer has the custom role.'); // Block a user using the bulk form. - $this->assertTrue($account->status); + $this->assertTrue($account->status->value, 'The user is not blocked.'); $this->assertRaw($account->label(), 'The user is found in the table.'); $edit = array( 'user_bulk_form[1]' => TRUE, - 'action' => 'block', + 'action' => 'user_block_user_action', ); $this->drupalPost(NULL, $edit, t('Apply')); // Re-load the user and check their status. $account = entity_load('user', $account->id(), TRUE); - $this->assertFalse($account->status); + $this->assertFalse($account->status->value, 'The user is blocked.'); $this->assertNoRaw($account->label(), 'The user is not found in the table.'); // Remove the user status filter from the view. @@ -98,7 +98,7 @@ public function testBulkForm() { // Attempt to block the anonymous user. $edit = array( 'user_bulk_form[0]' => TRUE, - 'action' => 'block', + 'action' => 'user_block_user_action', ); $this->drupalPost(NULL, $edit, t('Apply')); $anonymous_account = user_load(0);