Commit 6c97da66 authored by catch's avatar catch
Browse files

Issue #3261266 by mondrake, longwave, daffie: Remove deprecated code from the...

Issue #3261266 by mondrake, longwave, daffie: Remove deprecated code from the testing framework (base classes, listeners, etc)
parent 0be587c4
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
@@ -670,20 +670,6 @@ public function testEscapingAssertions() {
    $assert->assertNoEscaped("<script>alert('Marked safe');alert(\"Marked safe\");</script>");
  }

  /**
   * Tests deprecation of drupalPostForm().
   *
   * @group legacy
   */
  public function testLegacyDrupalPostForm(): void {
    $this->expectDeprecation('UiHelperTrait::drupalPostForm() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use $this->submitForm() instead. See https://www.drupal.org/node/3168858');
    $this->expectDeprecation('Calling Drupal\Tests\UiHelperTrait::drupalPostForm() with $submit as an object is deprecated in drupal:9.2.0 and the method is removed in drupal:10.0.0. Use $this->submitForm() instead. See https://www.drupal.org/node/3168858');
    $this->expectDeprecation('Calling Drupal\Tests\UiHelperTrait::drupalPostForm() with $edit set to NULL is deprecated in drupal:9.1.0 and the method is removed in drupal:10.0.0. Use $this->submitForm() instead. See https://www.drupal.org/node/3168858');
    $this->drupalPostForm('form-test/object-builder', NULL, t('Save'));
    $this->expectDeprecation('Calling Drupal\Tests\UiHelperTrait::drupalPostForm() with $path set to NULL is deprecated in drupal:9.2.0 and the method is removed in drupal:10.0.0. Use $this->submitForm() instead. See https://www.drupal.org/node/3168858');
    $this->drupalPostForm(NULL, [], 'Save');
  }

  /**
   * Tests that deprecation headers do not get duplicated.
   *
@@ -715,17 +701,6 @@ public function testDeprecationHeaders() {
    $this->assertCount(1, $test_deprecation_messages);
  }

  /**
   * Tests legacy drupalGetHeader().
   *
   * @group legacy
   */
  public function testDrupalGetHeader() {
    $this->expectDeprecation('BrowserTestBase::drupalGetHeader() is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use $this->getSession()->getResponseHeader() instead. See https://www.drupal.org/node/3168383');
    $this->drupalGet('test-page');
    $this->drupalGetHeader('Content-Type');
  }

  /**
   * Tests the dump() function provided by the var-dumper Symfony component.
   */
+0 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
use Drupal\Core\TypedData\Plugin\DataType\StringData;
use Drupal\Core\TypedData\TypedDataManagerInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\Traits\ExpectDeprecationTrait;

/**
 * @coversDefaultClass \Drupal\Core\Plugin\ContextAwarePluginTrait
@@ -26,8 +25,6 @@
 */
class ContextAwarePluginTraitTest extends KernelTestBase {

  use ExpectDeprecationTrait;

  /**
   * The plugin instance under test.
   *
+0 −7
Original line number Diff line number Diff line
@@ -733,13 +733,6 @@ protected function installSchema($module, $tables) {
    $schema = $this->container->get('database')->schema();
    $tables = (array) $tables;
    foreach ($tables as $table) {
      // The tables key_value and key_value_expire are lazy loaded and therefore
      // no longer have to be created with the installSchema() method.
      // @see https://www.drupal.org/node/3143286
      if ($module === 'system' && in_array($table, ['key_value', 'key_value_expire'])) {
        @trigger_error('Installing the tables key_value and key_value_expire with the method KernelTestBase::installSchema() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. The tables are now lazy loaded and therefore will be installed automatically when used. See https://www.drupal.org/node/3143286', E_USER_DEPRECATED);
        continue;
      }
      if (empty($specification[$table])) {
        throw new \LogicException("$module module does not define a schema for table '$table'.");
      }
+0 −12
Original line number Diff line number Diff line
@@ -339,18 +339,6 @@ public function testProfileModules() {
    );
  }

  /**
   * Tests the deprecation of ::installSchema with the tables key_value(_expire).
   *
   * @group legacy
   */
  public function testKernelTestBaseInstallSchema() {
    $this->expectDeprecation('Installing the tables key_value and key_value_expire with the method KernelTestBase::installSchema() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. The tables are now lazy loaded and therefore will be installed automatically when used. See https://www.drupal.org/node/3143286');
    $this->enableModules(['system']);
    $this->installSchema('system', ['key_value', 'key_value_expire']);
    $this->assertFalse(Database::getConnection()->schema()->tableExists('key_value'));
  }

  /**
   * Tests the dump() function provided by the var-dumper Symfony component.
   */
+0 −48
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests;

use Drupal\Component\Render\MarkupInterface;

@trigger_error(__NAMESPACE__ . '\AssertHelperTrait is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3123638', E_USER_DEPRECATED);

/**
 * Provides helper methods for assertions.
 *
 * @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no
 *   replacement.
 *
 * @see https://www.drupal.org/node/3123638
 */
trait AssertHelperTrait {

  /**
   * Casts MarkupInterface objects into strings.
   *
   * @param string|array $value
   *   The value to act on.
   *
   * @return mixed
   *   The input value, with MarkupInterface objects casted to string.
   *
   * @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no
   *   replacement, just use assertEquals in tests.
   *
   * @see https://www.drupal.org/node/3123638
   */
  protected static function castSafeStrings($value) {
    @trigger_error('AssertHelperTrait::castSafeStrings() is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no replacement; assertEquals() will automatically cast MarkupInterface to strings when needed. See https://www.drupal.org/node/3123638', E_USER_DEPRECATED);
    if ($value instanceof MarkupInterface) {
      $value = (string) $value;
    }
    if (is_array($value)) {
      array_walk_recursive($value, function (&$item) {
        if ($item instanceof MarkupInterface) {
          $item = (string) $item;
        }
      });
    }
    return $value;
  }

}
Loading