Skip to content

Commit

Permalink
Fix tests after drupal/core changes (#605)
Browse files Browse the repository at this point in the history
* Fix tests after drupal/core changes

* fix conditionals on dev branch

* ordering matters
  • Loading branch information
mglaman authored Sep 27, 2023
1 parent a19934c commit b5c980d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
14 changes: 12 additions & 2 deletions tests/src/Rules/RevisionableStorageInterfaceStubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions tests/src/Rules/data/bug-586.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
$genericContentEntityStorage = \Drupal::entityTypeManager()->getStorage('foo');
assert($genericContentEntityStorage instanceof ContentEntityStorageInterface);
$genericContentEntityStorage->loadRevision(1);

$genericEntityStorage = \Drupal::entityTypeManager()->getStorage('bar');
$genericEntityStorage->loadRevision(1);

0 comments on commit b5c980d

Please sign in to comment.