Commit ca69f969 authored by Luke Leber's avatar Luke Leber
Browse files

Issue #3300712 by Luke.Leber, bnh10, kjl16: Add support for Drupal 10; drop support for Drupal 8

parent c8019681
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -12,6 +12,6 @@
    }
  ],
  "require": {
    "drupal/core": "^8.8 || ^9"
    "drupal/core": "^9.3 || ^10"
  }
}
+1 −1
Original line number Diff line number Diff line
@@ -3,6 +3,6 @@ description: Conditionally adds Google Optimize to certain pages via optimize.js
package: A/B Testing
configure: google_optimize_js.settings
type: module
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^9.3 || ^10
dependencies:
  - drupal:path_alias
+8 −8
Original line number Diff line number Diff line
@@ -30,12 +30,12 @@ class SettingsFormTest extends BrowserTestBase {

    // Ensure that anonymous users are denied access.
    $this->drupalGet('/admin/config/system/google_optimize');
    $this->assertResponse(403);
    $this->assertSession()->statusCodeEquals(403);

    // Ensure that authenticated users without permission are denied access.
    $this->drupalLogin($this->drupalCreateUser());
    $this->drupalGet('/admin/config/system/google_optimize');
    $this->assertResponse(403);
    $this->assertSession()->statusCodeEquals(403);
  }

  /**
@@ -46,7 +46,7 @@ class SettingsFormTest extends BrowserTestBase {

    // Ensure that authorized users are allowed access.
    $this->drupalGet('/admin/config/system/google_optimize');
    $this->assertResponse(200);
    $this->assertSession()->statusCodeEquals(200);

    $edit = [
      'container' => '"</script><script>alert("XSS!");</script>',
@@ -57,8 +57,8 @@ class SettingsFormTest extends BrowserTestBase {
      'datalayer_js_weight' => 1,
    ];

    $this->drupalPostForm(NULL, $edit, 'Save configuration');
    $this->assertText('Container Id field is not in the right format.');
    $this->submitForm($edit, 'Save configuration');
    $this->assertSession()->pageTextContains('Container Id field is not in the right format.');

    // Fill out the form.
    $edit = [
@@ -71,17 +71,17 @@ class SettingsFormTest extends BrowserTestBase {
      'loading_strategy' => 'asynchronous',
    ];

    $this->drupalPostForm(NULL, $edit, 'Save configuration');
    $this->submitForm($edit, 'Save configuration');

    $config = $this->config('google_optimize_js.settings');
    foreach ($edit as $k => $v) {

      // Assert the value on the form has updated.
      $form_element = $this->getSession()->getPage()->findField($k);
      $this->assertEqual($form_element->getValue(), $v);
      $this->assertEquals($form_element->getValue(), $v);

      // Assert that configuration has updated.
      $this->assertEqual($config->get($k), $v);
      $this->assertEquals($config->get($k), $v);
    }
  }

+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ class UpdateTest extends UpdatePathTestBase {
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
  protected function setUp(): void {
    parent::setUp();
    $this->configFactory = $this->container->get('config.factory');
  }
@@ -42,7 +42,7 @@ class UpdateTest extends UpdatePathTestBase {
   */
  protected function setDatabaseDumpFiles() {
    $this->databaseDumpFiles = [
      static::getDrupalRoot() . '/core/modules/system/tests/fixtures/update/drupal-9.0.0.bare.standard.php.gz',
      static::getDrupalRoot() . '/core/modules/system/tests/fixtures/update/drupal-9.3.0.bare.standard.php.gz',
      __DIR__ . '/../../fixtures/google_optimize_js.update-hook-test.php',
    ];
  }
+3 −7
Original line number Diff line number Diff line
@@ -52,19 +52,15 @@ class InclusionTest extends KernelTestBase {
  /**
   * {@inheritDoc}
   */
  public function setUp() {
  public function setUp(): void {
    parent::setUp();
    $this->installConfig('google_optimize_js');

    $this->currentPathStack = $this->getMockBuilder(CurrentPathStack::class)
      ->disableOriginalConstructor()
      ->getMock();
    $this->currentPathStack = $this->createMock(CurrentPathStack::class);

    $this->container->set('path.current', $this->currentPathStack);

    $this->adminContext = $this->getMockBuilder(AdminContext::class)
      ->disableOriginalConstructor()
      ->getMock();
    $this->adminContext = $this->createMock(AdminContext::class);

    $this->container->set('router.admin_context', $this->adminContext);