1
1
<?php
2
2
3
+ /**
4
+ * The PHPUnit Framework is required to run unit tests with PHPUnit.
5
+ * The file "PHPUnit/Framework.php" has all the other includes that
6
+ * we need, so we can just require that file. However, we have to
7
+ * require_once() so we don't accidentally load it twice.
8
+ */
3
9
require_once 'PHPUnit/Framework.php ' ;
4
10
11
+
12
+ /**
13
+ * Require the class we want to test: Calculator
14
+ */
5
15
require_once 'Calculator.php ' ;
6
16
7
17
class CalculatorTest
8
18
extends PHPUnit_Framework_TestCase
9
19
{
10
20
11
- public function setUp (){
21
+ public function setUp ( )
22
+ {
12
23
$ this ->Calc = new Calculator ;
13
- }
24
+ } // END setUp
25
+
14
26
15
27
public function test_add ( )
16
28
{
17
-
18
-
19
29
$ this ->assertEquals (2 , $ this ->Calc ->add (1 ,1 ),
20
30
'The $this->Calc should be able to add 1 + 1 '
21
31
);
@@ -36,7 +46,6 @@ public function test_add ( )
36
46
37
47
public function test_subtract ( )
38
48
{
39
-
40
49
$ this ->assertEquals (1 , $ this ->Calc ->sub (2 ,1 ),
41
50
'The $this->Calc should be able to subtract 2 - 1 '
42
51
);
@@ -52,20 +61,21 @@ public function test_subtract ( )
52
61
53
62
} // END test_subtract
54
63
55
- public function test_multiply (){
56
-
64
+
65
+ public function test_multiply ( )
66
+ {
57
67
$ result = $ this ->Calc ->multiply (10 , 10 );
68
+
58
69
$ this ->assertEquals (100 , $ result ,
59
70
"10 x 10 should be 100 but it's $ result "
60
71
);
61
- $ result = $ this ->Calc ->multiply (10 , 11 );
62
- $ this ->assertEquals (110 , $ result ,
63
- "10 X 11 should be 110 but it's $ result "
64
- );
65
-
66
-
67
-
68
- }
72
+
73
+ $ result = $ this ->Calc ->multiply (10 , 11 );
74
+
75
+ $ this ->assertEquals (110 , $ result ,
76
+ "10 X 11 should be 110 but it's $ result "
77
+ );
78
+ } // END test_multiply
69
79
70
80
public function test_division (){
71
81
@@ -95,4 +105,4 @@ public function test_add_multvals(){
95
105
96
106
97
107
98
- } // END CalculatorTest
108
+ } // END CalculatorTest
0 commit comments