-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathcall_private.phpt
56 lines (50 loc) · 2.07 KB
/
call_private.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
--TEST--
swoole_timer: call private method
--SKIPIF--
<?php require __DIR__ . '/../include/skipif.inc'; ?>
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
class Test
{
private static function foo() { }
private function bar() { }
}
// method not exists
//------------------------------------------------------------------------------------------------------------------
$pm = ProcessManager::exec(function () {
Swoole\Timer::After(1, [Test::class, 'not_exist']);
});
$pm->expectExitCode(255);
$output = $pm->getChildOutput();
if (PHP_VERSION_ID < 80000) {
Assert::contains($output, 'Uncaught TypeError: Argument 2 passed to Swoole\Timer::after() must be callable, array given');
} else {
Assert::contains($output, 'Uncaught TypeError: Swoole\Timer::after(): Argument #2 ($callback) must be a valid callback, class Test does not have a method "not_exist"');
}
// private method
//------------------------------------------------------------------------------------------------------------------
$pm = ProcessManager::exec(function () {
Swoole\Timer::After(1, [Test::class, 'foo']);
});
$pm->expectExitCode(255);
$output = $pm->getChildOutput();
if (PHP_VERSION_ID < 80000) {
Assert::contains($output, 'Uncaught TypeError: Argument 2 passed to Swoole\Timer::after() must be callable, array given');
} else {
Assert::contains($output, 'Swoole\Timer::after(): Argument #2 ($callback) must be a valid callback, cannot access private method Test::foo()');
}
// private method
//------------------------------------------------------------------------------------------------------------------
$pm = ProcessManager::exec(function () {
Swoole\Timer::After(1, [new Test, 'bar']);
});
$pm->expectExitCode(255);
$output = $pm->getChildOutput();
if (PHP_VERSION_ID < 80000) {
Assert::contains($output, 'Uncaught TypeError: Argument 2 passed to Swoole\Timer::after() must be callable, array given');
} else {
Assert::contains($output, 'Swoole\Timer::after(): Argument #2 ($callback) must be a valid callback, cannot access private method Test::bar()');
}
?>
--EXPECT--