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

Issue #3480919 by mondrake: Method getMockForAbstractClass() is deprecated -...

Issue #3480919 by mondrake: Method getMockForAbstractClass()  is deprecated - replace in Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest
parent 62ace6aa
No related branches found
No related tags found
13 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3731Claro: role=button on status report items,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #313306 passed with warnings
Pipeline: drupal

#313322

    Pipeline: drupal

    #313321

      Pipeline: drupal

      #313316

        +3
        ......@@ -63165,12 +63165,6 @@
        'count' => 1,
        'path' => __DIR__ . '/modules/views/tests/src/Unit/Plugin/area/ResultTest.php',
        ];
        $ignoreErrors[] = [
        // identifier: method.deprecated
        'message' => '#^Call to deprecated method getMockForAbstractClass\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\.$#',
        'count' => 2,
        'path' => __DIR__ . '/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php',
        ];
        $ignoreErrors[] = [
        // identifier: method.deprecated
        'message' => '#^Call to deprecated method getMockForAbstractClass\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\.$#',
        ......@@ -74217,18 +74211,6 @@
        'count' => 1,
        'path' => __DIR__ . '/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php',
        ];
        $ignoreErrors[] = [
        // identifier: phpunit.mockMethod
        'message' => '#^Trying to mock an undefined method getRevisionId\\(\\) on class Drupal\\\\Tests\\\\Core\\\\Entity\\\\UrlTestEntity\\.$#',
        'count' => 1,
        'path' => __DIR__ . '/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php',
        ];
        $ignoreErrors[] = [
        // identifier: phpunit.mockMethod
        'message' => '#^Trying to mock an undefined method isDefaultRevision\\(\\) on class Drupal\\\\Tests\\\\Core\\\\Entity\\\\UrlTestEntity\\.$#',
        'count' => 1,
        'path' => __DIR__ . '/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php',
        ];
        $ignoreErrors[] = [
        // identifier: missingType.return
        'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Entity\\\\FieldDefinitionTest\\:\\:factoryTypeProvider\\(\\) has no return type specified\\.$#',
        ......@@ -6,6 +6,7 @@
        use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
        use Drupal\Core\Entity\EntityTypeManagerInterface;
        use Drupal\Tests\Core\Entity\StubEntityBase;
        use Drupal\Tests\UnitTestCase;
        use Drupal\views\Plugin\views\argument_validator\Entity;
        ......@@ -59,7 +60,10 @@ protected function setUp(): void {
        $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
        $this->entityTypeBundleInfo = $this->createMock(EntityTypeBundleInfoInterface::class);
        $mock_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']);
        $mock_entity = $this->getMockBuilder(StubEntityBase::class)
        ->disableOriginalConstructor()
        ->onlyMethods(['bundle', 'access'])
        ->getMock();
        $mock_entity->expects($this->any())
        ->method('bundle')
        ->willReturn('test_bundle');
        ......@@ -71,7 +75,10 @@ protected function setUp(): void {
        ['test_op_3', NULL, FALSE, TRUE],
        ]);
        $mock_entity_bundle_2 = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']);
        $mock_entity_bundle_2 = $this->getMockBuilder(StubEntityBase::class)
        ->disableOriginalConstructor()
        ->onlyMethods(['bundle', 'access'])
        ->getMock();
        $mock_entity_bundle_2->expects($this->any())
        ->method('bundle')
        ->willReturn('test_bundle_2');
        ......
        ......@@ -7,7 +7,6 @@
        use Drupal\Core\Access\AccessResult;
        use Drupal\Core\Cache\Cache;
        use Drupal\Core\DependencyInjection\ContainerBuilder;
        use Drupal\Core\Entity\EntityBase;
        use Drupal\Core\Entity\EntityStorageInterface;
        use Drupal\Core\Entity\EntityTypeManagerInterface;
        use Drupal\Core\Entity\EntityTypeRepositoryInterface;
        ......@@ -127,7 +126,7 @@ protected function setUp(): void {
        $container->set('cache_tags.invalidator', $this->cacheTagsInvalidator->reveal());
        \Drupal::setContainer($container);
        $this->entity = new EntityBaseTest($this->values, $this->entityTypeId);
        $this->entity = new StubEntityBase($this->values, $this->entityTypeId);
        }
        /**
        ......@@ -605,11 +604,3 @@ public function testCacheMaxAge(): void {
        }
        }
        class EntityBaseTest extends EntityBase {
        public $id;
        public $langcode;
        public $uuid;
        public $label;
        }
        ......@@ -5,7 +5,6 @@
        namespace Drupal\Tests\Core\Entity;
        use Drupal\Core\DependencyInjection\ContainerBuilder;
        use Drupal\Core\Entity\EntityBase;
        use Drupal\Core\Entity\EntityMalformedException;
        use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
        use Drupal\Core\Entity\EntityTypeInterface;
        ......@@ -96,7 +95,7 @@ class EntityUrlTest extends UnitTestCase {
        * @covers ::toUrl
        */
        public function testToUrlNoId(): void {
        $entity = $this->getEntity(UrlTestEntity::class, []);
        $entity = $this->getEntity(StubEntityBase::class, []);
        $this->expectException(EntityMalformedException::class);
        $this->expectExceptionMessage('The "' . static::ENTITY_TYPE_ID . '" entity cannot have a URI as it does not have an ID');
        ......@@ -113,7 +112,7 @@ public function testToUrlNoId(): void {
        */
        public function testToUrlDefaultException(): void {
        $values = ['id' => static::ENTITY_ID];
        $entity = $this->getEntity(UrlTestEntity::class, $values);
        $entity = $this->getEntity(StubEntityBase::class, $values);
        $this->entityType->getUriCallback()->willReturn(NULL);
        $this->expectException(UndefinedLinkTemplateException::class);
        ......@@ -131,7 +130,7 @@ public function testToUrlDefaultException(): void {
        */
        public function testToUrlDefaultFallback(): void {
        $values = ['id' => static::ENTITY_ID, 'langcode' => $this->langcode];
        $entity = $this->getEntity(UrlTestEntity::class, $values);
        $entity = $this->getEntity(StubEntityBase::class, $values);
        $this->registerLinkTemplate('edit-form');
        /** @var \Drupal\Core\Url $url */
        $url = $entity->toUrl();
        ......@@ -168,7 +167,7 @@ public function testToUrlDefaultFallback(): void {
        */
        public function testToUrlLinkTemplates($link_template, $expected_route_name): void {
        $values = ['id' => static::ENTITY_ID, 'langcode' => $this->langcode];
        $entity = $this->getEntity(UrlTestEntity::class, $values);
        $entity = $this->getEntity(StubEntityBase::class, $values);
        $this->registerLinkTemplate($link_template);
        /** @var \Drupal\Core\Url $url */
        ......@@ -216,7 +215,8 @@ public static function providerTestToUrlLinkTemplates() {
        */
        public function testToUrlLinkTemplateRevision(bool $is_default_revision, string $link_template, string $expected_route_name, array $expected_route_parameters): void {
        $values = ['id' => static::ENTITY_ID, 'langcode' => $this->langcode];
        $entity = $this->getEntity(RevisionableEntity::class, $values);
        $entity = $this->getEntity(RevisionableEntity::class, $values, ['getRevisionId', 'isDefaultRevision']);
        assert($entity instanceof RevisionableEntity);
        $entity->method('getRevisionId')->willReturn(static::REVISION_ID);
        $entity->method('isDefaultRevision')->willReturn($is_default_revision);
        $this->registerLinkTemplate($link_template);
        ......@@ -265,7 +265,7 @@ public static function providerTestToUrlLinkTemplateRevision(): array {
        * @covers ::urlRouteParameters
        */
        public function testToUrlLinkTemplateNoId($link_template, $expected_route_name): void {
        $entity = $this->getEntity(UrlTestEntity::class, ['id' => static::ENTITY_ID]);
        $entity = $this->getEntity(StubEntityBase::class, ['id' => static::ENTITY_ID]);
        $this->registerLinkTemplate($link_template);
        /** @var \Drupal\Core\Url $url */
        ......@@ -310,7 +310,7 @@ public static function providerTestToUrlLinkTemplateNoId() {
        */
        public function testToUrlLinkTemplateAddForm(bool $has_bundle_key, ?string $bundle_entity_type, string|false $bundle_key, array $expected_route_parameters): void {
        $values = ['id' => static::ENTITY_ID, 'langcode' => $this->langcode];
        $entity = $this->getEntity(UrlTestEntity::class, $values);
        $entity = $this->getEntity(StubEntityBase::class, $values);
        $this->entityType->hasKey('bundle')->willReturn($has_bundle_key);
        $this->entityType->getBundleEntityType()->willReturn($bundle_entity_type);
        $this->entityType->getKey('bundle')->willReturn($bundle_key);
        ......@@ -355,7 +355,7 @@ public static function providerTestToUrlLinkTemplateAddForm(): array {
        * @covers ::linkTemplates
        */
        public function testToUrlUriCallbackUndefined(array $bundle_info, $uri_callback): void {
        $entity = $this->getEntity(UrlTestEntity::class, ['id' => static::ENTITY_ID]);
        $entity = $this->getEntity(StubEntityBase::class, ['id' => static::ENTITY_ID]);
        $this->registerBundleInfo($bundle_info);
        $this->entityType->getUriCallback()->willReturn($uri_callback);
        ......@@ -396,7 +396,7 @@ public static function providerTestToUrlUriCallbackUndefined() {
        * @dataProvider providerTestToUrlUriCallback
        */
        public function testToUrlUriCallback(array $bundle_info, ?\Closure $uri_callback): void {
        $entity = $this->getEntity(UrlTestEntity::class, ['id' => static::ENTITY_ID, 'langcode' => $this->langcode]);
        $entity = $this->getEntity(StubEntityBase::class, ['id' => static::ENTITY_ID, 'langcode' => $this->langcode]);
        $this->registerBundleInfo($bundle_info);
        $this->entityType->getUriCallback()->willReturn($uri_callback);
        ......@@ -433,7 +433,7 @@ public static function providerTestToUrlUriCallback(): array {
        * @covers ::uriRelationships
        */
        public function testUriRelationships(): void {
        $entity = $this->getEntity(UrlTestEntity::class, ['id' => static::ENTITY_ID]);
        $entity = $this->getEntity(StubEntityBase::class, ['id' => static::ENTITY_ID]);
        $container_builder = new ContainerBuilder();
        $url_generator = $this->createMock(UrlGeneratorInterface::class);
        ......@@ -463,7 +463,7 @@ public function testUriRelationships(): void {
        * Returns a mock entity for testing.
        *
        * @param string $class
        * The class name to mock. Should be \Drupal\Tests\Core\Entity\UrlTestEntity
        * The class name to mock. Should be \Drupal\Tests\Core\Entity\StubEntityBase
        * or a subclass.
        * @param array $values
        * An array of entity values to construct the mock entity with.
        ......@@ -471,7 +471,7 @@ public function testUriRelationships(): void {
        * (optional) An array of additional methods to mock on the entity object.
        * The getEntityType() and entityTypeBundleInfo() methods are always mocked.
        *
        * @return \Drupal\Tests\Core\Entity\UrlTestEntity|\PHPUnit\Framework\MockObject\MockObject
        * @return \Drupal\Tests\Core\Entity\StubEntityBase|\PHPUnit\Framework\MockObject\MockObject
        */
        protected function getEntity($class, array $values, array $methods = []) {
        $methods = array_merge($methods, ['getEntityType', 'entityTypeBundleInfo']);
        ......@@ -502,7 +502,7 @@ protected function getEntity($class, array $values, array $methods = []) {
        * The expected route name of the generated URL.
        * @param array $expected_route_parameters
        * The expected route parameters of the generated URL.
        * @param \Drupal\Tests\Core\Entity\UrlTestEntity|\PHPUnit\Framework\MockObject\MockObject $entity
        * @param \Drupal\Tests\Core\Entity\StubEntityBase|\PHPUnit\Framework\MockObject\MockObject $entity
        * The entity that is expected to be set as a URL option.
        * @param bool $has_language
        * Whether or not the URL is expected to have a language option.
        ......@@ -553,12 +553,20 @@ protected function registerBundleInfo($bundle_info) {
        }
        class UrlTestEntity extends EntityBase {
        public $id;
        public $langcode;
        public $uuid;
        public $label;
        abstract class RevisionableEntity extends StubEntityBase implements RevisionableInterface {
        }
        /**
        * {@inheritdoc}
        */
        public function getRevisionId(): int|string|NULL {
        return NULL;
        }
        abstract class RevisionableEntity extends UrlTestEntity implements RevisionableInterface {}
        /**
        * {@inheritdoc}
        */
        public function isDefaultRevision($new_value = NULL): bool {
        return FALSE;
        }
        }
        <?php
        declare(strict_types=1);
        namespace Drupal\Tests\Core\Entity;
        use Drupal\Core\Entity\EntityBase;
        /**
        * A stub base entity for testing purposes.
        */
        class StubEntityBase extends EntityBase {
        public $id;
        public $langcode;
        public $uuid;
        public $label;
        }
        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