From a8d82c5f523629a7623a0be91b67615bdb4facfb Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Thu, 31 Aug 2023 09:34:38 +0200 Subject: [PATCH 1/3] test(phpstan): Fix node publish/unpublish calls in tests --- .github/workflows/testing.yml | 2 +- phpstan.neon | 7 ------- .../Kernel/DataProducer/Routing/RouteEntityTest.php | 12 ++++++------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 910b2ff28..e90e3ce6a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -86,7 +86,7 @@ jobs: webonyx/graphql-php:^14.8 \ drupal/typed_data:^1.0 \ drupal/redirect:^1.0 \ - phpstan/phpstan:^1.7.14 \ + phpstan/phpstan:^1.10.32 \ mglaman/phpstan-drupal:^1.1.2 \ phpstan/phpstan-deprecation-rules:^1.0.0 \ jangregor/phpstan-prophecy:^1.0.0 \ diff --git a/phpstan.neon b/phpstan.neon index 68be96082..235c373e0 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -51,10 +51,3 @@ parameters: message: "#^Method Drupal\\\\graphql\\\\Entity\\\\ServerInterface\\:\\:removePersistedQueryInstance\\(\\) has no return type specified\\.$#" count: 1 path: src/Entity/ServerInterface.php - - # We already use the ProphecyTrait, so not sure why PHPStan complains about - # this? - - """ - #^Call to deprecated method prophesize\\(\\) of class Drupal\\\\Tests\\\\graphql\\\\Kernel\\\\GraphQLTestBase\\: - https\\://github\\.com/sebastianbergmann/phpunit/issues/4141$# - """ diff --git a/tests/src/Kernel/DataProducer/Routing/RouteEntityTest.php b/tests/src/Kernel/DataProducer/Routing/RouteEntityTest.php index 6e1a07bbc..fb91fc0d9 100644 --- a/tests/src/Kernel/DataProducer/Routing/RouteEntityTest.php +++ b/tests/src/Kernel/DataProducer/Routing/RouteEntityTest.php @@ -52,11 +52,11 @@ public function setUp(): void { $this->unpublished_node->save(); $this->translation_fr_unpublished = $this->unpublished_node->addTranslation('fr', ['title' => 'Test Unpublished Event FR']); - $this->translation_fr_unpublished->status = NodeInterface::NOT_PUBLISHED; + $this->translation_fr_unpublished->setUnpublished(); $this->translation_fr_unpublished->save(); $this->translation_de_unpublished = $this->unpublished_node->addTranslation('de', ['title' => 'Test Unpublished Event DE']); - $this->translation_de_unpublished->status = NodeInterface::NOT_PUBLISHED; + $this->translation_de_unpublished->setUnpublished(); $this->translation_de_unpublished->save(); // Unpublished node to published translations. @@ -68,11 +68,11 @@ public function setUp(): void { $this->unpublished_to_published_node->save(); $this->translation_fr_unpublished_to_published = $this->unpublished_to_published_node->addTranslation('fr', ['title' => 'Test Unpublished to Published Event FR']); - $this->translation_fr_unpublished_to_published->status = NodeInterface::PUBLISHED; + $this->translation_fr_unpublished_to_published->setPublished(); $this->translation_fr_unpublished_to_published->save(); $this->translation_de_unpublished_to_published = $this->unpublished_to_published_node->addTranslation('de', ['title' => 'Test Unpublished to Published Event DE']); - $this->translation_de_unpublished_to_published->status = NodeInterface::PUBLISHED; + $this->translation_de_unpublished_to_published->setPublished(); $this->translation_de_unpublished_to_published->save(); // Published node to unpublished translations. @@ -84,11 +84,11 @@ public function setUp(): void { $this->published_to_unpublished_node->save(); $this->translation_fr_published_to_unpublished = $this->published_to_unpublished_node->addTranslation('fr', ['title' => 'Test Published to Unpublished Event FR']); - $this->translation_fr_published_to_unpublished->status = NodeInterface::NOT_PUBLISHED; + $this->translation_fr_published_to_unpublished->setUnpublished(); $this->translation_fr_published_to_unpublished->save(); $this->translation_de_published_to_unpublished = $this->published_to_unpublished_node->addTranslation('de', ['title' => 'Test Published to Unpublished Event DE']); - $this->translation_de_published_to_unpublished->status = NodeInterface::NOT_PUBLISHED; + $this->translation_de_published_to_unpublished->setUnpublished(); $this->translation_de_published_to_unpublished->save(); \Drupal::service('content_translation.manager')->setEnabled('node', 'event', TRUE); From f5868647a4376e958712ceaf999ece3d464a3069 Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Thu, 31 Aug 2023 09:53:11 +0200 Subject: [PATCH 2/3] Ignore prophesize calls --- phpstan.neon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpstan.neon b/phpstan.neon index 235c373e0..5aeff2b0d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -12,6 +12,9 @@ parameters: # Not sure we can specify generic types properly with Drupal coding standards # yet, disable for now. checkGenericClassInNonGenericObjectType: false + # Sometimes we have a mismatch between local execution and CI, we don't care + # about ignored errors that are not triggered. + reportUnmatchedIgnoredErrors: false excludePaths: # Exclude the RouteLoad producer because the redirect module is not D10 # compatible so we are not downloading it. @@ -51,3 +54,6 @@ parameters: message: "#^Method Drupal\\\\graphql\\\\Entity\\\\ServerInterface\\:\\:removePersistedQueryInstance\\(\\) has no return type specified\\.$#" count: 1 path: src/Entity/ServerInterface.php + + # We don't care about using the deprecated prophesize() method for now. + - '#https:\/\/github.com\/sebastianbergmann\/phpunit\/issues\/4141#' From 1637925936a96ccf8b479dacb2b59b5f80e16874 Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Thu, 31 Aug 2023 09:58:34 +0200 Subject: [PATCH 3/3] restore original ignore rule --- phpstan.neon | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 5aeff2b0d..ed80ea50f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -55,5 +55,9 @@ parameters: count: 1 path: src/Entity/ServerInterface.php - # We don't care about using the deprecated prophesize() method for now. - - '#https:\/\/github.com\/sebastianbergmann\/phpunit\/issues\/4141#' + # We already use the ProphecyTrait, so not sure why PHPStan complains about + # this? + - """ + #^Call to deprecated method prophesize\\(\\) of class Drupal\\\\Tests\\\\graphql\\\\Kernel\\\\GraphQLTestBase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4141$# + """