From b5c980da18d3e1b4cf9c1c4354abb15bc5f520c1 Mon Sep 17 00:00:00 2001 From: Matt Glaman Date: Wed, 27 Sep 2023 14:52:21 -0500 Subject: [PATCH] Fix tests after drupal/core changes (#605) * Fix tests after drupal/core changes * fix conditionals on dev branch * ordering matters --- .github/workflows/php.yml | 2 +- .../Rules/RevisionableStorageInterfaceStubTest.php | 14 ++++++++++++-- tests/src/Rules/data/bug-586.php | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index f8f3a10e..4eb36e85 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -127,7 +127,7 @@ jobs: - name: "require phpstan-drupal" run: | cd ~/drupal - COMPOSER_MEMORY_LIMIT=-1 composer require mglaman/phpstan-drupal "${{ steps.branch_alias.outputs.VERSION_ALIAS }} as 1.1.99" phpstan/extension-installer --with-all-dependencies + COMPOSER_MEMORY_LIMIT=-1 composer require mglaman/phpstan-drupal "${{ steps.branch_alias.outputs.VERSION_ALIAS }} as 1.2.99" phpstan/extension-installer --with-all-dependencies cp $GITHUB_WORKSPACE/tests/fixtures/config/drupal-phpstan.neon phpstan.neon - name: "Test core/install.php" run: | diff --git a/tests/src/Rules/RevisionableStorageInterfaceStubTest.php b/tests/src/Rules/RevisionableStorageInterfaceStubTest.php index 782e5c09..ea815fc0 100644 --- a/tests/src/Rules/RevisionableStorageInterfaceStubTest.php +++ b/tests/src/Rules/RevisionableStorageInterfaceStubTest.php @@ -24,12 +24,22 @@ protected function getRule(): Rule public function testRule(): void { $errors = []; - if (version_compare(\Drupal::VERSION, '10.1', '>=')) { + $drupalVersion = str_replace('-dev', '', \Drupal::VERSION); + if (version_compare($drupalVersion, '10.1', '>=')) { + // There's a quirk on 10.1.x+ which false reports this error but was fixed on 11.x. + if (version_compare($drupalVersion, '11.0', '<')) { + $errors[] = [ + 'Call to deprecated method loadRevision() of class Drupal\Core\Entity\EntityStorageInterface: +in drupal:10.1.0 and is removed from drupal:11.0.0. Use +\Drupal\Core\Entity\RevisionableStorageInterface::loadRevision instead.', + 12 + ]; + } $errors[] = [ 'Call to deprecated method loadRevision() of class Drupal\Core\Entity\EntityStorageInterface: in drupal:10.1.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision instead.', - 12 + 15 ]; } $this->analyse( diff --git a/tests/src/Rules/data/bug-586.php b/tests/src/Rules/data/bug-586.php index e8d2871e..524bb280 100644 --- a/tests/src/Rules/data/bug-586.php +++ b/tests/src/Rules/data/bug-586.php @@ -10,3 +10,6 @@ $genericContentEntityStorage = \Drupal::entityTypeManager()->getStorage('foo'); assert($genericContentEntityStorage instanceof ContentEntityStorageInterface); $genericContentEntityStorage->loadRevision(1); + +$genericEntityStorage = \Drupal::entityTypeManager()->getStorage('bar'); +$genericEntityStorage->loadRevision(1);