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