3 namespace Drupal\system\Tests\Update;
5 @trigger_error(__NAMESPACE__ . '\DbUpdatesTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\FunctionalTests\Update\DbUpdatesTrait instead. See https://www.drupal.org/node/2896640.', E_USER_DEPRECATED);
7 use Drupal\Core\StringTranslation\StringTranslationTrait;
11 * Provides methods to conditionally enable db update functions and apply
12 * pending db updates through the Update UI.
14 * This should be used only by classes extending \Drupal\simpletest\WebTestBase.
16 * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0.
17 * Use \Drupal\FunctionalTests\Update\DbUpdatesTrait.
18 * @see https://www.drupal.org/node/2896640
20 trait DbUpdatesTrait {
22 use StringTranslationTrait;
25 * Enables db updates until the specified index.
27 * @param string $module
28 * The name of the module defining the update functions.
29 * @param string $group
30 * A name identifying the group of update functions to enable.
32 * The index of the last update function to run.
34 protected function enableUpdates($module, $group, $index) {
35 $this->container->get('state')->set($module . '.db_updates.' . $group, $index);
39 * Applies any pending DB updates through the Update UI.
41 protected function applyUpdates() {
42 $this->drupalGet(Url::fromRoute('system.db_update'));
43 $this->clickLink($this->t('Continue'));
44 $this->clickLink($this->t('Apply pending updates'));
48 * Conditionally load Update API functions for the specified group.
50 * @param string $module
51 * The name of the module defining the update functions.
52 * @param string $group
53 * A name identifying the group of update functions to enable.
55 public static function includeUpdates($module, $group) {
56 if ($index = \Drupal::state()->get($module . '.db_updates.' . $group)) {
57 module_load_include('inc', $module, 'update/' . $group . '_' . $index);