@@ -14,7 +14,7 @@ class ExampleTest extends AbstractTestCase
1414 /**
1515 * As PHP5.3 does not support traits, __call is (a)bused instead of the trait.
1616 *
17- use \Potherca\PhpUnit\Traits\GetCompatibleExceptionNameTrait;
17+ use \Potherca\PhpUnit\Traits\GetCompatibleExceptionNameTrait;
1818 *
1919 * @param string $name
2020 * @param array $parameters
@@ -26,10 +26,28 @@ final public function __call($name, array $parameters)
2626 return \Potherca \PhpUnit \Shim \Util::traitShim ($ this , $ name , $ parameters );
2727 }
2828
29- public function testException ()
29+ public function testArithmeticError ()
3030 {
31- // Please not that `\TypeError::class` is NOT used, as this will cause an error if `TypeError` does not exist.
32- $ exceptionName = $ this ->getCompatibleExceptionName ('\TypeError ' );
31+ // Please note that `\ArithmeticError::class` is NOT used, as this will cause an error if `ArithmeticError` does not exist.
32+ $ exceptionName = $ this ->getCompatibleExceptionName ('\\ArithmeticError ' );
33+
34+ if (method_exists ($ this , 'expectExceptionMessage ' )) {
35+ /* PHPUnit ^5.2 | ^6.0 */
36+ $ this ->expectException ($ exceptionName );
37+ $ this ->expectExceptionMessage ('Bit shift by negative number ' );
38+ } else {
39+ /* PHPUnit ^4.3 | =< 5.6 */
40+ $ this ->setExpectedExceptionRegExp ($ exceptionName , 'Bit shift by negative number ' );
41+ }
42+
43+ /** @noinspection PhpExpressionResultUnusedInspection */
44+ 1 >> -1 ;
45+ }
46+
47+ public function testArgumentCountError ()
48+ {
49+ // Please note that `\ArgumentCountError::class` is NOT used, as this will cause an error if `ArgumentCountError` does not exist.
50+ $ exceptionName = $ this ->getCompatibleExceptionName ('\\ArgumentCountError ' );
3351
3452 if (method_exists ($ this , 'expectExceptionMessageRegExp ' )) {
3553 /* PHPUnit ^5.2 | ^6.0 */
@@ -40,8 +58,43 @@ public function testException()
4058 $ this ->setExpectedExceptionRegExp ($ exceptionName , '/none given|0 passed/ ' );
4159 }
4260
43- $ example = new Example ();
61+ /** @noinspection PhpParamsInspection */
62+ new Example ();
63+ }
64+
65+ public function testDivisionByZeroError ()
66+ {
67+ // Please note that `\DivisionByZeroError::class` is NOT used, as this will cause an error if `DivisionByZeroError` does not exist.
68+ $ exceptionName = $ this ->getCompatibleExceptionName ('\\DivisionByZeroError ' );
69+
70+ if (method_exists ($ this , 'expectExceptionMessage ' )) {
71+ /* PHPUnit ^5.2 | ^6.0 */
72+ $ this ->expectException ($ exceptionName );
73+ $ this ->expectExceptionMessage ('Division by zero ' );
74+ } else {
75+ /* PHPUnit ^4.3 | =< 5.6 */
76+ $ this ->setExpectedException ($ exceptionName , 'Division by zero ' );
77+ }
78+
79+ /** @noinspection PhpExpressionResultUnusedInspection */
80+ 0 / 0 ;
81+ }
82+
83+ public function testTypeError ()
84+ {
85+ // Please note that `\TypeError::class` is NOT used, as this will cause an error if `TypeError` does not exist.
86+ $ exceptionName = $ this ->getCompatibleExceptionName ('\\TypeError ' );
87+
88+ if (method_exists ($ this , 'expectExceptionMessageRegExp ' )) {
89+ /* PHPUnit ^5.2 | ^6.0 */
90+ $ this ->expectException ($ exceptionName );
91+ $ this ->expectExceptionMessageRegExp ('/must be of the type array|must be an array/ ' );
92+ } else {
93+ /* PHPUnit ^4.3 | =< 5.6 */
94+ $ this ->setExpectedExceptionRegExp ($ exceptionName , '/must be of the type array|must be an array/ ' );
95+ }
4496
45- var_dump ($ example );
97+ /** @noinspection PhpParamsInspection */
98+ new Example (false );
4699 }
47100}
0 commit comments