From 635e494ceb6bccd2c765b32989cdeea9826dd4e8 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 8 Feb 2023 13:59:06 +0100 Subject: [PATCH] [Tests] Fixed SiteAccessLimitationMapperTest generate mock (#2087) * [Tests] Fixed SiteAccessLimitationMapperTest generate mock * [CS] Fixed constructor call arguments alignment Co-authored-by: Konrad Oboza --------- Co-authored-by: Konrad Oboza --- .../Mapper/SiteAccessLimitationMapperTest.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib/Tests/Limitation/Mapper/SiteAccessLimitationMapperTest.php b/src/lib/Tests/Limitation/Mapper/SiteAccessLimitationMapperTest.php index 623faf9da5..f4ec538887 100644 --- a/src/lib/Tests/Limitation/Mapper/SiteAccessLimitationMapperTest.php +++ b/src/lib/Tests/Limitation/Mapper/SiteAccessLimitationMapperTest.php @@ -10,13 +10,12 @@ use eZ\Publish\Core\MVC\Symfony\SiteAccess; use eZ\Publish\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface; use EzSystems\EzPlatformAdminUi\Limitation\Mapper\SiteAccessLimitationMapper; -use EzSystems\EzPlatformAdminUi\Siteaccess\SiteAccessKeyGenerator; use EzSystems\EzPlatformAdminUi\Siteaccess\SiteAccessKeyGeneratorInterface; use PHPUnit\Framework\TestCase; class SiteAccessLimitationMapperTest extends TestCase { - public function testMapLimitationValue() + public function testMapLimitationValue(): void { $siteAccessList = [ '2356372769' => 'foo', @@ -40,14 +39,18 @@ static function (string $siteAccessName): SiteAccess { $siteAccessesGeneratorInterface = $this->createMock(SiteAccessKeyGeneratorInterface::class); $siteAccessesGeneratorInterface ->method('generate') - ->willReturn(new SiteAccessKeyGenerator()); + // re-map SiteAccess crc32 identifiers back to string, as the keys get stored as integers + ->willReturnOnConsecutiveCalls(...array_map('strval', array_keys($siteAccessList))); $siteAccessService = $this->createMock(SiteAccessServiceInterface::class); $siteAccessService->method('getAll')->willReturn($siteAccesses); - $mapper = new SiteAccessLimitationMapper($siteAccessService, $siteAccessesGeneratorInterface); + $mapper = new SiteAccessLimitationMapper( + $siteAccessService, + $siteAccessesGeneratorInterface + ); $result = $mapper->mapLimitationValue($limitation); - $this->assertEquals(array_values($siteAccessList), $result); + self::assertEquals(array_values($siteAccessList), $result); } }