Skip to content

Commit

Permalink
test(phpunit): Replace deprecated getMockForAbstractClass() and getNa…
Browse files Browse the repository at this point in the history
…me() calls (#1415)
  • Loading branch information
klausi committed Aug 2, 2024
1 parent 75dd0a4 commit e0dacc2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
# Pin the exact Coder version to upgrade manually when we want to.
run: |
composer --no-interaction --no-progress require \
phpstan/phpstan:^1.11.2 \
phpstan/phpstan:^1.11.9 \
mglaman/phpstan-drupal:^1.1.2 \
phpstan/phpstan-deprecation-rules:^1.0.0 \
jangregor/phpstan-prophecy:^1.0.0 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ public function resolve(FileInterface $entity = NULL, $style, RefinableCacheable
$metadata->addCacheableDependency($access);
if ($access->isAllowed() && $image_style = ImageStyle::load($style)) {

// @phpstan-ignore-next-line
$width = $entity->width;
// @phpstan-ignore-next-line
$height = $entity->height;

// @phpstan-ignore-next-line
if (empty($width) || empty($height)) {
/** @var \Drupal\Core\Image\ImageInterface $image */
$image = \Drupal::service('image.factory')->get($entity->getFileUri());
Expand Down
14 changes: 7 additions & 7 deletions tests/src/Kernel/AlterableSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\Tests\graphql\Kernel;

use Drupal\graphql\GraphQL\ResolverRegistry;
use Drupal\graphql\Plugin\GraphQL\SchemaExtension\SdlSchemaExtensionPluginBase;
use Drupal\graphql\Plugin\SchemaExtensionPluginInterface;
use Drupal\graphql\Plugin\SchemaExtensionPluginManager;
use Drupal\Tests\graphql\Kernel\Schema\AlterableComposableTestSchema;

Expand Down Expand Up @@ -148,17 +148,17 @@ protected function mockSchema($id, $schema, array $extensions = []): void {
->getMock();

// Adds extra extension in order to test alter extension data event.
$extensions['graphql_alterable_schema_test'] = $this->getMockBuilder(SdlSchemaExtensionPluginBase::class)
->disableOriginalConstructor()
->onlyMethods(['getBaseDefinition', 'getExtensionDefinition'])
->getMockForAbstractClass();
$extensions['graphql_alterable_schema_test'] = $this->getMockBuilder(SchemaExtensionPluginInterface::class)
->getMock();

$extensions['graphql_alterable_schema_test']->expects(static::any())
->method('getBaseDefinition')
->willReturn('');

// Different extension definition for different tests.
switch ($this->getName()) {
// PHPUnit compatibility: remove once support for Drupal 10.2 is dropped.
$methodName = method_exists($this, 'name') ? 'name' : 'getName';
switch ($this->$methodName()) {
case 'testEmptySchemaExtensionAlteredQueryResultPropertyAdded':
$extensionDefinition = '';
break;
Expand Down Expand Up @@ -193,7 +193,7 @@ protected function mockSchema($id, $schema, array $extensions = []): void {
$this->container->get('event_dispatcher'),
])
->onlyMethods(['getSchemaDefinition', 'getResolverRegistry'])
->getMockForAbstractClass();
->getMock();

$this->schema->expects(static::any())
->method('getSchemaDefinition')
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Traits/MockingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected function mockSchema($id, $schema, array $extensions = []): void {
['development' => FALSE],
])
->onlyMethods(['getSchemaDefinition', 'getResolverRegistry'])
->getMockForAbstractClass();
->getMock();

$this->schema->expects(static::any())
->method('getSchemaDefinition')
Expand Down

0 comments on commit e0dacc2

Please sign in to comment.