Skip to content

Commit 6097f69

Browse files
committed
Update tests
1 parent 5e6a193 commit 6097f69

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

Zend/tests/context_managers/basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ echo "After with() block\n";
1414

1515
?>
1616
--EXPECTF--
17-
string(21) "Manager::enterContext"
17+
Manager::enterContext()
1818
In with() block
1919
object(stdClass)#%d (0) {
2020
}
21-
string(20) "Manager::exitContext"
21+
Manager::exitContext(null)
2222
After with() block
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
class Manager implements ContextManager
4+
{
5+
public function __construct(private bool $rethrow = true)
6+
{
7+
}
8+
9+
public function enterContext(): mixed
10+
{
11+
echo __METHOD__, "()\n";
12+
return new stdClass;
13+
}
14+
15+
public function exitContext(?\Throwable $e = null): ?bool
16+
{
17+
echo __METHOD__, "(", ($e ? get_class($e) . '(' . $e->getMessage() . ')' : 'null'), ")\n";
18+
return !$this->rethrow;
19+
}
20+
}
21+
22+
?>

Zend/tests/context_managers/exitContext_can_swallow_exception.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ echo "After with() block\n";
1515

1616
?>
1717
--EXPECTF--
18-
string(21) "Manager::enterContext"
18+
Manager::enterContext()
1919
In with() block
2020
object(stdClass)#%d (0) {
2121
}
22-
string(20) "Manager::exitContext"
22+
Manager::exitContext(Exception(exception in with block))
2323
After with() block

Zend/tests/context_managers/variable_is_optional.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ echo "After with() block\n";
1313

1414
?>
1515
--EXPECT--
16-
string(21) "Manager::enterContext"
16+
Manager::enterContext()
1717
In with() block
18-
string(20) "Manager::exitContext"
18+
Manager::exitContext(null)
1919
After with() block

Zend/tests/context_managers/with_calls_exitContext_on_exception.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ echo "After with() block\n";
1919

2020
?>
2121
--EXPECTF--
22-
string(21) "Manager::enterContext"
22+
Manager::enterContext()
2323
In with() block
2424
object(stdClass)#%d (0) {
2525
}
26-
string(20) "Manager::exitContext"
26+
Manager::exitContext(Exception(exception in with block))
2727
Exception: exception in with block
2828
After with() block

Zend/tests/context_managers/with_handles_throwable.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ echo "After with() block\n";
1919

2020
?>
2121
--EXPECTF--
22-
string(21) "Manager::enterContext"
22+
Manager::enterContext()
2323
In with() block
2424
object(stdClass)#%d (0) {
2525
}
26-
string(20) "Manager::exitContext"
26+
Manager::exitContext(Error(error in with block))
2727
Error: error in with block
2828
After with() block

0 commit comments

Comments
 (0)