Skip to content

Commit b4df02d

Browse files
committed
refactor: adjusted test error message formatting
see: #18757 (comment)
1 parent c9ebae4 commit b4df02d

7 files changed

+24
-24
lines changed

Zend/tests/property_hooks/readonly_class_property_backed.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ var_dump($t->prop);
2525
try {
2626
$t->set(43);
2727
} catch (Error $e) {
28-
echo $e->getMessage(), "\n";
28+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
2929
}
3030
try {
3131
$t->prop = 43;
3232
} catch (Error $e) {
33-
echo $e->getMessage(), "\n";
33+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
3434
}
3535
var_dump($t->prop);
3636
?>
3737
--EXPECT--
3838
int(42)
39-
Cannot modify readonly property Test::$prop
40-
Cannot modify protected(set) readonly property Test::$prop from global scope
39+
Error: Cannot modify readonly property Test::$prop
40+
Error: Cannot modify protected(set) readonly property Test::$prop from global scope
4141
int(42)

Zend/tests/property_hooks/readonly_class_property_backed_promoted.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ var_dump($t->prop);
2323
try {
2424
$t->set(43);
2525
} catch (Error $e) {
26-
echo $e->getMessage(), "\n";
26+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
2727
}
2828
try {
2929
$t->prop = 43;
3030
} catch (Error $e) {
31-
echo $e->getMessage(), "\n";
31+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
3232
}
3333
var_dump($t->prop);
3434
?>
3535
--EXPECT--
3636
int(42)
37-
Cannot modify readonly property Test::$prop
38-
Cannot modify protected(set) readonly property Test::$prop from global scope
37+
Error: Cannot modify readonly property Test::$prop
38+
Error: Cannot modify protected(set) readonly property Test::$prop from global scope
3939
int(42)

Zend/tests/property_hooks/readonly_property_backed.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ var_dump($t->prop);
2525
try {
2626
$t->set(43);
2727
} catch (Error $e) {
28-
echo $e->getMessage(), "\n";
28+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
2929
}
3030
try {
3131
$t->prop = 43;
3232
} catch (Error $e) {
33-
echo $e->getMessage(), "\n";
33+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
3434
}
3535
var_dump($t->prop);
3636

@@ -79,8 +79,8 @@ final readonly class Foo3
7979
?>
8080
--EXPECT--
8181
int(42)
82-
Cannot modify readonly property Test::$prop
83-
Cannot modify protected(set) readonly property Test::$prop from global scope
82+
Error: Cannot modify readonly property Test::$prop
83+
Error: Cannot modify protected(set) readonly property Test::$prop from global scope
8484
int(42)
8585
array(3) {
8686
[0]=>

Zend/tests/property_hooks/readonly_property_backed_inheritance_3.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ $t->getParentValue();
5050
try {
5151
$t->setAgain(); // cannot write, readonly
5252
} catch (Error $e) {
53-
echo $e->getMessage(), "\n";
53+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
5454
}
5555

5656
try {
5757
$t->prop = 43; // cannot write, visibility
5858
} catch (Error $e) {
59-
echo $e->getMessage(), "\n";
59+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
6060
}
6161

6262
?>
@@ -93,5 +93,5 @@ In ChildClass::$prop::get():
9393
parent::$prop::get(): 911
9494
$this->prop: 911
9595
$this->prop * 2: 1822
96-
Cannot modify readonly property ChildClass::$prop
97-
Cannot modify protected(set) readonly property ChildClass::$prop from global scope
96+
Error: Cannot modify readonly property ChildClass::$prop
97+
Error: Cannot modify protected(set) readonly property ChildClass::$prop from global scope

Zend/tests/property_hooks/readonly_property_backed_promoted.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ var_dump($t->prop);
2323
try {
2424
$t->set(43);
2525
} catch (Error $e) {
26-
echo $e->getMessage(), "\n";
26+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
2727
}
2828
try {
2929
$t->prop = 43;
3030
} catch (Error $e) {
31-
echo $e->getMessage(), "\n";
31+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
3232
}
3333
var_dump($t->prop);
3434
?>
3535
--EXPECT--
3636
int(42)
37-
Cannot modify readonly property Test::$prop
38-
Cannot modify protected(set) readonly property Test::$prop from global scope
37+
Error: Cannot modify readonly property Test::$prop
38+
Error: Cannot modify protected(set) readonly property Test::$prop from global scope
3939
int(42)

Zend/tests/property_hooks/readonly_rfc_example_lazy_product.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var_dump($product);
7777
try {
7878
$categoryId->setValue($product, '420');
7979
} catch (Error $e) {
80-
echo $e->getMessage(), "\n";
80+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
8181
}
8282

8383
?>
@@ -102,4 +102,4 @@ object(LazyProduct)#2 (5) {
102102
["categoryId":"LazyProduct":private]=>
103103
string(2) "42"
104104
}
105-
Cannot modify readonly property LazyProduct::$categoryId
105+
Error: Cannot modify readonly property LazyProduct::$categoryId

Zend/tests/property_hooks/readonly_rfc_example_validation.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var_dump($one);
1717
try {
1818
$two = new PositivePoint(0,1);
1919
} catch (Error $e) {
20-
echo $e->getMessage(), "\n";
20+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
2121
}
2222

2323

@@ -29,4 +29,4 @@ object(PositivePoint)#1 (2) {
2929
["y"]=>
3030
int(1)
3131
}
32-
Value must be greater 0
32+
Error: Value must be greater 0

0 commit comments

Comments
 (0)