Skip to content

Commit

Permalink
Move the statement from assert
Browse files Browse the repository at this point in the history
Because the test results will change in environments where assert is not valid (such as Windows),
  • Loading branch information
koriym committed Nov 26, 2024
1 parent 0f6d283 commit 1b44e4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tests/DonutQueryInterceptorPurgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
9 changes: 6 additions & 3 deletions tests/DonutRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.
Expand All @@ -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]);
Expand Down

0 comments on commit 1b44e4f

Please sign in to comment.