<?php
namespace Drupal\system\Tests\Upgrade;
class UserRoleUpgradePathTest extends UpgradePathTestBase {
public static function getInfo() {
return array(
'name' => 'Role upgrade test',
'description' => 'Upgrade tests with role data.',
'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.roles.database.php',
);
parent::setUp();
}
public function testRoleUpgrade() {
$this
->assertTrue($this
->performUpgrade(), 'The upgrade was completed successfully.');
$this
->drupalGet('admin/people/roles/manage/4');
$this
->assertResponse(200, 'Role edit page for "gärtner" was found.');
$this
->assertField('label', 'Role edit page for "gärtner" was found.');
$this
->assertRaw('gärtner', 'Role edit page for "gärtner" was found.');
$this
->drupalGet('admin/people/permissions/' . DRUPAL_ANONYMOUS_RID);
$this
->assertResponse(200, 'Permission edit page for "anonymous" was found.');
$this
->drupalGet('admin/people/permissions/' . DRUPAL_AUTHENTICATED_RID);
$this
->assertResponse(200, 'Permission edit page for "authenticated" was found.');
$this
->drupalGet('admin/people/permissions/4');
$this
->assertFieldChecked('edit-4-edit-own-comments', 'Edit own comments permission for "gärtner" is set correctly.');
$this
->drupalGet('admin/structure/block/add/user_online_block/bartik');
$this
->assertText('gärtner', 'Role name is displayed on block visibility settings.');
$this
->assertText('very long role name that has exactly sixty-four characters in it', 'Role name is displayed on block visibility settings.');
$this
->assertText('very_long role name that has exactly sixty-four characters in it', 'Role name is displayed on block visibility settings.');
$this
->drupalGet('admin/config/people/accounts');
$this
->assertFieldByName('user_admin_role', 3);
}
public function testRoleUpgradeToConfig() {
$this
->assertTrue($this
->performUpgrade(), 'The upgrade was completed successfully.');
$anonymous = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
$this
->assertNotEqual(FALSE, $anonymous, "The 'anonymous' role has been converted to config.");
$authenticated = entity_load('user_role', DRUPAL_AUTHENTICATED_RID);
$this
->assertNotEqual(FALSE, $authenticated, "The 'authenticated' role has been converted to config.");
}
}