Commit a1a86c91 authored by catch's avatar catch
Browse files

Issue #3447307 by longwave, catch, quietone: Remove remaining deprecated code from Drupal 11

(cherry picked from commit 5f69735b)
parent 932ef94e
Loading
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -18,20 +18,19 @@ class AjaxWaitTest extends WebDriverTestBase {
  protected $defaultTheme = 'starterkit_theme';

  /**
   * Tests that an unnecessary wait triggers a deprecation error.
   * Tests that an unnecessary wait triggers an error.
   */
  public function testUnnecessaryWait(): void {
    $this->drupalGet('user');

    $this->expectDeprecation("Drupal\FunctionalJavascriptTests\JSWebAssert::assertExpectedAjaxRequest called unnecessarily in a test is deprecated in drupal:10.2.0 and will throw an exception in drupal:11.0.0. See https://www.drupal.org/node/3401201");
    $this->expectException(\RuntimeException::class);
    $this->expectExceptionMessage('Unable to complete AJAX request.');
    $this->expectExceptionMessage('There are no AJAX requests to wait for.');

    $this->assertSession()->assertWaitOnAjaxRequest(500);
  }

  /**
   * Tests that an untracked XHR triggers a deprecation error.
   * Tests that an untracked XHR triggers an error.
   */
  public function testUntrackedXhr(): void {
    $this->getSession()->executeScript(<<<JS
+2 −2
Original line number Diff line number Diff line
@@ -100,9 +100,9 @@ function isAjaxing(instance) {
      $current_page_ajax_response_count = 0;
    }

    // Detect unnecessary AJAX request waits and inform the test author.
    // Detect unnecessary AJAX request waits.
    if ($drupal_ajax_request_count === $current_page_ajax_response_count) {
      @trigger_error(sprintf('%s called unnecessarily in a test is deprecated in drupal:10.2.0 and will throw an exception in drupal:11.0.0. See https://www.drupal.org/node/3401201', __METHOD__), E_USER_DEPRECATED);
      throw new \RuntimeException('There are no AJAX requests to wait for.');
    }

    // Detect untracked AJAX requests. This will alert if the detection is
+0 −5
Original line number Diff line number Diff line
@@ -142,11 +142,6 @@ protected function getMinkDriverArgs() {
      $json = getenv('MINK_DRIVER_ARGS_WEBDRIVER') ?: parent::getMinkDriverArgs();
      if (!($json === FALSE || $json === '')) {
        $args = json_decode($json, TRUE);
        if (isset($args[1]['chromeOptions'])) {
          @trigger_error('The "chromeOptions" array key is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use "goog:chromeOptions instead. See https://www.drupal.org/node/3422624', E_USER_DEPRECATED);
          $args[1]['goog:chromeOptions'] = $args[1]['chromeOptions'];
          unset($args[1]['chromeOptions']);
        }
        if (isset($args[0]) && $args[0] === 'chrome' && !isset($args[1]['goog:chromeOptions']['w3c'])) {
          // @todo https://www.drupal.org/project/drupal/issues/3421202
          //   Deprecate defaulting behavior and require w3c to be set.
+0 −11
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
use Drupal\Tests\Traits\Core\PathAliasTestTrait;
use Drupal\user\Entity\Role;
use PHPUnit\Framework\ExpectationFailedException;
use Symfony\Component\HttpFoundation\Request;

// cspell:ignore htkey

@@ -570,16 +569,6 @@ public function testSessionOnRequest(): void {
    $this->assertEquals('do-cleanup', $session->remove('some-other-val'));
  }

  /**
   * Tests deprecation of modified request stack lacking a session.
   *
   * @group legacy
   */
  public function testDeprecatedSessionMissing(): void {
    $this->expectDeprecation('Pushing requests without a session onto the request_stack is deprecated in drupal:10.3.0 and an error will be thrown from drupal:11.0.0. See https://www.drupal.org/node/3337193');
    $this->container->get('request_stack')->push(Request::create('/'));
  }

  /**
   * Tests that deprecation headers do not get duplicated.
   *
+4 −21
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@
use Drupal\TestTools\TestVarDumper;
use GuzzleHttp\Cookie\CookieJar;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
use Symfony\Component\VarDumper\VarDumper;

/**
@@ -377,17 +376,6 @@ protected function setUp(): void {
    $this->addToAssertionCount(1);
  }

  /**
   * {@inheritdoc}
   */
  public function __get(string $name) {
    if ($name === 'randomGenerator') {
      @trigger_error('Accessing the randomGenerator property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use getRandomGenerator() instead. See https://www.drupal.org/node/3358445', E_USER_DEPRECATED);

      return $this->getRandomGenerator();
    }
  }

  /**
   * Sets up the root application path.
   */
@@ -447,16 +435,11 @@ protected function tearDown(): void {

    if ($this->container) {
      // Cleanup mock session started in DrupalKernel::preHandle().
      try {
      /** @var \Symfony\Component\HttpFoundation\Session\Session $session */
      $session = $this->container->get('request_stack')->getSession();
      $session->clear();
      $session->save();
    }
      catch (SessionNotFoundException) {
        @trigger_error('Pushing requests without a session onto the request_stack is deprecated in drupal:10.3.0 and an error will be thrown from drupal:11.0.0. See https://www.drupal.org/node/3337193', E_USER_DEPRECATED);
      }
    }

    // Destroy the testing kernel.
    if (isset($this->kernel)) {
Loading