-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug: cant correct resolve attribute data for several attributes o…
…n method
- Loading branch information
1 parent
ab80eba
commit 29f471f
Showing
17 changed files
with
159 additions
and
57 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
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
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
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Andi\GraphQL\Common; | ||
|
||
use Andi\GraphQL\Attribute\AbstractField; | ||
|
||
final class ReflectionMethodWithAttribute | ||
{ | ||
public function __construct( | ||
public readonly \ReflectionMethod $method, | ||
public readonly AbstractField $attribute, | ||
) { | ||
} | ||
} |
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
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,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Andi\Tests\GraphQL\Common; | ||
|
||
use Andi\GraphQL\Attribute\AbstractDefinition; | ||
use Andi\GraphQL\Attribute\AbstractField; | ||
use Andi\GraphQL\Attribute\QueryField; | ||
use Andi\GraphQL\Common\ReflectionMethodWithAttribute; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\UsesClass; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(ReflectionMethodWithAttribute::class)] | ||
#[UsesClass(AbstractDefinition::class)] | ||
#[UsesClass(AbstractField::class)] | ||
final class ReflectionMethodWithAttributeTest extends TestCase | ||
{ | ||
public function testClass(): void | ||
{ | ||
$object = new class { | ||
#[QueryField] | ||
public function foo(): void | ||
{ | ||
} | ||
}; | ||
|
||
$reflectionClass = new \ReflectionClass($object); | ||
$method = null; | ||
foreach ($reflectionClass->getMethods() as $method) { | ||
break; | ||
} | ||
|
||
$attribute = null; | ||
foreach ($method->getAttributes() as $reflectionAttribute) { | ||
$attribute = $reflectionAttribute->newInstance(); | ||
break; | ||
} | ||
|
||
$instance = new ReflectionMethodWithAttribute($method, $attribute); | ||
|
||
self::assertSame($method, $instance->method); | ||
self::assertSame($attribute, $instance->attribute); | ||
} | ||
} |
Oops, something went wrong.