Skip to content
Snippets Groups Projects
Verified Commit c5e63487 authored by Dave Long's avatar Dave Long
Browse files

Issue #3416074 by catch, longwave: UpdatePathTestBaseFilledTest is mostly pointless

parent d0677640
No related branches found
No related tags found
No related merge requests found
Showing with 76 additions and 55 deletions
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
* Create, view, edit, delete, and change shortcut links. * Create, view, edit, delete, and change shortcut links.
* *
* @group shortcut * @group shortcut
* @group #slow
*/ */
class ShortcutLinksTest extends ShortcutTestBase { class ShortcutLinksTest extends ShortcutTestBase {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* Tests low-level theme functions. * Tests low-level theme functions.
* *
* @group Theme * @group Theme
* @group #slow
*/ */
class ThemeTest extends BrowserTestBase { class ThemeTest extends BrowserTestBase {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Drupal\Tests\system\Functional\UpdateSystem; namespace Drupal\Tests\system\Functional\UpdateSystem;
use Drupal\FunctionalTests\Update\UpdatePathTestBaseTest; use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\user\Entity\User; use Drupal\user\Entity\User;
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
// cspell:ignore hola usuario // cspell:ignore hola usuario
/** /**
* Runs UpdatePathTestBaseTest with a dump filled with content. * Runs UpdatePathTestBase with a dump filled with content.
* *
* @group #slow * @group #slow
* @group Update * @group Update
*/ */
class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { class UpdatePathTestBaseFilledTest extends UpdatePathTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -26,8 +26,9 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { ...@@ -26,8 +26,9 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function setDatabaseDumpFiles() { protected function setDatabaseDumpFiles() {
parent::setDatabaseDumpFiles(); $this->databaseDumpFiles[] = __DIR__ . '/../../../../tests/fixtures/update/drupal-9.4.0.filled.standard.php.gz';
$this->databaseDumpFiles[0] = __DIR__ . '/../../../../tests/fixtures/update/drupal-9.4.0.filled.standard.php.gz'; $this->databaseDumpFiles[] = __DIR__ . '/../../../../tests/fixtures/update/drupal-8.update-test-schema-enabled.php';
$this->databaseDumpFiles[] = __DIR__ . '/../../../../tests/fixtures/update/drupal-8.update-test-semver-update-n-enabled.php';
} }
/** /**
...@@ -417,4 +418,11 @@ protected function replaceUser1() { ...@@ -417,4 +418,11 @@ protected function replaceUser1() {
// Do not replace the user from our dump. // Do not replace the user from our dump.
} }
/**
* Tests that the database was properly loaded.
*/
public function testDatabaseProperlyLoaded() {
$this->testDatabaseLoaded();
}
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* Tests load, save and delete for taxonomy terms. * Tests load, save and delete for taxonomy terms.
* *
* @group taxonomy * @group taxonomy
* @group #slow
*/ */
class TermTest extends TaxonomyTestBase { class TermTest extends TaxonomyTestBase {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* Tests the taxonomy index filter handler UI. * Tests the taxonomy index filter handler UI.
* *
* @group taxonomy * @group taxonomy
* @group #slow
* @see \Drupal\taxonomy\Plugin\views\field\TaxonomyIndexTid * @see \Drupal\taxonomy\Plugin\views\field\TaxonomyIndexTid
*/ */
class TaxonomyIndexTidUiTest extends UITestBase { class TaxonomyIndexTidUiTest extends UITestBase {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
* Tests the creation of telephone fields. * Tests the creation of telephone fields.
* *
* @group telephone * @group telephone
* @group #slow
*/ */
class TelephoneFieldTest extends BrowserTestBase { class TelephoneFieldTest extends BrowserTestBase {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
* Tests the creation of text fields. * Tests the creation of text fields.
* *
* @group text * @group text
* @group #slow
*/ */
class TextFieldTest extends StringFieldTest { class TextFieldTest extends StringFieldTest {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\FunctionalTests\Update; namespace Drupal\FunctionalTests\Update;
use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Html;
use Drupal\Core\Site\Settings; use Drupal\Core\Site\Settings;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
...@@ -241,4 +242,58 @@ protected function replaceUser1() { ...@@ -241,4 +242,58 @@ protected function replaceUser1() {
$account->save(); $account->save();
} }
/**
* Tests that the database was properly loaded.
*/
protected function testDatabaseLoaded() {
// Set a value in the cache to prove caches are cleared.
\Drupal::service('cache.default')->set(__CLASS__, 'Test');
/** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
$update_registry = \Drupal::service('update.update_hook_registry');
foreach (['user' => 9301, 'node' => 8700, 'system' => 8901, 'update_test_schema' => 8000] as $module => $schema) {
$this->assertEquals($schema, $update_registry->getInstalledVersion($module), "Module $module schema is $schema");
}
// Ensure that all {router} entries can be unserialized. If they cannot be
// unserialized a notice will be thrown by PHP.
$result = \Drupal::database()->select('router', 'r')
->fields('r', ['name', 'route'])
->execute()
->fetchAllKeyed(0, 1);
// For the purpose of fetching the notices and displaying more helpful error
// messages, let's override the error handler temporarily.
set_error_handler(function ($severity, $message, $filename, $lineno) {
throw new \ErrorException($message, 0, $severity, $filename, $lineno);
});
foreach ($result as $route_name => $route) {
try {
unserialize($route);
}
catch (\Exception $e) {
$this->fail(sprintf('Error "%s" while unserializing route %s', $e->getMessage(), Html::escape($route_name)));
}
}
restore_error_handler();
// Before accessing the site we need to run updates first or the site might
// be broken.
$this->runUpdates();
$this->assertEquals('standard', \Drupal::config('core.extension')->get('profile'));
$this->assertEquals('Site-Install', \Drupal::config('system.site')->get('name'));
$this->drupalGet('<front>');
$this->assertSession()->pageTextContains('Site-Install');
// Ensure that the database tasks have been run during set up. Neither MySQL
// nor SQLite make changes that are testable.
$database = $this->container->get('database');
if ($database->driver() == 'pgsql') {
$this->assertEquals('on', $database->query("SHOW standard_conforming_strings")->fetchField());
$this->assertEquals('escape', $database->query("SHOW bytea_output")->fetchField());
}
// Ensure the test runners cache has been cleared.
$this->assertFalse(\Drupal::service('cache.default')->get(__CLASS__));
}
} }
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
namespace Drupal\FunctionalTests\Update; namespace Drupal\FunctionalTests\Update;
use Drupal\Component\Utility\Html;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\Core\Site\Settings; use Drupal\Core\Site\Settings;
...@@ -31,55 +30,8 @@ protected function setDatabaseDumpFiles() { ...@@ -31,55 +30,8 @@ protected function setDatabaseDumpFiles() {
/** /**
* Tests that the database was properly loaded. * Tests that the database was properly loaded.
*/ */
public function testDatabaseLoaded() { public function testDatabaseProperlyLoaded() {
// Set a value in the cache to prove caches are cleared. $this->testDatabaseLoaded();
\Drupal::service('cache.default')->set(__CLASS__, 'Test');
/** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
$update_registry = \Drupal::service('update.update_hook_registry');
foreach (['user' => 9301, 'node' => 8700, 'system' => 8901, 'update_test_schema' => 8000] as $module => $schema) {
$this->assertEquals($schema, $update_registry->getInstalledVersion($module), "Module $module schema is $schema");
}
// Ensure that all {router} entries can be unserialized. If they cannot be
// unserialized a notice will be thrown by PHP.
$result = \Drupal::database()->select('router', 'r')
->fields('r', ['name', 'route'])
->execute()
->fetchAllKeyed(0, 1);
// For the purpose of fetching the notices and displaying more helpful error
// messages, let's override the error handler temporarily.
set_error_handler(function ($severity, $message, $filename, $lineno) {
throw new \ErrorException($message, 0, $severity, $filename, $lineno);
});
foreach ($result as $route_name => $route) {
try {
unserialize($route);
}
catch (\Exception $e) {
$this->fail(sprintf('Error "%s" while unserializing route %s', $e->getMessage(), Html::escape($route_name)));
}
}
restore_error_handler();
// Before accessing the site we need to run updates first or the site might
// be broken.
$this->runUpdates();
$this->assertEquals('standard', \Drupal::config('core.extension')->get('profile'));
$this->assertEquals('Site-Install', \Drupal::config('system.site')->get('name'));
$this->drupalGet('<front>');
$this->assertSession()->pageTextContains('Site-Install');
// Ensure that the database tasks have been run during set up. Neither MySQL
// nor SQLite make changes that are testable.
$database = $this->container->get('database');
if ($database->driver() == 'pgsql') {
$this->assertEquals('on', $database->query("SHOW standard_conforming_strings")->fetchField());
$this->assertEquals('escape', $database->query("SHOW bytea_output")->fetchField());
}
// Ensure the test runners cache has been cleared.
$this->assertFalse(\Drupal::service('cache.default')->get(__CLASS__));
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment