Skip to content
Snippets Groups Projects
Commit a5d30edd authored by catch's avatar catch
Browse files

Issue #3472115 by mondrake, prashant.c: Method getMockForAbstractClass() is...

Issue #3472115 by mondrake, prashant.c: Method getMockForAbstractClass() is deprecated in PHPUnit 10 - replace in class ConfigEntityStorageTest
parent 2c6c1ae6
No related branches found
No related tags found
No related merge requests found
......@@ -2493,12 +2493,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/Drupal/Tests/Composer/ComposerTest.php',
];
$ignoreErrors[] = [
// identifier: method.deprecated
'message' => '#^Call to deprecated method getMockForAbstractClass\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php',
];
$ignoreErrors[] = [
// identifier: method.deprecated
'message' => '#^Call to deprecated method getMockForAbstractClass\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\.$#',
......
......@@ -160,7 +160,7 @@ protected function setUp(): void {
$container->set('theme_handler', $this->themeHandler->reveal());
\Drupal::setContainer($container);
$this->entity = $this->getMockBuilder(ConfigEntityBaseMockableClass::class)
$this->entity = $this->getMockBuilder(StubConfigEntity::class)
->setConstructorArgs([$values, $this->entityTypeId])
->onlyMethods([])
->getMock();
......@@ -335,7 +335,7 @@ public static function providerCalculateDependenciesWithPluginCollections(): arr
* @covers ::onDependencyRemoval
*/
public function testCalculateDependenciesWithThirdPartySettings(): void {
$this->entity = $this->getMockBuilder(ConfigEntityBaseMockableClass::class)
$this->entity = $this->getMockBuilder(StubConfigEntity::class)
->setConstructorArgs([[], $this->entityTypeId])
->onlyMethods([])
->getMock();
......@@ -570,7 +570,7 @@ public function testToArray(): void {
* @covers ::toArray
*/
public function testToArrayIdKey(): void {
$entity = $this->getMockBuilder(ConfigEntityBaseMockableClass::class)
$entity = $this->getMockBuilder(StubConfigEntity::class)
->setConstructorArgs([[], $this->entityTypeId])
->onlyMethods(['id', 'get'])
->getMock();
......@@ -748,10 +748,3 @@ public function getPluginCollections() {
}
}
/**
* A class extending ConfigEntityBase for testing purposes.
*/
class ConfigEntityBaseMockableClass extends ConfigEntityBase {
}
......@@ -13,7 +13,6 @@
use Drupal\Core\Config\ConfigDuplicateUUIDException;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ConfigManagerInterface;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\Entity\ConfigEntityStorage;
use Drupal\Core\Config\Entity\ConfigEntityType;
......@@ -29,6 +28,7 @@
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use Prophecy\Argument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
......@@ -695,10 +695,13 @@ public function testDeleteNothing(): void {
* @param array $methods
* (optional) The methods to mock.
*
* @return \Drupal\Core\Entity\EntityInterface|\PHPUnit\Framework\MockObject\MockObject
* @return \Drupal\Core\Config\Entity\ConfigEntityInterface&\PHPUnit\Framework\MockObject\MockObject
*/
public function getMockEntity(array $values = [], $methods = []) {
return $this->getMockForAbstractClass(ConfigEntityBase::class, [$values, 'test_entity_type'], '', TRUE, TRUE, TRUE, $methods);
public function getMockEntity(array $values = [], array $methods = []): ConfigEntityInterface&MockObject {
return $this->getMockBuilder(StubConfigEntity::class)
->setConstructorArgs([$values, 'test_entity_type'])
->onlyMethods($methods)
->getMock();
}
}
......
<?php
declare(strict_types=1);
namespace Drupal\Tests\Core\Config\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
/**
* A stub extending ConfigEntityBase for testing purposes.
*/
class StubConfigEntity extends ConfigEntityBase {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment