mirror of
https://github.com/danog/Valinor.git
synced 2025-01-10 06:38:24 +01:00
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace CuyZ\Valinor\Tests\Unit\Definition\Repository\Cache;
|
|
|
|
use CuyZ\Valinor\Definition\Repository\Cache\CacheFunctionDefinitionRepository;
|
|
use CuyZ\Valinor\Tests\Fake\Cache\FakeCache;
|
|
use CuyZ\Valinor\Tests\Fake\Definition\Repository\FakeFunctionDefinitionRepository;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class CacheFunctionDefinitionRepositoryTest extends TestCase
|
|
{
|
|
private CacheFunctionDefinitionRepository $repository;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->repository = new CacheFunctionDefinitionRepository(
|
|
new FakeFunctionDefinitionRepository(),
|
|
new FakeCache()
|
|
);
|
|
}
|
|
|
|
public function test_function_is_saved_in_cache(): void
|
|
{
|
|
$callableA = fn (): int => 42;
|
|
$callableB = fn (): int => 1337;
|
|
|
|
$functionA = $this->repository->for($callableA);
|
|
$functionB = $this->repository->for($callableA);
|
|
$functionC = $this->repository->for($callableB);
|
|
|
|
self::assertSame($functionA, $functionB);
|
|
self::assertNotSame($functionA, $functionC);
|
|
}
|
|
}
|