Valinor/tests/Unit/Definition/ClassDefinitionTest.php
Romain Canon 7869cbd09c refactor: remove unnecessary ClassSignature
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.
2022-01-25 18:32:28 +01:00

36 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace CuyZ\Valinor\Tests\Unit\Definition;
use CuyZ\Valinor\Definition\ClassDefinition;
use CuyZ\Valinor\Definition\Methods;
use CuyZ\Valinor\Definition\Properties;
use CuyZ\Valinor\Tests\Fake\Definition\FakeAttributes;
use CuyZ\Valinor\Tests\Fake\Definition\FakeMethodDefinition;
use CuyZ\Valinor\Tests\Fake\Definition\FakePropertyDefinition;
use CuyZ\Valinor\Tests\Fake\Type\FakeType;
use CuyZ\Valinor\Type\Types\ClassType;
use PHPUnit\Framework\TestCase;
use stdClass;
final class ClassDefinitionTest extends TestCase
{
public function test_class_data_can_be_retrieved(): void
{
$type = new ClassType(stdClass::class, ['T' => new FakeType()]);
$attributes = new FakeAttributes();
$properties = new Properties(FakePropertyDefinition::new());
$methods = new Methods(FakeMethodDefinition::new());
$class = new ClassDefinition($type, $attributes, $properties, $methods);
self::assertSame(stdClass::class, $class->name());
self::assertSame($type, $class->type());
self::assertSame($attributes, $class->attributes());
self::assertSame($properties, $class->properties());
self::assertSame($methods, $class->methods());
}
}