|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +namespace Cspray\AnnotatedTarget\Unit; |
| 4 | + |
| 5 | +use Cspray\AnnotatedTargetFixture\ClassOnly; |
| 6 | +use Cspray\AnnotatedTargetFixture\Fixtures; |
| 7 | +use function Cspray\Typiphy\objectType; |
| 8 | + |
| 9 | +uses(AnnotatedTargetParserTestCase::class); |
| 10 | + |
| 11 | +beforeEach()->withFixtures(Fixtures::aliasedAttribute()); |
| 12 | + |
| 13 | +it('counts parsed targets for single class') |
| 14 | + ->expect(fn() => $this->getTargets()) |
| 15 | + ->toHaveCount(1); |
| 16 | + |
| 17 | +it('ensures all targets are correct type') |
| 18 | + ->expect(fn() => $this->getTargets()) |
| 19 | + ->toContainOnlyAnnotatedTargets(); |
| 20 | + |
| 21 | +it('ensures all targets share target reflection') |
| 22 | + ->expect(fn() => $this->getTargets()) |
| 23 | + ->toShareTargetReflection(); |
| 24 | + |
| 25 | +it('ensures all targets share attribute reflection') |
| 26 | + ->expect(fn() => $this->getTargets()) |
| 27 | + ->toShareAttributeReflection(); |
| 28 | + |
| 29 | +it('ensures all targets share attribute instance') |
| 30 | + ->expect(fn() => $this->getTargets()) |
| 31 | + ->toShareAttributeInstance(); |
| 32 | + |
| 33 | +it('includes target reflection class') |
| 34 | + ->expect(fn() => $this->getTargets()) |
| 35 | + ->toContainTargetClass(Fixtures::aliasedAttribute()->fooClass()); |
| 36 | + |
| 37 | +it('includes attribute reflection class') |
| 38 | + ->expect(fn() => $this->getTargets()) |
| 39 | + ->toContainTargetClassWithAttribute(Fixtures::aliasedAttribute()->fooClass(), objectType(ClassOnly::class)); |
| 40 | + |
| 41 | +it('includes attribute instance with correct value') |
| 42 | + ->expect(fn() => $this->getTargets()) |
| 43 | + ->toContainTargetClassWithAttributeInstance( |
| 44 | + Fixtures::aliasedAttribute()->fooClass(), |
| 45 | + objectType(ClassOnly::class), |
| 46 | + fn(ClassOnly $classOnly) => $classOnly->value === 'my aliased value' |
| 47 | + ); |
0 commit comments