Commit 90661969 authored by catch's avatar catch
Browse files

Issue #3178998 by alexpott, andypost: Update error types and messages for PHP 8

parent b34bb87f
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -111,7 +111,9 @@ public function testUncaughtException() {
  public function testUncaughtFatalError() {
    $fatal_error = [
      '%type' => 'TypeError',
      '@message' => 'Argument 1 passed to Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}() must be of the type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 65',
      '@message' => PHP_VERSION_ID >= 80000 ?
        'Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}(): Argument #1 ($test) must be of type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 65' :
        'Argument 1 passed to Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}() must be of the type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 65',
      '%function' => 'Drupal\error_test\Controller\ErrorTestController->Drupal\error_test\Controller\{closure}()',
    ];
    $this->drupalGet('error-test/generate-fatals');
@@ -198,7 +200,9 @@ public function testErrorContainer() {
    $this->writeSettings($settings);
    \Drupal::service('kernel')->invalidateContainer();

    $this->expectedExceptionMessage = 'Argument 1 passed to Drupal\FunctionalTests\Bootstrap\ErrorContainer::Drupal\FunctionalTests\Bootstrap\{closur';
    $this->expectedExceptionMessage = PHP_VERSION_ID >= 80000 ?
      'Drupal\FunctionalTests\Bootstrap\ErrorContainer::Drupal\FunctionalTests\Bootstrap\{closure}(): Argument #1 ($container) must be of type Drupal\FunctionalTests\Bootstrap\ErrorContainer' :
      'Argument 1 passed to Drupal\FunctionalTests\Bootstrap\ErrorContainer::Drupal\FunctionalTests\Bootstrap\{closur';
    $this->drupalGet('');
    $this->assertResponse(500);

+2 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
use Drupal\KernelTests\KernelTestBase;
use Drupal\TestTools\Comparator\MarkupInterfaceComparator;
use PHPUnit\Framework\Error\Notice;
use PHPUnit\Framework\Error\Warning;
use SebastianBergmann\Comparator\Factory;
use SebastianBergmann\Comparator\ComparisonFailure;

@@ -108,7 +109,7 @@ public function dataSetProvider() {
        new FormattableMarkup('goldfinger', []),
        ['goldfinger'],
        FALSE,
        Notice::class,
        PHP_VERSION_ID >= 80000 ? Warning::class : Notice::class,
      ],
      'stdClass vs TranslatableMarkup' => [
        (object) ['goldfinger'],
+1 −1
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ public function testSetIllegalOffsetValue() {
    $this->config->set('testData', 1);

    // Attempt to treat the single value as a nested item.
    $this->expectException(Warning::class);
    $this->expectException(PHP_VERSION_ID >= 80000 ? \Error::class : Warning::class);
    $this->config->set('testData.illegalOffset', 1);
  }

+24 −6
Original line number Diff line number Diff line
@@ -56,8 +56,14 @@ protected function setUp(): void {
   */
  public function testOptionsDeprecated() {
    $this->expectDeprecation('Drupal\Core\Routing\CompiledRoute::getOptions() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3159706');
    if (PHP_VERSION_ID >= 80000) {
      $this->expectWarning();
      $this->expectWarningMessage('Undefined property: Drupal\Core\Routing\CompiledRoute::$route');
    }
    else {
      $this->expectNotice();
      $this->expectNoticeMessage('Undefined property: Drupal\Core\Routing\CompiledRoute::$route');
    }
    $this->compiled_route->getOptions();
  }

@@ -79,8 +85,14 @@ public function testOptionsDynamicallySet() {
   */
  public function testDefaultsDeprecated() {
    $this->expectDeprecation('Drupal\Core\Routing\CompiledRoute::getDefaults() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3159706');
    if (PHP_VERSION_ID >= 80000) {
      $this->expectWarning();
      $this->expectWarningMessage('Undefined property: Drupal\Core\Routing\CompiledRoute::$route');
    }
    else {
      $this->expectNotice();
      $this->expectNoticeMessage('Undefined property: Drupal\Core\Routing\CompiledRoute::$route');
    }
    $this->compiled_route->getDefaults();
  }

@@ -100,8 +112,14 @@ public function testDefaultsDynamicallySet() {
   */
  public function testRequirementsDeprecated() {
    $this->expectDeprecation('Drupal\Core\Routing\CompiledRoute::getRequirements() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3159706');
    if (PHP_VERSION_ID >= 80000) {
      $this->expectWarning();
      $this->expectWarningMessage('Undefined property: Drupal\Core\Routing\CompiledRoute::$route');
    }
    else {
      $this->expectNotice();
      $this->expectNoticeMessage('Undefined property: Drupal\Core\Routing\CompiledRoute::$route');
    }
    $this->compiled_route->getRequirements();
  }