Issue #3102059 by alexpott, Berdir, longwave: Make tests of the update system use UpdatePathTestTrait instead of UpdatePathTestBase
parent
677f9d42d8
commit
5c832d2e3e
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Simulate an entity type that had previously set an initial key schema for a
|
||||
// field.
|
||||
$schema = $connection->select('key_value')
|
||||
->fields('key_value', ['value'])
|
||||
->condition('collection', 'entity.storage_schema.sql')
|
||||
->condition('name', 'entity_test_update.field_schema_data.name')
|
||||
->execute()
|
||||
->fetchField();
|
||||
|
||||
$schema = unserialize($schema);
|
||||
$schema['entity_test_update']['fields']['name']['initial'] = 'test';
|
||||
|
||||
$connection->update('key_value')
|
||||
->fields(['value' => serialize($schema)])
|
||||
->condition('collection', 'entity.storage_schema.sql')
|
||||
->condition('name', 'entity_test_update.field_schema_data.name')
|
||||
->execute();
|
|
@ -3,3 +3,5 @@ type: module
|
|||
description: 'Provides an entity type for testing definition and schema updates.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
dependencies:
|
||||
- drupal:field
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace Drupal\Tests\system\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\Tests\UpdatePathTestTrait;
|
||||
|
||||
/**
|
||||
* Tests handling of existing initial keys during updates.
|
||||
|
@ -10,9 +12,9 @@ use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
|||
* @see https://www.drupal.org/project/drupal/issues/2925550
|
||||
*
|
||||
* @group Update
|
||||
* @group legacy
|
||||
*/
|
||||
class EntityUpdateInitialTest extends UpdatePathTestBase {
|
||||
class EntityUpdateInitialTest extends BrowserTestBase {
|
||||
use UpdatePathTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -22,11 +24,33 @@ class EntityUpdateInitialTest extends UpdatePathTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../fixtures/update/drupal-8.0.0-rc1-filled.standard.entity_test_update.php.gz',
|
||||
__DIR__ . '/../../../fixtures/update/drupal-8.entity-test-initial.php',
|
||||
];
|
||||
protected static $modules = ['entity_test_update'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->ensureUpdatesToRun();
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Simulate an entity type that had previously set an initial key schema for
|
||||
// a field.
|
||||
$schema = $connection->select('key_value')
|
||||
->fields('key_value', ['value'])
|
||||
->condition('collection', 'entity.storage_schema.sql')
|
||||
->condition('name', 'entity_test_update.field_schema_data.name')
|
||||
->execute()
|
||||
->fetchField();
|
||||
|
||||
$schema = unserialize($schema);
|
||||
$schema['entity_test_update']['fields']['name']['initial'] = 'test';
|
||||
|
||||
$connection->update('key_value')
|
||||
->fields(['value' => serialize($schema)])
|
||||
->condition('collection', 'entity.storage_schema.sql')
|
||||
->condition('name', 'entity_test_update.field_schema_data.name')
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\system\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
|
||||
/**
|
||||
* Runs UpdatePathWithBrokenRoutingTest with a dump filled with content.
|
||||
*
|
||||
* @group Update
|
||||
* @group legacy
|
||||
*/
|
||||
class UpdatePathWithBrokenRoutingFilledTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../tests/fixtures/update/drupal-8.8.0.filled.standard.php.gz',
|
||||
__DIR__ . '/../../../../tests/fixtures/update/drupal-8.broken_routing.php',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests running update.php with some form of broken routing.
|
||||
*/
|
||||
public function testWithBrokenRouting() {
|
||||
// Simulate a broken router, and make sure the front page is
|
||||
// inaccessible.
|
||||
\Drupal::state()->set('update_script_test_broken_inbound', TRUE);
|
||||
\Drupal::service('cache_tags.invalidator')->invalidateTags(['route_match', 'rendered']);
|
||||
$this->drupalGet('<front>');
|
||||
$this->assertResponse(500);
|
||||
|
||||
$this->runUpdates();
|
||||
|
||||
// Remove the simulation of the broken router, and make sure we can get to
|
||||
// the front page again.
|
||||
\Drupal::state()->set('update_script_test_broken_inbound', FALSE);
|
||||
$this->drupalGet('<front>');
|
||||
$this->assertResponse(200);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\workspaces\Functional\Update;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\Tests\UpdatePathTestTrait;
|
||||
|
||||
/**
|
||||
* Tests that there is no active workspace during database updates.
|
||||
*
|
||||
* @group workspaces
|
||||
* @group Update
|
||||
*/
|
||||
class ActiveWorkspaceUpdateTest extends BrowserTestBase {
|
||||
use UpdatePathTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = ['workspaces', 'workspace_update_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
// Ensure the workspace_update_test_post_update_check_active_workspace()
|
||||
// update runs.
|
||||
$existing_updates = \Drupal::keyValue('post_update')->get('existing_updates', []);
|
||||
$index = array_search('workspace_update_test_post_update_check_active_workspace', $existing_updates);
|
||||
unset($existing_updates[$index]);
|
||||
\Drupal::keyValue('post_update')->set('existing_updates', $existing_updates);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that there is no active workspace during database updates.
|
||||
*/
|
||||
public function testActiveWorkspaceDuringUpdate() {
|
||||
/** @var \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager */
|
||||
$workspace_manager = \Drupal::service('workspaces.manager');
|
||||
|
||||
// Check that we have an active workspace before running the updates.
|
||||
$this->assertTrue($workspace_manager->hasActiveWorkspace());
|
||||
$this->assertEquals('test', $workspace_manager->getActiveWorkspace()->id());
|
||||
|
||||
$this->runUpdates();
|
||||
|
||||
// Check that we didn't have an active workspace while running the updates.
|
||||
// @see workspace_update_test_post_update_check_active_workspace()
|
||||
$this->assertFalse(\Drupal::state()->get('workspace_update_test.has_active_workspace'));
|
||||
|
||||
// Check that we have an active workspace after running the updates.
|
||||
$workspace_manager = \Drupal::service('workspaces.manager');
|
||||
$this->assertTrue($workspace_manager->hasActiveWorkspace());
|
||||
$this->assertEquals('test', $workspace_manager->getActiveWorkspace()->id());
|
||||
}
|
||||
|
||||
}
|
|
@ -127,28 +127,6 @@ class WorkspacesUpdateTest extends UpdatePathTestBase {
|
|||
$this->assertNull($form_display->getComponent('parent'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that there is no active workspace during database updates.
|
||||
*/
|
||||
public function testActiveWorkspaceDuringUpdate() {
|
||||
/** @var \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager */
|
||||
$workspace_manager = \Drupal::service('workspaces.manager');
|
||||
|
||||
// Check that we have an active workspace before running the updates.
|
||||
$this->assertTrue($workspace_manager->hasActiveWorkspace());
|
||||
$this->assertEquals('test', $workspace_manager->getActiveWorkspace()->id());
|
||||
|
||||
$this->runUpdates();
|
||||
|
||||
// Check that we didn't have an active workspace while running the updates.
|
||||
// @see workspace_update_test_post_update_check_active_workspace()
|
||||
$this->assertFalse(\Drupal::state()->get('workspace_update_test.has_active_workspace'));
|
||||
|
||||
// Check that we have an active workspace after running the updates.
|
||||
$this->assertTrue($workspace_manager->hasActiveWorkspace());
|
||||
$this->assertEquals('test', $workspace_manager->getActiveWorkspace()->id());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue