Commit edf8109b authored by catch's avatar catch
Browse files

Issue #3210502 by longwave, quietone, Spokje: Convert UpdateDescriptionTest to a kernel test

parent 2c841415
<?php
namespace Drupal\Tests\system\Functional\UpdateSystem;
use Drupal\Core\Database\Database;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the display of the description for hook_update().
*
* @group Update
*/
class UpdateDescriptionTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests displayed description.
*/
public function testDescription() {
$user = $this->drupalCreateUser([
'administer software updates',
'access site in maintenance mode',
]);
$this->drupalLogin($user);
$connection = Database::getConnection();
// Set the schema version.
$connection->merge('key_value')
->condition('collection', 'system.schema')
->condition('name', 'update_test_description')
->fields([
'collection' => 'system.schema',
'name' => 'update_test_description',
'value' => 'i:8000;',
])
->execute();
// Update core.extension.
$extensions = $connection->select('config')
->fields('config', ['data'])
->condition('collection', '')
->condition('name', 'core.extension')
->execute()
->fetchField();
$extensions = unserialize($extensions);
$extensions['module']['update_test_description'] = 8000;
$connection->update('config')
->fields([
'data' => serialize($extensions),
])
->condition('collection', '')
->condition('name', 'core.extension')
->execute();
// Go to the update page.
$update_url = Url::fromRoute('system.db_update');
$this->drupalGet($update_url);
$this->clickLink(t('Continue'));
// Check that the description is displayed correctly.
$this->assertSession()->responseContains('8001 - Update test of slash in description and/or.');
$this->assertSession()->responseContains('8002 - Update test with multiline description, the quick brown fox jumped over the lazy dog.');
}
}
<?php
namespace Drupal\KernelTests\Core\Extension;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests for update descriptions.
*
* @group Core
*/
class UpdateDescriptionTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['update_test_description'];
/**
* Tests the list of pending database updates.
*
* @see update_get_update_list()
*/
public function testUpdateGetUpdateList() {
require_once $this->root . '/core/includes/update.inc';
drupal_set_installed_schema_version('update_test_description', 8000);
\Drupal::moduleHandler()->loadInclude('update_test_description', 'install');
$updates = update_get_update_list();
$expected = [
'pending' => [
8001 => '8001 - Update test of slash in description and/or.',
8002 => '8002 - Update test with multiline description, the quick brown fox jumped over the lazy dog.',
],
'start' => 8001,
];
$this->assertEquals($expected, $updates['update_test_description']);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment