Skip to content

Commit db4152c

Browse files
committed
tests: consolidated
1 parent 8919116 commit db4152c

14 files changed

+74
-213
lines changed

tests/Utils/Reflection.getParameterDefaultValue.php71.phpt

Lines changed: 0 additions & 40 deletions
This file was deleted.

tests/Utils/Reflection.getParameterDefaultValue.phpt

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,38 @@ Assert::exception(function () {
1717
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'a'));
1818
}, ReflectionException::class);
1919

20-
Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'b')));
20+
Assert::same('abc', Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'b')));
2121

22-
Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'c')));
22+
Assert::same('abc', Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'c')));
2323

24-
Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'd')));
24+
Assert::same('abc', Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'd')));
2525

26-
Assert::same(NS\Bar::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'e')));
26+
Assert::same('abc', Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'e')));
27+
28+
Assert::same('abc', Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'f')));
29+
30+
Assert::same('abc', Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'g')));
31+
32+
Assert::same('abc', Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'h')));
33+
34+
Assert::exception(function () {
35+
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'i'));
36+
}, ReflectionException::class, 'Unable to resolve constant self::UNDEFINED used as default value of $i in NS\Foo::method().');
2737

2838
Assert::exception(function () {
29-
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'f'));
30-
}, ReflectionException::class, 'Unable to resolve constant self::UNDEFINED used as default value of $f in NS\Foo::method().');
39+
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'j'));
40+
}, ReflectionException::class, 'Unable to resolve constant NS\\Foo::UNDEFINED used as default value of $j in NS\Foo::method().');
41+
42+
Assert::same(NS\Bar::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'k')));
3143

3244
Assert::exception(function () {
33-
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'g'));
34-
}, ReflectionException::class, 'Unable to resolve constant NS\Undefined::ANY used as default value of $g in NS\Foo::method().');
45+
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'l'));
46+
}, ReflectionException::class, 'Unable to resolve constant NS\Undefined::ANY used as default value of $l in NS\Foo::method().');
3547

36-
Assert::same(DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'h')));
48+
Assert::same(DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'm')));
3749

3850
Assert::exception(function () {
39-
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'i'));
40-
}, ReflectionException::class, 'Unable to resolve constant NS\UNDEFINED used as default value of $i in NS\Foo::method().');
51+
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'n'));
52+
}, ReflectionException::class, 'Unable to resolve constant NS\UNDEFINED used as default value of $n in NS\Foo::method().');
4153

42-
Assert::same(NS\NS_DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'j')));
54+
Assert::same(NS\NS_DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'o')));

tests/Utils/Reflection.getParameterType.php71.phpt

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/Utils/Reflection.getParameterType.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require __DIR__ . '/../bootstrap.php';
1616

1717
class A
1818
{
19-
public function method(Undeclared $undeclared, B $b, array $array, callable $callable, self $self, $none)
19+
public function method(Undeclared $undeclared, B $b, array $array, callable $callable, self $self, $none, ?B $nullable)
2020
{
2121
}
2222
}
@@ -37,7 +37,7 @@ Assert::same('array', Reflection::getParameterType($params[2]));
3737
Assert::same('callable', Reflection::getParameterType($params[3]));
3838
Assert::same('A', Reflection::getParameterType($params[4]));
3939
Assert::null(Reflection::getParameterType($params[5]));
40-
40+
Assert::same('Test\B', Reflection::getParameterType($params[6]));
4141

4242
$method = new ReflectionMethod('AExt', 'methodExt');
4343
$params = $method->getParameters();

tests/Utils/Reflection.getReturnType.php7.phpt

Lines changed: 0 additions & 67 deletions
This file was deleted.

tests/Utils/Reflection.getReturnType.php71.phpt renamed to tests/Utils/Reflection.getReturnType.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ namespace NS
3232
}
3333

3434

35+
public function parentType(): parent
36+
{
37+
}
38+
39+
3540
public function nullableClassType(): ?B
3641
{
3742
}
@@ -46,6 +51,13 @@ namespace NS
4651
{
4752
}
4853
}
54+
55+
class AExt extends A
56+
{
57+
public function parentTypeExt(): parent
58+
{
59+
}
60+
}
4961
}
5062

5163
namespace
@@ -64,9 +76,13 @@ namespace
6476

6577
Assert::same('NS\A', Reflection::getReturnType(new \ReflectionMethod(NS\A::class, 'selfType')));
6678

79+
Assert::same('parent', Reflection::getReturnType(new \ReflectionMethod(NS\A::class, 'parentType')));
80+
6781
Assert::same('Test\B', Reflection::getReturnType(new \ReflectionMethod(NS\A::class, 'nullableClassType')));
6882

6983
Assert::same('string', Reflection::getReturnType(new \ReflectionMethod(NS\A::class, 'nullableNativeType')));
7084

7185
Assert::same('NS\A', Reflection::getReturnType(new \ReflectionMethod(NS\A::class, 'nullableSelfType')));
86+
87+
Assert::same('NS\A', Reflection::getReturnType(new \ReflectionMethod(NS\AExt::class, 'parentTypeExt')));
7288
}

tests/Utils/Strings.Regexp.errors.backtrack.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ function cb()
4040

4141

4242
Assert::exception(function () {
43-
Strings::replace('0123456789', '#.*\d\d#', Nette\Utils\Callback::closure('cb'));
43+
Strings::replace('0123456789', '#.*\d\d#', Closure::fromCallable('cb'));
4444
}, Nette\Utils\RegexpException::class, 'Backtrack limit was exhausted (pattern: #.*\d\d#)');

tests/Utils/Strings.Regexp.errors.compilation.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ function cb()
4141

4242

4343
Assert::exception(function () {
44-
Strings::replace('0123456789', '#*#', Nette\Utils\Callback::closure('cb'));
44+
Strings::replace('0123456789', '#*#', Closure::fromCallable('cb'));
4545
}, Nette\Utils\RegexpException::class, 'Compilation failed: %a% in pattern: #*#');
4646

4747
Assert::exception(function () {
48-
Strings::replace('0123456789', ['##', '#*#'], Nette\Utils\Callback::closure('cb'));
48+
Strings::replace('0123456789', ['##', '#*#'], Closure::fromCallable('cb'));
4949
}, Nette\Utils\RegexpException::class, 'Compilation failed: %a% in pattern: ## or #*#');

tests/Utils/Strings.Regexp.errors.utf8.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ function cb()
3737

3838

3939
Assert::exception(function () {
40-
Strings::replace("0123456789\xFF", '#\d#u', Nette\Utils\Callback::closure('cb'));
40+
Strings::replace("0123456789\xFF", '#\d#u', Closure::fromCallable('cb'));
4141
}, Nette\Utils\RegexpException::class, 'Malformed UTF-8 data (pattern: #\d#u)');

tests/Utils/Strings.replace().php53.phpt

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)