class UpdatePostUpdateFailingTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateFailingTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePostUpdateFailingTest
- 10 core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateFailingTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePostUpdateFailingTest
- 8.9.x core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateFailingTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePostUpdateFailingTest
Tests hook_post_update() when there are failing update hooks.
@group Update
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\UpdateSystem\UpdatePostUpdateFailingTest uses \Drupal\Tests\UpdatePathTestTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of UpdatePostUpdateFailingTest
File
-
core/
modules/ system/ tests/ src/ Functional/ UpdateSystem/ UpdatePostUpdateFailingTest.php, line 14
Namespace
Drupal\Tests\system\Functional\UpdateSystemView source
class UpdatePostUpdateFailingTest extends BrowserTestBase {
use UpdatePathTestTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$connection = Database::getConnection();
// Set the schema version.
\Drupal::service('update.update_hook_registry')->setInstalledVersion('update_test_failing', 8000);
// 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_failing'] = 8000;
$connection->update('config')
->fields([
'data' => serialize($extensions),
])
->condition('collection', '')
->condition('name', 'core.extension')
->execute();
}
/**
* Tests hook_post_update_NAME().
*/
public function testPostUpdate() {
// There are expected to be failed updates.
$this->checkFailedUpdates = FALSE;
$this->runUpdates();
// There should be no post update hooks registered as being run.
$this->assertSame([], \Drupal::state()->get('post_update_test_execution', []));
$key_value = \Drupal::keyValue('update__post_update');
$this->assertEquals([], $key_value->get('existing_updates', []));
}
/**
* {@inheritdoc}
*/
protected function doSelectionTest() {
// First update, should not be run since this module's update hooks fail.
$this->assertSession()
->responseContains('8001 - This update will fail.');
$this->assertSession()
->responseContains('8002 - A further update');
$this->assertSession()
->assertEscaped("First update, should not be run since this module's update hooks fail.");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.