Commit 41c08aea authored by Luke Leber's avatar Luke Leber
Browse files

Issue #3260846 by Luke.Leber: Update hook missing in HEAD for new option defaults

parent 6f6279fd
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Contains post update functions for Inline All CSS.
 */

/**
 * Ensure that module behavior does not change from the RC2 release.
 */
function inline_all_css_post_update_retain_rc2_state() {
  \Drupal::configFactory()
    ->getEditable('inline_all_css.settings')
    ->set('enabled', TRUE)
    ->save();
}
+38 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Sets up the database state for the upgrade path tests.
 */

use Drupal\Core\Database\Database;

$connection = Database::getConnection();

// Set the schema version.
$connection->merge('key_value')
  ->condition('collection', 'system.schema')
  ->condition('name', 'inline_all_css')
  ->fields([
    'collection' => 'system.schema',
    'name' => 'inline_all_css',
    'value' => 's:4:"9000";',
  ])
  ->execute();

// Add the proper core.extension configuration.
$extensions = $connection->select('config')
  ->fields('config', ['data'])
  ->condition('collection', '')
  ->condition('name', 'core.extension')
  ->execute()
  ->fetchField();
$extensions = unserialize($extensions, ['allowed_classes' => []]);
$extensions['module']['inline_all_css'] = 9000;
$connection->update('config')
  ->fields([
    'data' => serialize($extensions),
  ])
  ->condition('collection', '')
  ->condition('name', 'core.extension')
  ->execute();
+61 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\inline_all_css\Functional;

use Drupal\FunctionalTests\Update\UpdatePathTestBase;

/**
 * Test cases for the incremental upgrade path.
 *
 * @group inline_all_css
 */
class PostUpdateTest extends UpdatePathTestBase {

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * The config factory service.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->configFactory = $this->container->get('config.factory');
  }

  /**
   * {@inheritdoc}
   */
  protected function setDatabaseDumpFiles() {
    $this->databaseDumpFiles = [
      DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-9.0.0.bare.standard.php.gz',
      __DIR__ . '/../../fixtures/update/inline_all_css.update-hook-test.php',
    ];
  }

  /**
   * {@inheritdoc}
   */
  protected function doSelectionTest() {
    parent::doSelectionTest();
    $this->assertSession()->responseContains('Ensure that module behavior does not change from the RC2 release.');
  }

  /**
   * Test case for the upgrade path.
   */
  public function testUpgrade() {
    static::assertArrayNotHasKey('inline_all_css.settings', $this->configFactory->listAll());
    $this->runUpdates();
    static::assertTrue($this->config('inline_all_css.settings')->get('enabled'));
  }

}
+0 −3
Original line number Diff line number Diff line
@@ -173,9 +173,6 @@ CSS

  /**
   * Sets up the CSS to add in the dispatched event.
   *
   * @param string $css
   *   The CSS to add.
   */
  protected function setEventCss() {
    $this->eventDispatcher->method('dispatch')