From 914c90808b8234cec373f4ccf2d8d5d636c167fd Mon Sep 17 00:00:00 2001 From: Adrian Mejias Date: Sat, 1 Jan 2022 00:41:48 -0600 Subject: [PATCH] wip --- tests/Veils/FooVeil.php | 2 +- tests/Veils/MyTestClass.php | 13 ++++++- tests/VeilsTest.php | 75 +++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 2 deletions(-) diff --git a/tests/Veils/FooVeil.php b/tests/Veils/FooVeil.php index ddf7a26..adfb297 100644 --- a/tests/Veils/FooVeil.php +++ b/tests/Veils/FooVeil.php @@ -14,7 +14,7 @@ * @method static string getVeilAccessor() Get veil accessor. * @method static \AdrianMejias\Tests\Veils\MyTestClass getVeilInstance() * Get veil instance. - * @method static string bar() Say hi. + * @method static string bar(mixed ...$args) Say hi. */ class FooVeil extends VeilAbstract { diff --git a/tests/Veils/MyTestClass.php b/tests/Veils/MyTestClass.php index 75d187b..d77b535 100644 --- a/tests/Veils/MyTestClass.php +++ b/tests/Veils/MyTestClass.php @@ -4,15 +4,26 @@ namespace AdrianMejias\Tests\Veils; +/** + * My Test Class. + * + * @package Veil + * @category Test + */ class MyTestClass { /** * Say hi. * + * @param mixed $args * @return string */ - public function bar(): string + public function bar(...$args): string { + if (count($args) > 0) { + return 'hi' . json_encode($args ?? []); + } + return 'hi'; } } diff --git a/tests/VeilsTest.php b/tests/VeilsTest.php index 4b13285..2d66d31 100644 --- a/tests/VeilsTest.php +++ b/tests/VeilsTest.php @@ -90,6 +90,81 @@ public function it_can_call_method() $this->assertSame($expected, $actual); } + /** + * @test + * @covers \AdrianMejias\Veil\Veil + * @covers \AdrianMejias\Veil\VeilAbstract + */ + public function it_can_call_method_with_one_arg() + { + (new Veil)->register()->add('Foo', FooVeil::class); + + $expected = \Foo::bar(1); + $actual = FooVeil::getVeilInstance()->bar(1); + + $this->assertSame($expected, $actual); + } + + /** + * @test + * @covers \AdrianMejias\Veil\Veil + * @covers \AdrianMejias\Veil\VeilAbstract + */ + public function it_can_call_method_with_two_args() + { + (new Veil)->register()->add('Foo', FooVeil::class); + + $expected = \Foo::bar(1, 2); + $actual = FooVeil::getVeilInstance()->bar(1, 2); + + $this->assertSame($expected, $actual); + } + + /** + * @test + * @covers \AdrianMejias\Veil\Veil + * @covers \AdrianMejias\Veil\VeilAbstract + */ + public function it_can_call_method_with_three_args() + { + (new Veil)->register()->add('Foo', FooVeil::class); + + $expected = \Foo::bar(1, 2, 3); + $actual = FooVeil::getVeilInstance()->bar(1, 2, 3); + + $this->assertSame($expected, $actual); + } + + /** + * @test + * @covers \AdrianMejias\Veil\Veil + * @covers \AdrianMejias\Veil\VeilAbstract + */ + public function it_can_call_method_with_four_args() + { + (new Veil)->register()->add('Foo', FooVeil::class); + + $expected = \Foo::bar(1, 2, 3, 4); + $actual = FooVeil::getVeilInstance()->bar(1, 2, 3, 4); + + $this->assertSame($expected, $actual); + } + + /** + * @test + * @covers \AdrianMejias\Veil\Veil + * @covers \AdrianMejias\Veil\VeilAbstract + */ + public function it_can_call_method_with_five_args() + { + (new Veil)->register()->add('Foo', FooVeil::class); + + $expected = \Foo::bar(1, 2, 3, 4, 5); + $actual = FooVeil::getVeilInstance()->bar(1, 2, 3, 4, 5); + + $this->assertSame($expected, $actual); + } + /** * @test * @covers \AdrianMejias\Veil\Veil