Commit ec41d082 authored by alexpott's avatar alexpott

Issue #2558247 by dawehner, catch, mradcliffe, jhedstrom, Berdir, jibran,...

Issue #2558247 by dawehner, catch, mradcliffe, jhedstrom, Berdir, jibran, effulgentsia, webchick: Remove rebuildAll() and module install from UpdatePathTestBase
parent b049dd6f
...@@ -166,8 +166,9 @@ public function __call($method, array $args) { ...@@ -166,8 +166,9 @@ public function __call($method, array $args) {
* Serializes the Extension object in the most optimized way. * Serializes the Extension object in the most optimized way.
*/ */
public function serialize() { public function serialize() {
// Don't serialize the app root, since this could change if the install is
// moved.
$data = array( $data = array(
'root' => $this->root,
'type' => $this->type, 'type' => $this->type,
'pathname' => $this->pathname, 'pathname' => $this->pathname,
'filename' => $this->filename, 'filename' => $this->filename,
...@@ -188,7 +189,8 @@ public function serialize() { ...@@ -188,7 +189,8 @@ public function serialize() {
*/ */
public function unserialize($data) { public function unserialize($data) {
$data = unserialize($data); $data = unserialize($data);
$this->root = $data['root']; // Get the app root from the container.
$this->root = DRUPAL_ROOT;
$this->type = $data['type']; $this->type = $data['type'];
$this->pathname = $data['pathname']; $this->pathname = $data['pathname'];
$this->filename = $data['filename']; $this->filename = $data['filename'];
......
...@@ -32,6 +32,8 @@ protected function setDatabaseDumpFiles() { ...@@ -32,6 +32,8 @@ protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [ $this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz', __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php', __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php',
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.language-enabled.php',
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.block-test-enabled.php',
]; ];
} }
......
...@@ -228,7 +228,8 @@ protected function info(Request $request) { ...@@ -228,7 +228,8 @@ protected function info(Request $request) {
'#type' => 'link', '#type' => 'link',
'#title' => $this->t('Continue'), '#title' => $this->t('Continue'),
'#attributes' => array('class' => array('button', 'button--primary')), '#attributes' => array('class' => array('button', 'button--primary')),
'#url' => Url::fromUri($request->getUriForPath('/selection')), // @todo Revisit once https://www.drupal.org/node/2548095 is in.
'#url' => Url::fromUri('base://selection'),
); );
return $build; return $build;
} }
...@@ -484,6 +485,9 @@ protected function results(Request $request) { ...@@ -484,6 +485,9 @@ protected function results(Request $request) {
*/ */
public function requirements($severity, array $requirements, Request $request) { public function requirements($severity, array $requirements, Request $request) {
$options = $severity == REQUIREMENT_WARNING ? array('continue' => 1) : array(); $options = $severity == REQUIREMENT_WARNING ? array('continue' => 1) : array();
// @todo Revisit once https://www.drupal.org/node/2548095 is in. Something
// like Url::fromRoute('system.db_update')->setOptions() should then be
// possible.
$try_again_url = Url::fromUri($request->getUriForPath(''))->setOptions(['query' => $options])->toString(TRUE)->getGeneratedUrl(); $try_again_url = Url::fromUri($request->getUriForPath(''))->setOptions(['query' => $options])->toString(TRUE)->getGeneratedUrl();
$build['status_report'] = array( $build['status_report'] = array(
...@@ -580,7 +584,8 @@ protected function triggerBatch(Request $request) { ...@@ -580,7 +584,8 @@ protected function triggerBatch(Request $request) {
); );
batch_set($batch); batch_set($batch);
return batch_process(Url::fromUri($request->getUriForPath('/results')), Url::fromUri($request->getUriForPath('/start'))); // @todo Revisit once https://www.drupal.org/node/2548095 is in.
return batch_process(Url::fromUri('base://results'), Url::fromUri('base://start'));
} }
/** /**
......
...@@ -179,16 +179,15 @@ protected function setUp() { ...@@ -179,16 +179,15 @@ protected function setUp() {
// Add the config directories to settings.php. // Add the config directories to settings.php.
drupal_install_config_directories(); drupal_install_config_directories();
// Install any additional modules.
$this->installModulesFromClassProperty($container);
// Restore the original Simpletest batch. // Restore the original Simpletest batch.
$this->restoreBatch(); $this->restoreBatch();
// Rebuild and reset. // Set the container. parent::rebuildAll() would normally do this, but this
$this->rebuildAll(); // not safe to do here, because the database has not been updated yet.
$this->container = \Drupal::getContainer();
// Replace User 1 with the user created here. // Replace User 1 with the user created here.
// @todo: do this without saving the user account.
/** @var \Drupal\user\UserInterface $account */ /** @var \Drupal\user\UserInterface $account */
$account = User::load(1); $account = User::load(1);
$account->setPassword($this->rootUser->pass_raw); $account->setPassword($this->rootUser->pass_raw);
...@@ -267,25 +266,4 @@ protected function runUpdates() { ...@@ -267,25 +266,4 @@ protected function runUpdates() {
$this->assertFalse(\Drupal::service('entity.definition_update_manager')->needsUpdates(), 'After all updates ran, entity schema is up to date.'); $this->assertFalse(\Drupal::service('entity.definition_update_manager')->needsUpdates(), 'After all updates ran, entity schema is up to date.');
} }
/**
* {@inheritdoc}
*/
protected function rebuildAll() {
// We know the rebuild causes notices, so don't exit on failure.
$die_on_fail = $this->dieOnFail;
$this->dieOnFail = FALSE;
parent::rebuildAll();
// Remove the notices we get due to the menu link rebuild prior to running
// the system updates for the schema change.
foreach ($this->assertions as $key => $assertion) {
if ($assertion['message_group'] == 'Notice' && basename($assertion['file']) == 'MenuTreeStorage.php' && strpos($assertion['message'], 'unserialize(): Error at offset 0') !== FALSE) {
unset($this->assertions[$key]);
$this->deleteAssert($assertion['message_id']);
$this->results['#exception']--;
}
}
$this->dieOnFail = $die_on_fail;
}
} }
...@@ -18,6 +18,7 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { ...@@ -18,6 +18,7 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function setDatabaseDumpFiles() { protected function setDatabaseDumpFiles() {
parent::setDatabaseDumpFiles();
$this->databaseDumpFiles[0] = __DIR__ . '/../../../tests/fixtures/update/drupal-8.filled.standard.php.gz'; $this->databaseDumpFiles[0] = __DIR__ . '/../../../tests/fixtures/update/drupal-8.filled.standard.php.gz';
} }
......
...@@ -25,7 +25,10 @@ class UpdatePathTestBaseTest extends UpdatePathTestBase { ...@@ -25,7 +25,10 @@ class UpdatePathTestBaseTest extends UpdatePathTestBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function setDatabaseDumpFiles() { protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [__DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz']; $this->databaseDumpFiles = [
__DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../tests/fixtures/update/drupal-8.update-test-schema-enabled.php',
];
} }
/** /**
......
...@@ -241,7 +241,7 @@ function system_theme_suggestions_html(array $variables) { ...@@ -241,7 +241,7 @@ function system_theme_suggestions_html(array $variables) {
$path_args = ['']; $path_args = [''];
} }
else { else {
$path_args = explode('/', Url::fromRoute('<current>')->getInternalPath()); $path_args = explode('/', ltrim(\Drupal::service('path.current')->getPath(), '/'));
} }
return theme_get_suggestions($path_args, 'html'); return theme_get_suggestions($path_args, 'html');
} }
......
<?php
/**
* @file
* Partial database to mimic the installation of the block_test module.
*/
use Drupal\Core\Database\Database;
use Symfony\Component\Yaml\Yaml;
$connection = Database::getConnection();
// Set the schema version.
$connection->insert('key_value')
->fields([
'collection' => 'system.schema',
'name' => 'block_test',
'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']['block_test'] = 8000;
$connection->update('config')
->fields([
'data' => serialize($extensions),
])
->condition('collection', '')
->condition('name', 'core.extension')
->execute();
// Install the block configuration.
$config = file_get_contents(__DIR__ . '/../../../../block/tests/modules/block_test/config/install/block.block.test_block.yml');
$config = Yaml::parse($config);
$connection->insert('config')
->fields(['data', 'name', 'collection'])
->values([
'name' => 'block.block.test_block',
'data' => serialize($config),
'collection' => '',
])
->execute();
<?php
/**
* @file
* Partial database to mimic the installation of the update_test_schema module.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Create the table.
$connection->schema()->createTable('update_test_schema_table', array(
'fields' => array(
'a' => array(
'type' => 'int',
'not null' => TRUE,
'size' => 'normal',
),
'b' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'normal',
),
),
));
// Set the schema version.
$connection->merge('key_value')
->condition('collection', 'system.schema')
->condition('name', 'update_test_schema')
->fields([
'collection' => 'system.schema',
'name' => 'update_test_schema',
'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_schema'] = 8000;
$connection->update('config')
->fields([
'data' => serialize($extensions),
])
->condition('collection', '')
->condition('name', 'core.extension')
->execute();
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