From 0d34d10df5699f4f3abcd1db12908bc81703e070 Mon Sep 17 00:00:00 2001 From: Yurun Date: Fri, 27 Oct 2023 11:57:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unit/Component/Tests/Annotation/Attr1.php | 13 ++++++ .../unit/Component/Tests/Annotation/Attr2.php | 16 +++++++ .../Component/Tests/Annotation/NotAttr.php | 9 ++++ .../Tests/Util/AnnotationUtilTest.php | 42 +++++-------------- 4 files changed, 49 insertions(+), 31 deletions(-) create mode 100644 tests/unit/Component/Tests/Annotation/Attr1.php create mode 100644 tests/unit/Component/Tests/Annotation/Attr2.php create mode 100644 tests/unit/Component/Tests/Annotation/NotAttr.php diff --git a/tests/unit/Component/Tests/Annotation/Attr1.php b/tests/unit/Component/Tests/Annotation/Attr1.php new file mode 100644 index 0000000000..eea982fecc --- /dev/null +++ b/tests/unit/Component/Tests/Annotation/Attr1.php @@ -0,0 +1,13 @@ +assertEquals(<<<'CODE' + $this->assertStringEqualsStringIgnoringLineEndings(<<<'CODE' #[ - \Imi\Test\Component\Tests\Util\Attr1(), - \Imi\Test\Component\Tests\Util\Attr2(attr1: [ - new \Imi\Test\Component\Tests\Util\Attr1(id: 'a\\1', arr: [ + \Imi\Test\Component\Tests\Annotation\Attr1(), + \Imi\Test\Component\Tests\Annotation\Attr2(attr1: [ + new \Imi\Test\Component\Tests\Annotation\Attr1(id: 'a\\1', arr: [ 1, 2, 3 ]) ], attr1s: [ - new \Imi\Test\Component\Tests\Util\Attr1(id: 'b'), - new \Imi\Test\Component\Tests\Util\Attr1(id: 'c') + new \Imi\Test\Component\Tests\Annotation\Attr1(id: 'b'), + new \Imi\Test\Component\Tests\Annotation\Attr1(id: 'c') ]) ] CODE, AttributeUtil::generateAttributesCode($attributes)); @@ -38,30 +41,7 @@ public function testGenerateAttributesCode(): void public function testGenerateAttributesCodeNotAttr(): void { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Class Imi\Test\Component\Tests\Util\NotAttr does not an Attribute'); + $this->expectExceptionMessage('Class Imi\Test\Component\Tests\Annotation\NotAttr does not an Attribute'); AttributeUtil::generateAttributesCode(new NotAttr()); } } - -#[\Attribute()] -class Attr1 -{ - public function __construct(public string $id = '', public array $arr = []) - { - } -} - -#[\Attribute()] -class Attr2 -{ - /** - * @param Attr1[] $attr1s - */ - public function __construct(public Attr1 $attr1, public array $attr1s) - { - } -} - -class NotAttr -{ -}