-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for attributes on interfaces (#9)
- Loading branch information
Showing
6 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
fixture_src/ClassOnlyAttributeSingleInterface/FooInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Cspray\AnnotatedTargetFixture\ClassOnlyAttributeSingleInterface; | ||
|
||
use Cspray\AnnotatedTargetFixture\ClassOnly; | ||
|
||
#[ClassOnly('foo')] | ||
interface FooInterface { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Cspray\AnnotatedTargetFixture; | ||
|
||
use Cspray\Typiphy\ObjectType; | ||
use function Cspray\Typiphy\objectType; | ||
|
||
class ClassOnlyAttributeSingleInterfaceFixture implements Fixture { | ||
|
||
public function getPath() : string { | ||
return __DIR__ .'/ClassOnlyAttributeSingleInterface'; | ||
} | ||
|
||
public function fooInterface() : ObjectType { | ||
return objectType(ClassOnlyAttributeSingleInterface\FooInterface::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Cspray\AnnotatedTarget\Unit; | ||
|
||
use Cspray\AnnotatedTargetFixture\ClassOnly; | ||
use Cspray\AnnotatedTargetFixture\Fixtures; | ||
use function Cspray\Typiphy\objectType; | ||
|
||
uses(AnnotatedTargetParserTestCase::class); | ||
|
||
beforeEach()->withFixtures(Fixtures::classOnlyAttributeSingleInterface()); | ||
|
||
it('counts parsed targets for single class') | ||
->expect(fn() => $this->getTargets()) | ||
->toHaveCount(1); | ||
|
||
it('ensures all targets are correct type') | ||
->expect(fn() => $this->getTargets()) | ||
->toContainOnlyAnnotatedTargets(); | ||
|
||
it('ensures all targets share target reflection') | ||
->expect(fn() => $this->getTargets()) | ||
->toShareTargetReflection(); | ||
|
||
it('ensures all targets share attribute reflection') | ||
->expect(fn() => $this->getTargets()) | ||
->toShareAttributeReflection(); | ||
|
||
it('ensures all targets share attribute instance') | ||
->expect(fn() => $this->getTargets()) | ||
->toShareAttributeInstance(); | ||
|
||
it('includes target reflection class') | ||
->expect(fn() => $this->getTargets()) | ||
->toContainTargetClass(Fixtures::classOnlyAttributeSingleInterface()->fooInterface()); | ||
|
||
it('includes attribute reflection class') | ||
->expect(fn() => $this->getTargets()) | ||
->toContainTargetClassWithAttribute(Fixtures::classOnlyAttributeSingleInterface()->fooInterface(), objectType(ClassOnly::class)); | ||
|
||
it('includes attribute instance with correct value') | ||
->expect(fn() => $this->getTargets()) | ||
->toContainTargetClassWithAttributeInstance( | ||
Fixtures::classOnlyAttributeSingleInterface()->fooInterface(), | ||
objectType(ClassOnly::class), | ||
fn(ClassOnly $classOnly) => $classOnly->value === 'foo' | ||
); |