Skip to content

Commit 0989481

Browse files
committed
I cleaned up CalculatorTest a little and added some documentation, but nothing major.
1 parent b393b4c commit 0989481

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

CalculatorTest.php

+26-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
<?php
22

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+
*/
39
require_once 'PHPUnit/Framework.php';
410

11+
12+
/**
13+
* Require the class we want to test: Calculator
14+
*/
515
require_once 'Calculator.php';
616

717
class CalculatorTest
818
extends PHPUnit_Framework_TestCase
919
{
1020

11-
public function setUp(){
21+
public function setUp ( )
22+
{
1223
$this->Calc = new Calculator;
13-
}
24+
} // END setUp
25+
1426

1527
public function test_add ( )
1628
{
17-
18-
1929
$this->assertEquals(2, $this->Calc->add(1,1),
2030
'The $this->Calc should be able to add 1 + 1'
2131
);
@@ -36,7 +46,6 @@ public function test_add ( )
3646

3747
public function test_subtract ( )
3848
{
39-
4049
$this->assertEquals(1, $this->Calc->sub(2,1),
4150
'The $this->Calc should be able to subtract 2 - 1'
4251
);
@@ -52,20 +61,21 @@ public function test_subtract ( )
5261

5362
} // END test_subtract
5463

55-
public function test_multiply(){
56-
64+
65+
public function test_multiply ( )
66+
{
5767
$result = $this->Calc->multiply(10, 10);
68+
5869
$this->assertEquals(100, $result,
5970
"10 x 10 should be 100 but it's $result"
6071
);
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
6979

7080
public function test_division(){
7181

@@ -95,4 +105,4 @@ public function test_add_multvals(){
95105

96106

97107

98-
} // END CalculatorTest
108+
} // END CalculatorTest

0 commit comments

Comments
 (0)