1c1 < From 21c67b20b98c34cf0da3f2f2074e3dd79734cc42 Mon Sep 17 00:00:00 2001 --- > From aa9bdef2d9c1341078771d4e4f6ff4d695032a56 Mon Sep 17 00:00:00 2001 10a11,12 > .../Upgrade/UserPermissionUpgradePathTest.php | 64 ++++++++++++++++++++ > .../upgrade/drupal-7.user_permission.database.php | 60 ++++++++++++++++++ 13,14c15,16 < core/modules/user/user.install | 29 +++++++++++++++++--- < core/modules/user/user.module | 9 +++++- --- > core/modules/user/user.install | 29 +++++++-- > core/modules/user/user.module | 9 ++- 16c18,20 < 8 files changed, 39 insertions(+), 10 deletions(-) --- > 10 files changed, 163 insertions(+), 10 deletions(-) > create mode 100644 core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPermissionUpgradePathTest.php > create mode 100644 core/modules/system/tests/upgrade/drupal-7.user_permission.database.php 55a60,195 > diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPermissionUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPermissionUpgradePathTest.php > new file mode 100644 > index 0000000..ecb8b3a > --- /dev/null > +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPermissionUpgradePathTest.php > @@ -0,0 +1,64 @@ > + + > +/** > + * @file > + * Definition of Drupal\system\Tests\Upgrade\UserPermissionUpgradePathTest. > + */ > + > +namespace Drupal\system\Tests\Upgrade; > + > +use Drupal\Core\Session\UserSession; > + > +/** > + * Tests upgrading a bare database with user role data. > + * > + * Loads a bare installation of Drupal 7 with role data and runs the > + * upgrade process on it. Tests for the upgrade of user permissions. > + */ > +class UserPermissionUpgradePathTest extends UpgradePathTestBase { > + public static function getInfo() { > + return array( > + 'name' => 'User permission upgrade test', > + 'description' => 'Upgrade tests for user permissions.', > + 'group' => 'Upgrade path', > + ); > + } > + > + public function setUp() { > + $this->databaseDumpFiles = array( > + drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.standard_all.database.php.gz', > + drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.user_permission.database.php', > + ); > + parent::setUp(); > + } > + > + /** > + * Tests user-related permissions after a successful upgrade. > + */ > + public function testUserPermissionUpgrade() { > + $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); > + > + $this->drupalGet(''); > + $this->assertResponse(200); > + > + // Verify that we are still logged in. > + $this->drupalGet('user'); > + $this->clickLink(t('Edit')); > + $this->assertEqual($this->getUrl(), url('user/1/edit', array('absolute' => TRUE)), 'We are still logged in as admin at the end of the upgrade.'); > + > + // Login as another 'administrator' role user whose uid != 1 > + $this->drupalLogout(); > + $user = new UserSession(array( > + 'uid' => 2, > + 'name' => 'user1', > + 'pass_raw' => 'user1', > + )); > + $this->drupalLogin($user); > + > + // Check that user with permission 'administer users' also gets > + // 'administer account settings' access. > + $this->drupalGet('admin/config/people/accounts'); > + $this->assertResponse(200, '"Administer account settings" page was found.'); > + } > + > +} > diff --git a/core/modules/system/tests/upgrade/drupal-7.user_permission.database.php b/core/modules/system/tests/upgrade/drupal-7.user_permission.database.php > new file mode 100644 > index 0000000..dc6cd5a > --- /dev/null > +++ b/core/modules/system/tests/upgrade/drupal-7.user_permission.database.php > @@ -0,0 +1,60 @@ > + + > +/** > + * @file > + * Database additions for user permissions tests. Used in > + * \Drupal\system\Tests\Upgrade\UserPermissionUpgradePathTest. > + * > + * This dump only contains data and schema components relevant for user data > + * permission upgrade tests. The drupal-7.bare.standard_all.database.php.gz > + * file is imported before this dump, so the two form the database > + * structure expected in tests altogether. > + */ > + > +db_insert('users_roles')->fields(array( > + 'uid', > + 'rid', > +)) > +->values(array( > + 'uid' => '2', > + 'rid' => '3', > +)) > +->execute(); > + > +db_insert('users')->fields(array( > + 'uid', > + 'name', > + 'pass', > + 'mail', > + 'theme', > + 'signature', > + 'signature_format', > + 'created', > + 'access', > + 'login', > + 'status', > + 'timezone', > + 'language', > + 'picture', > + 'init', > + 'data', > +)) > +->values(array( > + 'uid' => '2', > + 'name' => 'user1', > + 'pass' => '$S$D9JgycE33DawX/9Iv2SfAjkQEi5alDZhxycfan6dDkUKf9lH0Nfo', > + 'mail' => 'user1@example.com', > + 'theme' => '', > + 'signature' => '', > + 'signature_format' => NULL, > + 'created' => '1376147347', > + 'access' => '0', > + 'login' => '0', > + 'status' => '1', > + 'timezone' => 'Europe/Berlin', > + 'language' => '', > + 'picture' => '0', > + 'init' => 'user1@example.com', > + 'data' => NULL, > +)) > +->execute(); 148c288 < index 60da26c..b22fbde 100644 --- > index 0a8d4ab..85d5fd5 100644 151c291 < @@ -481,6 +481,13 @@ function user_permission() { --- > @@ -479,6 +479,13 @@ function user_permission() { 165c305 < @@ -901,7 +908,7 @@ function user_menu() { --- > @@ -898,7 +905,7 @@ function user_menu() {