From 1884774247aa42da2c190a89a46b6b2b924e91ae Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 21 Sep 2016 16:14:31 +0200 Subject: [PATCH] tests: improvements --- .../DI/PhpReflection.getReturnType.php7.phpt | 38 ++++++++++++++----- tests/DI/PhpReflection.getReturnType.phpt | 22 +++++++---- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/tests/DI/PhpReflection.getReturnType.php7.phpt b/tests/DI/PhpReflection.getReturnType.php7.phpt index 2f9098bb9..01e782c61 100644 --- a/tests/DI/PhpReflection.getReturnType.php7.phpt +++ b/tests/DI/PhpReflection.getReturnType.php7.phpt @@ -2,7 +2,7 @@ /** * Test: Nette\DI\PhpReflection::getReturnType - * @phpversion >= 7 + * @phpversion 7 */ namespace NS @@ -14,22 +14,34 @@ namespace NS function noType() {} + function classType(): B + {} + + function nativeType(): string + {} + + function selfType(): self + {} + /** @return B */ - function annotationSingle() + function annotationClassType() {} /** @return B|string */ - function annotationComplex() + function annotationUnionType() {} - function nativeType(): string + /** @return String */ + function annotationNativeType() {} - function selfType(): self + /** @return self */ + function annotationSelfType() {} } - function classType(): B + /** @return B */ + function annotationClassType() {} } @@ -44,14 +56,20 @@ namespace Assert::null(PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'noType'))); - Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationSingle'))); - - Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationComplex'))); + Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'classType'))); Assert::same('string', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'nativeType'))); Assert::same('NS\A', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'selfType'))); + Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationClassType'))); + + Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationUnionType'))); + + Assert::same('string', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationNativeType'))); + + Assert::same('NS\A', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationSelfType'))); + // class name expanding is NOT supported for global functions - Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionFunction(NS\classType::class))); + Assert::same('B', PhpReflection::getReturnType(new \ReflectionFunction('NS\annotationClassType'))); } diff --git a/tests/DI/PhpReflection.getReturnType.phpt b/tests/DI/PhpReflection.getReturnType.phpt index 7d1e2ed45..1fe6887d4 100644 --- a/tests/DI/PhpReflection.getReturnType.phpt +++ b/tests/DI/PhpReflection.getReturnType.phpt @@ -14,20 +14,24 @@ namespace NS {} /** @return B */ - function annotationSingle() + function annotationClassType() {} /** @return B|string */ - function annotationComplex() + function annotationUnionType() {} /** @return String */ - function nativeType() + function annotationNativeType() + {} + + /** @return self */ + function annotationSelfType() {} } /** @return B */ - function classType() + function annotationClassType() {} } @@ -42,12 +46,14 @@ namespace Assert::null(PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'noType'))); - Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationSingle'))); + Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationClassType'))); + + Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationUnionType'))); - Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationComplex'))); + Assert::same('string', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationNativeType'))); - Assert::same('string', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'nativeType'))); + Assert::same('NS\A', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationSelfType'))); // class name expanding is NOT supported for global functions - Assert::same('B', PhpReflection::getReturnType(new \ReflectionFunction(NS\classType::class))); + Assert::same('B', PhpReflection::getReturnType(new \ReflectionFunction('NS\annotationClassType'))); }