-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckoutTest.php
44 lines (34 loc) · 962 Bytes
/
CheckoutTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require_once "autoload.php";
class CheckoutTest extends PHPUnit_Framework_TestCase {
/** @test */
public function shouldReturnPriceOfA() {
$checkout = new Checkout();
$total = $checkout->sum('A');
$this->assertEquals(40,$total);
}
/** @test */
public function shouldReturnSum() {
$checkout = new Checkout();
$total = $checkout->sum('A');
$total = $checkout->sum('A');
$this->assertEquals(80,$total);
}
/** @test */
public function shouldReturnPriceOfB() {
$checkout = new Checkout();
$total = $checkout->sum('B');
$this->assertEquals(10,$total);
}
/** @test */
public function shouldCallProductRepo() {
$product = new Product('C',30);
$repoMock = $this->getMock('ProductRepo',array('get'));
$repoMock->expects($this->once())
->method('get')
->with('C')
->will($this->returnValue($product));
$checkout = new Checkout($repoMock);
$total = $checkout->sum('C');
}
}