From 1d51a1661986de8de7c439f8034cb66bac3b000b Mon Sep 17 00:00:00 2001 From: Michael Telgmann Date: Sat, 5 Oct 2024 12:17:29 +0200 Subject: [PATCH] fix: Reduce flakiness of SitemapLockTest --- .phpstan-baseline.neon | 10 ------- .../Bundle/SitemapBundle/SitemapLockTest.php | 29 +++++++++---------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/.phpstan-baseline.neon b/.phpstan-baseline.neon index 727f06967c8..7fb526c8f98 100644 --- a/.phpstan-baseline.neon +++ b/.phpstan-baseline.neon @@ -39625,16 +39625,6 @@ parameters: count: 1 path: tests/Unit/Bundle/SitemapBundle/Service/UrlFilterTest.php - - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Bundle\\\\SitemapBundle\\\\SitemapLockTest\\:\\:testAcquireLockDefaultFalse\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Unit/Bundle/SitemapBundle/SitemapLockTest.php - - - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Bundle\\\\SitemapBundle\\\\SitemapLockTest\\:\\:testAcquireLockWorks\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Unit/Bundle/SitemapBundle/SitemapLockTest.php - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Bundle\\\\SitemapBundle\\\\SitemapNameGeneratorTest\\:\\:testPathGeneration\\(\\) has no return type specified\\.$#" count: 1 diff --git a/tests/Unit/Bundle/SitemapBundle/SitemapLockTest.php b/tests/Unit/Bundle/SitemapBundle/SitemapLockTest.php index 70895834694..a70aa362282 100644 --- a/tests/Unit/Bundle/SitemapBundle/SitemapLockTest.php +++ b/tests/Unit/Bundle/SitemapBundle/SitemapLockTest.php @@ -1,4 +1,6 @@ lifeTime = 3600; - $data = sprintf('Locked: %s', (new DateTime('NOW', new DateTimeZone('UTC')))->format(DateTime::ATOM)); - $this->cacheMock = $this->getMockBuilder(CoreCache::class) ->disableOriginalConstructor() - ->setMethods(['save', 'fetch']) ->getMock(); $this->cacheMock->method('fetch') ->with('sitemap-exporter-running-1') ->willReturn(false); - - $this->cacheMock->method('save') - ->with('sitemap-exporter-running-1', $data, $this->lifeTime) - ->willReturn(false); } - public function testAcquireLockDefaultFalse() + public function testAcquireLockDefaultFalse(): void { $shop = new ShopMock(); $shop->id = 1; @@ -73,8 +67,13 @@ public function testAcquireLockDefaultFalse() static::assertFalse($lock->isLocked($shop)); } - public function testAcquireLockWorks() + public function testAcquireLockWorks(): void { + $data = sprintf('Locked: %s', (new DateTime('NOW', new DateTimeZone('UTC')))->format(DateTimeInterface::ATOM)); + $this->cacheMock->method('save') + ->with('sitemap-exporter-running-1', $data, $this->lifeTime) + ->willReturn(false); + $shop = new ShopMock(); $shop->id = 1;