Skip to content

Commit 1884774

Browse files
committed
tests: improvements
1 parent 5f73db6 commit 1884774

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

tests/DI/PhpReflection.getReturnType.php7.phpt

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* Test: Nette\DI\PhpReflection::getReturnType
5-
* @phpversion >= 7
5+
* @phpversion 7
66
*/
77

88
namespace NS
@@ -14,22 +14,34 @@ namespace NS
1414
function noType()
1515
{}
1616

17+
function classType(): B
18+
{}
19+
20+
function nativeType(): string
21+
{}
22+
23+
function selfType(): self
24+
{}
25+
1726
/** @return B */
18-
function annotationSingle()
27+
function annotationClassType()
1928
{}
2029

2130
/** @return B|string */
22-
function annotationComplex()
31+
function annotationUnionType()
2332
{}
2433

25-
function nativeType(): string
34+
/** @return String */
35+
function annotationNativeType()
2636
{}
2737

28-
function selfType(): self
38+
/** @return self */
39+
function annotationSelfType()
2940
{}
3041
}
3142

32-
function classType(): B
43+
/** @return B */
44+
function annotationClassType()
3345
{}
3446
}
3547

@@ -44,14 +56,20 @@ namespace
4456

4557
Assert::null(PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'noType')));
4658

47-
Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationSingle')));
48-
49-
Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationComplex')));
59+
Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'classType')));
5060

5161
Assert::same('string', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'nativeType')));
5262

5363
Assert::same('NS\A', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'selfType')));
5464

65+
Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationClassType')));
66+
67+
Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationUnionType')));
68+
69+
Assert::same('string', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationNativeType')));
70+
71+
Assert::same('NS\A', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationSelfType')));
72+
5573
// class name expanding is NOT supported for global functions
56-
Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionFunction(NS\classType::class)));
74+
Assert::same('B', PhpReflection::getReturnType(new \ReflectionFunction('NS\annotationClassType')));
5775
}

tests/DI/PhpReflection.getReturnType.phpt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,24 @@ namespace NS
1414
{}
1515

1616
/** @return B */
17-
function annotationSingle()
17+
function annotationClassType()
1818
{}
1919

2020
/** @return B|string */
21-
function annotationComplex()
21+
function annotationUnionType()
2222
{}
2323

2424
/** @return String */
25-
function nativeType()
25+
function annotationNativeType()
26+
{}
27+
28+
/** @return self */
29+
function annotationSelfType()
2630
{}
2731
}
2832

2933
/** @return B */
30-
function classType()
34+
function annotationClassType()
3135
{}
3236
}
3337

@@ -42,12 +46,14 @@ namespace
4246

4347
Assert::null(PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'noType')));
4448

45-
Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationSingle')));
49+
Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationClassType')));
50+
51+
Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationUnionType')));
4652

47-
Assert::same('Test\B', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationComplex')));
53+
Assert::same('string', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationNativeType')));
4854

49-
Assert::same('string', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'nativeType')));
55+
Assert::same('NS\A', PhpReflection::getReturnType(new \ReflectionMethod(NS\A::class, 'annotationSelfType')));
5056

5157
// class name expanding is NOT supported for global functions
52-
Assert::same('B', PhpReflection::getReturnType(new \ReflectionFunction(NS\classType::class)));
58+
Assert::same('B', PhpReflection::getReturnType(new \ReflectionFunction('NS\annotationClassType')));
5359
}

0 commit comments

Comments
 (0)