class UpdatePostUpdateExceptionTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateExceptionTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePostUpdateExceptionTest
Tests hook_post_update() when there is an exception in a post update.
@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\UpdatePostUpdateExceptionTest uses \Drupal\Tests\UpdatePathTestTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of UpdatePostUpdateExceptionTest
File
-
core/
modules/ system/ tests/ src/ Functional/ UpdateSystem/ UpdatePostUpdateExceptionTest.php, line 14
Namespace
Drupal\Tests\system\Functional\UpdateSystemView source
class UpdatePostUpdateExceptionTest 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('post_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']['post_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();
$this->assertSession()
->pageTextContains('Failed: RuntimeException: This post update fails in post_update_test_failing_post_update_exception()');
}
/**
* {@inheritdoc}
*/
protected function doSelectionTest() {
$this->assertSession()
->assertEscaped("Post update that throws an exception.");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.