diff --git a/tests/DonutQueryInterceptorPurgeTest.php b/tests/DonutQueryInterceptorPurgeTest.php index 8703ccf6..79f659aa 100644 --- a/tests/DonutQueryInterceptorPurgeTest.php +++ b/tests/DonutQueryInterceptorPurgeTest.php @@ -51,8 +51,8 @@ public function testStatePurge(): void $ro1 = $this->resource->get('page://self/html/blog-posting'); $this->assertFalse($this->isCreatedByState($ro1)); $this->assertTrue($this->isStateCached()); - - assert($this->repository->purge(new Uri('page://self/html/comment'))); + $puregeResult = $this->repository->purge(new Uri('page://self/html/comment')); + assert($puregeResult); $this->assertFalse($this->isStateCached()); $ro2 = $this->resource->get('page://self/html/blog-posting'); diff --git a/tests/DonutRepositoryTest.php b/tests/DonutRepositoryTest.php index bc184f25..9c41271a 100644 --- a/tests/DonutRepositoryTest.php +++ b/tests/DonutRepositoryTest.php @@ -63,7 +63,8 @@ public function testCreateDonut(): void /** @depends testCreateDonut */ public function testCachePurge(): void { - assert($this->queryRepository->purge($this->uri)); + $purgeResult = $this->queryRepository->purge($this->uri); + $this->assertTrue($purgeResult); $maybeNullPurged = $this->queryRepository->get($this->uri); $this->assertNull($maybeNullPurged); } @@ -94,7 +95,8 @@ public function testCacheDependency(): void $blogState1 = $queryRepository->get(new Uri('page://self/html/blog-posting')); $this->assertInstanceOf(ResourceState::class, $blogState1); // When cache dependency is deleted, cache dependent automatically deleted - assert($queryRepository->purge(new Uri('page://self/html/comment'))); + $commentResult = $queryRepository->purge(new Uri('page://self/html/comment')); + assert($commentResult); $blogState2 = $queryRepository->get(new Uri('page://self/html/blog-posting')); $this->assertNull($blogState2); // Cache created again. @@ -110,7 +112,8 @@ public function testRefresh(): void $queryRepository = $injector->getInstance(QueryRepositoryInterface::class); $resource->get('page://self/html/blog-posting'); - assert($queryRepository->purge(new Uri('page://self/html/comment'))); + $purgeResult = $queryRepository->purge(new Uri('page://self/html/comment')); + $this->assertTrue($purgeResult); $donutRo = $resource->get('page://self/html/blog-posting'); $this->assertSame('r', $donutRo->headers[Header::ETAG][-1]); $this->assertStringContainsString('blog-posting-page', $donutRo->headers[Header::SURROGATE_KEY]); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index eddfbae6..b64d04d2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -5,16 +5,6 @@ use Koriym\Attributes\AttributeReader; use Ray\ServiceLocator\ServiceLocator; -$unlink = static function (string $path) use (&$unlink): void { - foreach ((array) glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*') as $f) { - $file = (string) $f; - is_dir($file) ? $unlink($file) : unlink($file); - @rmdir($file); - } -}; -$unlink(__DIR__ . '/tmp'); +array_map('unlink', glob(__DIR__ . '/tests/tmp/*.php')); // @phpstan-ignore-line -// no annotation in PHP 8 -if (PHP_MAJOR_VERSION >= 8) { // @phpstan-ignore-line - ServiceLocator::setReader(new AttributeReader()); -} +ServiceLocator::setReader(new AttributeReader());