11<?php
22namespace PHPJava \Tests \Packages \java \io ;
33
4+ use PHPJava \Exceptions \UncaughtException ;
5+ use PHPJava \Packages \java \lang \NullPointerException ;
46use PHPJava \Tests \Base ;
57
68class JavaIoPrintStreamClassTest extends Base
@@ -9,17 +11,23 @@ class JavaIoPrintStreamClassTest extends Base
911 'JavaIoPrintStreamClassTest ' ,
1012 ];
1113
14+ protected $ expectedSpecialException ;
15+
1216 private function call ($ method , ...$ arguments )
1317 {
1418 ob_start ();
15- static ::$ initiatedJavaClasses ['JavaIoPrintStreamClassTest ' ]
16- ->getInvoker ()
17- ->getStatic ()
18- ->getMethods ()
19- ->call (
20- $ method ,
21- ...$ arguments
22- );
19+ try {
20+ static ::$ initiatedJavaClasses ['JavaIoPrintStreamClassTest ' ]
21+ ->getInvoker ()
22+ ->getStatic ()
23+ ->getMethods ()
24+ ->call (
25+ $ method ,
26+ ...$ arguments
27+ );
28+ } catch (UncaughtException $ e ) {
29+ $ this ->expectedSpecialException = get_class ($ e ->getPrevious ());
30+ }
2331 return ob_get_clean ();
2432 }
2533
@@ -35,6 +43,16 @@ public function testPrintlnWithStringParams()
3543 $ this ->assertEquals ("Hello World \n" , $ result );
3644 }
3745
46+ public function testPrintlnWithNullStringParams ()
47+ {
48+ $ result = $ this ->call (explode (':: ' , __METHOD__ )[1 ]);
49+ $ this ->assertEquals ("null \n" , $ result );
50+ $ this ->assertSame (
51+ NullPointerException::class,
52+ $ this ->expectedSpecialException
53+ );
54+ }
55+
3856 public function testPrintlnWithCharParams ()
3957 {
4058 $ result = $ this ->call (explode (':: ' , __METHOD__ )[1 ]);
@@ -47,6 +65,16 @@ public function testPrintlnWithCharArrayParams()
4765 $ this ->assertEquals ("ABC \n" , $ result );
4866 }
4967
68+ public function testPrintlnWithNullCharArrayParams ()
69+ {
70+ $ result = $ this ->call (explode (':: ' , __METHOD__ )[1 ]);
71+ $ this ->assertEquals ("\n" , $ result );
72+ $ this ->assertSame (
73+ NullPointerException::class,
74+ $ this ->expectedSpecialException
75+ );
76+ }
77+
5078 public function testPrintlnWithFloatParams ()
5179 {
5280 $ result = $ this ->call (explode (':: ' , __METHOD__ )[1 ]);
@@ -74,6 +102,16 @@ public function testPrintWithStringParams()
74102 $ this ->assertEquals ('Hello World ' , $ result );
75103 }
76104
105+ public function testPrintWithNullStringParams ()
106+ {
107+ $ result = $ this ->call (explode (':: ' , __METHOD__ )[1 ]);
108+ $ this ->assertEquals ('null ' , $ result );
109+ $ this ->assertSame (
110+ NullPointerException::class,
111+ $ this ->expectedSpecialException
112+ );
113+ }
114+
77115 public function testPrintWithCharParams ()
78116 {
79117 $ result = $ this ->call (explode (':: ' , __METHOD__ )[1 ]);
@@ -86,6 +124,16 @@ public function testPrintWithCharArrayParams()
86124 $ this ->assertEquals ('ABC ' , $ result );
87125 }
88126
127+ public function testPrintWithNullCharArrayParams ()
128+ {
129+ $ result = $ this ->call (explode (':: ' , __METHOD__ )[1 ]);
130+ $ this ->assertEquals ('' , $ result );
131+ $ this ->assertSame (
132+ NullPointerException::class,
133+ $ this ->expectedSpecialException
134+ );
135+ }
136+
89137 public function testPrintWithFloatParams ()
90138 {
91139 $ result = $ this ->call (explode (':: ' , __METHOD__ )[1 ]);
0 commit comments