public function LanguageUpgradePathTest::testLanguagePermissionsUpgrade

Tests upgrading translations permissions.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php, line 172
Definition of Drupal\system\Tests\Upgrade\LanguageUpgradePathTest.

Class

LanguageUpgradePathTest
Tests upgrading a filled database with language data.

Namespace

Drupal\system\Tests\Upgrade

Code

public function testLanguagePermissionsUpgrade() {
  db_insert('role_permission')
    ->fields(array(
    'rid' => 2,
    'permission' => 'translate content',
    'module' => 'translation',
  ))
    ->execute();
  $this
    ->assertTrue($this
    ->performUpgrade(), 'The upgrade was completed successfully.');

  // Check that translate content role doesn't exist on database.
  $old_permission_exists = db_query('SELECT * FROM {role_permission} WHERE permission LIKE ?', array(
    'translate content',
  ))
    ->fetchObject();
  $this
    ->assertFalse($old_permission_exists, 'No translate content role left on database.');

  // Check that translate content has been renamed to translate all content.
  $new_permission_exists = db_query('SELECT * FROM {role_permission} WHERE permission LIKE ?', array(
    'translate all content',
  ))
    ->fetchObject();
  $this
    ->assertTrue($new_permission_exists, 'Rename role translate content to translate all content was completed successfully.');
}