File tree Expand file tree Collapse file tree 2 files changed +164
-0
lines changed
Expand file tree Collapse file tree 2 files changed +164
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ namespace PHPJava \Tests ;
3+
4+ use PHPUnit \Framework \TestCase ;
5+
6+ class IntegerCalculateTest extends Base
7+ {
8+ protected $ fixtures = [
9+ 'IntegerCalculateTest ' ,
10+ ];
11+
12+ private function call ($ name , ...$ parameters )
13+ {
14+ return $ this ->initiatedJavaClasses ['IntegerCalculateTest ' ]
15+ ->getInvoker ()
16+ ->getStatic ()
17+ ->getMethods ()
18+ ->call (
19+ $ name ,
20+ ...$ parameters
21+ );
22+ }
23+
24+ public function testIntAdd ()
25+ {
26+ $ this ->assertEquals (
27+ "30 " ,
28+ $ this ->call (
29+ 'intAdd ' ,
30+ 10 ,
31+ 20
32+ )
33+ );
34+ }
35+
36+ public function testIntSub ()
37+ {
38+
39+ $ this ->assertEquals (
40+ "5 " ,
41+ $ this ->call (
42+ 'intSub ' ,
43+ 10 ,
44+ 5
45+ )
46+ );
47+ }
48+
49+ public function testIntNegativeSub ()
50+ {
51+ $ this ->assertEquals (
52+ "-10 " ,
53+ $ this ->call (
54+ 'intSub ' ,
55+ 10 ,
56+ 20
57+ )
58+ );
59+ }
60+
61+
62+ public function testIntMul ()
63+ {
64+
65+ $ this ->assertEquals (
66+ "50 " ,
67+ $ this ->call (
68+ 'intMul ' ,
69+ 10 ,
70+ 5
71+ )
72+ );
73+ }
74+
75+
76+ public function testIntAddFromOtherMethod ()
77+ {
78+ $ this ->assertEquals (
79+ "30 " ,
80+ $ this ->call (
81+ 'intAddFromOtherMethod ' ,
82+ 10 ,
83+ 20
84+ )
85+ );
86+ }
87+
88+ public function testIntSubFromOtherMethod ()
89+ {
90+
91+ $ this ->assertEquals (
92+ "5 " ,
93+ $ this ->call (
94+ 'intSubFromOtherMethod ' ,
95+ 10 ,
96+ 5
97+ )
98+ );
99+ }
100+
101+ public function testIntNegativeSubFromOtherMethod ()
102+ {
103+ $ this ->assertEquals (
104+ "-10 " ,
105+ $ this ->call (
106+ 'intSubFromOtherMethod ' ,
107+ 10 ,
108+ 20
109+ )
110+ );
111+ }
112+
113+
114+ public function testIntMulFromOtherMethod ()
115+ {
116+
117+ $ this ->assertEquals (
118+ "50 " ,
119+ $ this ->call (
120+ 'intMulFromOtherMethod ' ,
121+ 10 ,
122+ 5
123+ )
124+ );
125+ }
126+ }
Original file line number Diff line number Diff line change 1+ class IntegerCalculateTest
2+ {
3+ private static int returnInt (int n )
4+ {
5+ return n ;
6+ }
7+
8+ public static int intAdd (int value1 , int value2 )
9+ {
10+ return value1 + value2 ;
11+ }
12+
13+ public static int intSub (int value1 , int value2 )
14+ {
15+ return value1 - value2 ;
16+ }
17+
18+ public static int intMul (int value1 , int value2 )
19+ {
20+ return value1 * value2 ;
21+ }
22+
23+ public static int intAddFromOtherMethod (int value1 , int value2 )
24+ {
25+ return returnInt (value1 ) + returnInt (value2 );
26+ }
27+
28+ public static int intSubFromOtherMethod (int value1 , int value2 )
29+ {
30+ return returnInt (value1 ) - returnInt (value2 );
31+ }
32+
33+ public static int intMulFromOtherMethod (int value1 , int value2 )
34+ {
35+ return returnInt (value1 ) * returnInt (value2 );
36+ }
37+
38+ }
You can’t perform that action at this time.
0 commit comments