-
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.
- Loading branch information
Showing
6 changed files
with
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Cspray\AnnotatedTargetFixture\AliasedAttribute; | ||
|
||
use Cspray\AnnotatedTargetFixture\ClassOnly as MyAttributeName; | ||
|
||
#[MyAttributeName('my aliased value')] | ||
class FooClass { | ||
|
||
} |
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; | ||
|
||
final class AliasedAttributeFixture implements Fixture { | ||
|
||
public function getPath() : string { | ||
return __DIR__ . '/AliasedAttribute'; | ||
} | ||
|
||
public function fooClass() : ObjectType { | ||
return objectType(AliasedAttribute\FooClass::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::aliasedAttribute()); | ||
|
||
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::aliasedAttribute()->fooClass()); | ||
|
||
it('includes attribute reflection class') | ||
->expect(fn() => $this->getTargets()) | ||
->toContainTargetClassWithAttribute(Fixtures::aliasedAttribute()->fooClass(), objectType(ClassOnly::class)); | ||
|
||
it('includes attribute instance with correct value') | ||
->expect(fn() => $this->getTargets()) | ||
->toContainTargetClassWithAttributeInstance( | ||
Fixtures::aliasedAttribute()->fooClass(), | ||
objectType(ClassOnly::class), | ||
fn(ClassOnly $classOnly) => $classOnly->value === 'my aliased value' | ||
); |
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