Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(phpunit): Replace deprecated getMockForAbstractClass() and getName() calls #1415

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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