Skip to content

Commit

Permalink
IBX-8019: Aligned unit tests and PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
webhdx committed Jun 2, 2024
1 parent b0e13ec commit f19e858
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 47 deletions.
47 changes: 11 additions & 36 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ parameters:
count: 1
path: src/bundle/DependencyInjection/ConfigurationMapper.php

-
message: "#^Parameter \\#1 \\$configuration of method Symfony\\\\Component\\\\DependencyInjection\\\\Extension\\\\Extension\\:\\:processConfiguration\\(\\) expects Symfony\\\\Component\\\\Config\\\\Definition\\\\ConfigurationInterface, Symfony\\\\Component\\\\Config\\\\Definition\\\\ConfigurationInterface\\|null given\\.$#"
count: 1
path: src/bundle/DependencyInjection/EzRecommendationClientExtension.php

-
message: "#^Method EzSystems\\\\EzRecommendationClientBundle\\\\EzRecommendationClientBundle\\:\\:build\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -1235,6 +1230,11 @@ parameters:
count: 1
path: tests/lib/Event/Subscriber/AbstractCoreEventSubscriberTest.php

-
message: "#^PHPDoc tag @var for property EzSystems\\\\EzRecommendationClient\\\\Tests\\\\Event\\\\Subscriber\\\\AbstractCoreEventSubscriberTest\\:\\:\\$notificationServiceMock contains unresolvable type\\.$#"
count: 1
path: tests/lib/Event/Subscriber/AbstractCoreEventSubscriberTest.php

-
message: "#^Return type of call to method PHPUnit\\\\Framework\\\\TestCase\\:\\:createMock\\(\\) contains unresolvable type\\.$#"
count: 1
Expand Down Expand Up @@ -1320,19 +1320,19 @@ parameters:
count: 1
path: tests/lib/Event/Subscriber/ContentEventSubscriberTest.php

-
message: "#^Parameter \\#1 \\$notificationService of class EzSystems\\\\EzRecommendationClient\\\\Event\\\\Subscriber\\\\ContentEventSubscriber constructor expects EzSystems\\\\EzRecommendationClient\\\\Service\\\\NotificationService, EzSystems\\\\EzRecommendationClient\\\\Service\\\\EventNotificationService\\|PHPUnit\\\\Framework\\\\MockObject\\\\MockObject given\\.$#"
count: 1
path: tests/lib/Event/Subscriber/ContentEventSubscriberTest.php

-
message: "#^Return type of call to method PHPUnit\\\\Framework\\\\TestCase\\:\\:createMock\\(\\) contains unresolvable type\\.$#"
count: 6
path: tests/lib/Event/Subscriber/ContentEventSubscriberTest.php

-
message: "#^Call to an undefined method EzSystems\\\\EzRecommendationClient\\\\Helper\\\\ContentHelper\\|PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\:\\:expects\\(\\)\\.$#"
count: 4
count: 3
path: tests/lib/Event/Subscriber/LocationEventSubscriberTest.php

-
message: "#^Call to an undefined method EzSystems\\\\EzRecommendationClient\\\\Helper\\\\ContentHelper\\|PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\:\\:method\\(\\)\\.$#"
count: 3
path: tests/lib/Event/Subscriber/LocationEventSubscriberTest.php

-
Expand Down Expand Up @@ -1385,16 +1385,6 @@ parameters:
count: 1
path: tests/lib/Event/Subscriber/LocationEventSubscriberTest.php

-
message: "#^Method EzSystems\\\\EzRecommendationClient\\\\Tests\\\\Event\\\\Subscriber\\\\LocationEventSubscriberTest\\:\\:updateLocationWithChildrenDataProvider\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/lib/Event/Subscriber/LocationEventSubscriberTest.php

-
message: "#^Parameter \\#1 \\$notificationService of class EzSystems\\\\EzRecommendationClient\\\\Event\\\\Subscriber\\\\LocationEventSubscriber constructor expects EzSystems\\\\EzRecommendationClient\\\\Service\\\\NotificationService, EzSystems\\\\EzRecommendationClient\\\\Service\\\\EventNotificationService\\|PHPUnit\\\\Framework\\\\MockObject\\\\MockObject given\\.$#"
count: 1
path: tests/lib/Event/Subscriber/LocationEventSubscriberTest.php

-
message: "#^Parameter \\#1 \\$originalClassName of method PHPUnit\\\\Framework\\\\TestCase\\:\\:createMock\\(\\) expects class\\-string\\<mixed\\>, string given\\.$#"
count: 1
Expand Down Expand Up @@ -1435,21 +1425,11 @@ parameters:
count: 1
path: tests/lib/Event/Subscriber/ObjectStateEventSubscriberTest.php

-
message: "#^Parameter \\#1 \\$notificationService of class EzSystems\\\\EzRecommendationClient\\\\Event\\\\Subscriber\\\\ObjectStateEventSubscriber constructor expects EzSystems\\\\EzRecommendationClient\\\\Service\\\\NotificationService, EzSystems\\\\EzRecommendationClient\\\\Service\\\\EventNotificationService\\|PHPUnit\\\\Framework\\\\MockObject\\\\MockObject given\\.$#"
count: 1
path: tests/lib/Event/Subscriber/ObjectStateEventSubscriberTest.php

-
message: "#^Return type of call to method PHPUnit\\\\Framework\\\\TestCase\\:\\:createMock\\(\\) contains unresolvable type\\.$#"
count: 1
path: tests/lib/Event/Subscriber/ObjectStateEventSubscriberTest.php

-
message: "#^Anonymous function has an unused use \\$contentInfo\\.$#"
count: 2
path: tests/lib/Event/Subscriber/TrashEventSubscriberTest.php

-
message: "#^Method EzSystems\\\\EzRecommendationClient\\\\Tests\\\\Event\\\\Subscriber\\\\TrashEventSubscriberTest\\:\\:getRelationList\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -1480,11 +1460,6 @@ parameters:
count: 1
path: tests/lib/Event/Subscriber/TrashEventSubscriberTest.php

-
message: "#^Parameter \\#1 \\$notificationService of class EzSystems\\\\EzRecommendationClient\\\\Event\\\\Subscriber\\\\TrashEventSubscriber constructor expects EzSystems\\\\EzRecommendationClient\\\\Service\\\\NotificationService, EzSystems\\\\EzRecommendationClient\\\\Service\\\\EventNotificationService\\|PHPUnit\\\\Framework\\\\MockObject\\\\MockObject given\\.$#"
count: 1
path: tests/lib/Event/Subscriber/TrashEventSubscriberTest.php

-
message: "#^Parameter \\#4 \\$locationHelper of class EzSystems\\\\EzRecommendationClient\\\\Event\\\\Subscriber\\\\TrashEventSubscriber constructor expects EzSystems\\\\EzRecommendationClient\\\\Helper\\\\LocationHelper, EzSystems\\\\EzRecommendationClient\\\\Helper\\\\LocationHelper\\|PHPUnit\\\\Framework\\\\MockObject\\\\MockObject given\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use eZ\Publish\Core\Repository\Values\Content\Content;
use eZ\Publish\Core\Repository\Values\Content\Location;
use eZ\Publish\Core\Repository\Values\Content\VersionInfo;
use EzSystems\EzRecommendationClient\Service\EventNotificationService;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

Expand All @@ -26,6 +27,9 @@ abstract class AbstractCoreEventSubscriberTest extends TestCase
/** @var \eZ\Publish\Core\Repository\Values\Content\Content */
protected $content;

/** @var \PHPUnit\Framework\MockObject\MockObject&\EzSystems\EzRecommendationClient\Service\EventNotificationService */
protected $notificationServiceMock;

public function setUp(): void
{
$this->contentInfo = new ContentInfo([
Expand All @@ -42,6 +46,7 @@ public function setUp(): void
'contentInfo' => $this->contentInfo,
]),
]);
$this->notificationServiceMock = $this->createMock(EventNotificationService::class);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,27 @@
use eZ\Publish\Core\Query\QueryFactoryInterface;
use EzSystems\EzRecommendationClient\Helper\ContentHelper;
use EzSystems\EzRecommendationClient\Helper\LocationHelper;
use EzSystems\EzRecommendationClient\Service\EventNotificationService;

abstract class AbstractRepositoryEventSubscriberTest extends AbstractCoreEventSubscriberTest
{
/** @var \PHPUnit\Framework\MockObject\MockObject&\eZ\Publish\API\Repository\ContentService */
/** @var \PHPUnit\Framework\MockObject\MockObject|\eZ\Publish\API\Repository\ContentService */
protected $contentServiceMock;

/** @var \PHPUnit\Framework\MockObject\MockObject&\eZ\Publish\API\Repository\LocationService */
/** @var \PHPUnit\Framework\MockObject\MockObject|\eZ\Publish\API\Repository\LocationService */
protected $locationServiceMock;

/** @var \PHPUnit\Framework\MockObject\MockObject&\EzSystems\EzRecommendationClient\Helper\LocationHelper */
/** @var \PHPUnit\Framework\MockObject\MockObject|\EzSystems\EzRecommendationClient\Helper\LocationHelper */
protected $locationHelperMock;

/** @var \PHPUnit\Framework\MockObject\MockObject&\EzSystems\EzRecommendationClient\Helper\ContentHelper */
/** @var \PHPUnit\Framework\MockObject\MockObject|\EzSystems\EzRecommendationClient\Helper\ContentHelper */
protected $contentHelperMock;

/** @var \PHPUnit\Framework\MockObject\MockObject&\eZ\Publish\Core\Query\QueryFactoryInterface */
/** @var \PHPUnit\Framework\MockObject\MockObject|\eZ\Publish\Core\Query\QueryFactoryInterface */
protected $queryFactoryMock;

/** @var \PHPUnit\Framework\MockObject\MockObject&\eZ\Publish\API\Repository\SearchService */
/** @var \PHPUnit\Framework\MockObject\MockObject|\eZ\Publish\API\Repository\SearchService */
protected $searchServiceMock;

/** @var \PHPUnit\Framework\MockObject\MockObject&\EzSystems\EzRecommendationClient\Service\EventNotificationService */
protected $notificationServiceMock;

public function setUp(): void
{
parent::setUp();
Expand All @@ -49,6 +45,5 @@ public function setUp(): void
$this->contentHelperMock = $this->createMock(ContentHelper::class);
$this->queryFactoryMock = $this->createMock(QueryFactoryInterface::class);
$this->searchServiceMock = $this->createMock(SearchService::class);
$this->notificationServiceMock = $this->createMock(EventNotificationService::class);
}
}

0 comments on commit f19e858

Please sign in to comment.