Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Windows test compat #151

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
koriym marked this conversation as resolved.
Show resolved Hide resolved
$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
14 changes: 2 additions & 12 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Loading