mirror of
https://github.com/danog/Valinor.git
synced 2024-11-27 12:44:39 +01:00
7869cbd09c
This abstraction layer was not useful, so it is removed to simplify the API around `ClassDefinition`. A new method `ClassDefinition::type()` is also added, giving access to the `ClassType` instance when working with a class definition.
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace CuyZ\Valinor\Tests\Unit\Definition\Repository\Cache;
|
|
|
|
use CuyZ\Valinor\Definition\Repository\Cache\CacheClassDefinitionRepository;
|
|
use CuyZ\Valinor\Tests\Fake\Cache\FakeCache;
|
|
use CuyZ\Valinor\Tests\Fake\Definition\Repository\FakeClassDefinitionRepository;
|
|
use CuyZ\Valinor\Type\Types\ClassType;
|
|
use DateTime;
|
|
use PHPUnit\Framework\TestCase;
|
|
use stdClass;
|
|
|
|
final class CacheClassDefinitionRepositoryTest extends TestCase
|
|
{
|
|
private CacheClassDefinitionRepository $repository;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->repository = new CacheClassDefinitionRepository(
|
|
new FakeClassDefinitionRepository(),
|
|
new FakeCache()
|
|
);
|
|
}
|
|
|
|
public function test_class_is_saved_in_cache(): void
|
|
{
|
|
$typeA = new ClassType(stdClass::class);
|
|
$typeB = new ClassType(DateTime::class);
|
|
|
|
$classA = $this->repository->for($typeA);
|
|
$classB = $this->repository->for($typeA);
|
|
$classC = $this->repository->for($typeB);
|
|
|
|
self::assertSame($classA, $classB);
|
|
self::assertNotSame($classA, $classC);
|
|
}
|
|
}
|