Verified Commit 5fc1b187 authored by Dave Long's avatar Dave Long
Browse files

test: #3558167 Fix "expects FooInterface, MockObject given" phpstan errors

By: mstrelan
By: mondrake
By: dcam
(cherry picked from commit c325b55a)
parent 7adf0a6a
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -224,7 +224,9 @@ public function testFlush(): void {
    \Drupal::setContainer($container);

    $image_effect_id = $this->randomMachineName();
    $image_effect = $this->getMockBuilder('\Drupal\image\ImageEffectBase');
    $image_effect = $this->getMockBuilder('\Drupal\image\ImageEffectBase')
      ->disableOriginalConstructor()
      ->getMock();

    $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['buildUri', 'getCacheTagsToInvalidate']);
    $image_style->expects($this->any())
+7 −12
Original line number Diff line number Diff line
@@ -5,11 +5,14 @@
namespace Drupal\Tests\locale\Unit;

use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Lock\LockBackendInterface;
use Drupal\locale\LocaleTranslation;
use Drupal\locale\StringStorageInterface;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\HttpFoundation\RequestStack;

/**
@@ -21,31 +24,23 @@ class LocaleTranslationTest extends UnitTestCase {

  /**
   * A mocked storage to use when instantiating LocaleTranslation objects.
   *
   * @var \PHPUnit\Framework\MockObject\MockObject
   */
  protected $storage;
  protected StringStorageInterface&MockObject $storage;

  /**
   * A mocked lock to use when instantiating LocaleTranslation objects.
   *
   * @var \Drupal\Core\Lock\LockBackendInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected LockBackendInterface $lock;
  protected LockBackendInterface&MockObject $lock;

  /**
   * A mocked cache to use when instantiating LocaleTranslation objects.
   *
   * @var \Drupal\Core\Cache\CacheBackendInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected CacheBackendInterface $cache;
  protected CacheBackendInterface&MockObject $cache;

  /**
   * A mocked language manager built from LanguageManagerInterface.
   *
   * @var \Drupal\Core\Language\LanguageManagerInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $languageManager;
  protected LanguageManagerInterface&MockObject $languageManager;

  /**
   * The request stack.
+5 −6
Original line number Diff line number Diff line
@@ -5,12 +5,15 @@
namespace Drupal\Tests\migrate_drupal\Unit\source;

use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\State\StateInterface;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\Tests\migrate\Unit\MigrateTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\MockObject\MockObject;

/**
 * Tests Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase.
@@ -44,17 +47,13 @@ class DrupalSqlBaseTest extends MigrateTestCase {

  /**
   * Mock StateInterface.
   *
   * @var \PHPUnit\Framework\MockObject\MockObject
   */
  protected $state;
  protected StateInterface&MockObject $state;

  /**
   * Mock entity type manager.
   *
   * @var \PHPUnit\Framework\MockObject\MockObject
   */
  protected $entityTypeManager;
  protected EntityTypeManagerInterface&MockObject $entityTypeManager;

  /**
   * Minimum database contents needed to test DrupalSqlBase.
+11 −14
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

namespace Drupal\Tests\Core\Access;

use Drupal\Core\Access\AccessArgumentsResolverFactoryInterface;
use Drupal\Core\Access\AccessCheckInterface;
use Drupal\Core\Access\AccessException;
use Drupal\Core\Access\AccessManager;
@@ -11,14 +12,18 @@
use Drupal\Core\Access\CheckProvider;
use Drupal\Core\Access\DefaultAccessCheck;
use Drupal\Core\Cache\Context\CacheContextsManager;
use Drupal\Core\ParamConverter\ParamConverterManagerInterface;
use Drupal\Core\Routing\RouteMatch;
use Drupal\Core\Routing\RouteObjectInterface;
use Drupal\Core\Routing\RouteProviderInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\router_test\Access\DefinedTestAccessCheck;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Route;
@@ -54,36 +59,28 @@ class AccessManagerTest extends UnitTestCase {

  /**
   * The route provider.
   *
   * @var \PHPUnit\Framework\MockObject\MockObject
   */
  protected $routeProvider;
  protected RouteProviderInterface&MockObject $routeProvider;

  /**
   * The parameter converter.
   *
   * @var \Drupal\Core\ParamConverter\ParamConverterManagerInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $paramConverter;
  protected ParamConverterManagerInterface&MockObject $paramConverter;

  /**
   * The mocked account.
   *
   * @var \Drupal\Core\Session\AccountInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $account;
  protected AccountInterface&MockObject $account;

  /**
   * The access arguments resolver.
   *
   * @var \Drupal\Core\Access\AccessArgumentsResolverFactoryInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $argumentsResolverFactory;
  protected AccessArgumentsResolverFactoryInterface&MockObject $argumentsResolverFactory;

  /**
   * @var \Drupal\Core\Session\AccountInterface|\PHPUnit\Framework\MockObject\MockObject
   * The current user.
   */
  protected $currentUser;
  protected AccountInterface&MockObject $currentUser;

  /**
   * @var \Drupal\Core\Access\CheckProvider
+7 −9
Original line number Diff line number Diff line
@@ -5,10 +5,14 @@
namespace Drupal\Tests\Core\Cache;

use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\CacheCollector;
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
use Drupal\Core\Lock\LockBackendInterface;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\MockObject\MockObject;

/**
 * Tests Drupal\Core\Cache\CacheCollector.
@@ -19,24 +23,18 @@ class CacheCollectorTest extends UnitTestCase {

  /**
   * The cache backend that should be used.
   *
   * @var \Drupal\Core\Cache\CacheBackendInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $cacheBackend;
  protected CacheBackendInterface&MockObject $cacheBackend;

  /**
   * The cache tags invalidator.
   *
   * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $cacheTagsInvalidator;
  protected CacheTagsInvalidatorInterface&MockObject $cacheTagsInvalidator;

  /**
   * The lock backend that should be used.
   *
   * @var \PHPUnit\Framework\MockObject\MockObject
   */
  protected $lock;
  protected LockBackendInterface&MockObject $lock;

  /**
   * The cache id used for the test.
Loading