Skip to content

Commit 3baad7a

Browse files
Reflection: add regression tests for printing boolean constant values
Add regression tests for the output of `ReflectionClassConstant::__toString()` and `ReflectionConstant::__toString()` when the value of the constant is boolean `true` or `false`. The `true` cases are already covered by some existing tests, but it seems that the `false` cases are currently untested.
1 parent 1f1d223 commit 3baad7a

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
ReflectionClassConstant::__toString() and class constant display
3+
--FILE--
4+
<?php
5+
6+
class Demo {
7+
public const IS_TRUE = true;
8+
public const IS_FALSE = false;
9+
}
10+
11+
echo new ReflectionClassConstant(Demo::class, 'IS_TRUE');
12+
echo new ReflectionClassConstant(Demo::class, 'IS_FALSE');
13+
14+
echo new ReflectionClass(Demo::class);
15+
16+
?>
17+
--EXPECTF--
18+
Constant [ public bool IS_TRUE ] { 1 }
19+
Constant [ public bool IS_FALSE ] { }
20+
Class [ <user> class Demo ] {
21+
@@ %s %d-%d
22+
23+
- Constants [2] {
24+
Constant [ public bool IS_TRUE ] { 1 }
25+
Constant [ public bool IS_FALSE ] { }
26+
}
27+
28+
- Static properties [0] {
29+
}
30+
31+
- Static methods [0] {
32+
}
33+
34+
- Properties [0] {
35+
}
36+
37+
- Methods [0] {
38+
}
39+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
ReflectionConstant::__toString()
3+
--FILE--
4+
<?php
5+
6+
const IS_TRUE = true;
7+
const IS_FALSE = false;
8+
9+
echo new ReflectionConstant('IS_TRUE');
10+
echo new ReflectionConstant('IS_FALSE');
11+
12+
?>
13+
--EXPECT--
14+
Constant [ bool IS_TRUE ] { 1 }
15+
Constant [ bool IS_FALSE ] { }

0 commit comments

Comments
 (0)