-
Notifications
You must be signed in to change notification settings - Fork 1
/
TestCustomer.php
139 lines (112 loc) · 3.72 KB
/
TestCustomer.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* Created by JetBrains PhpStorm.
* User: merklik
* Date: 4/27/13
* Time: 11:12 AM
* To change this template use File | Settings | File Templates.
*/
//namespace Refactoring;
require_once('Customer.php');
require_once('Rental.php');
require_once('Movie.php');
class TestCustomer extends PHPUnit_Framework_TestCase
{
public $customer;
public function setUp(){
$this->customer = new \Refactoring\Customer("Joe");
}
/**
* @test
*/
public function statment_OneRental_Childrens()
{
//Arrange
$this->addRental("Rambo 1", \Refactoring\Movie::CHILDRENS, 1);
// Act
$s = $this->customer->statement();
// Assert
$expected = "Rental Record for Joe\n\tRambo 1 1.5\nAmount owed is 1.5\nYou earned 1 frequent renter points";
$this->assertEquals($expected, $s);
}
/**
* @test
*/
public function statment_TwoRentalsOneDay_NewRelease()
{
// Arrange
$this->addRental("Rambo 1", \Refactoring\Movie::CHILDRENS, 1);
$this->addRental("Rambo 2", \Refactoring\Movie::NEW_RELEASE, 1);
// Act
$s = $this->customer->statement();
// Assert
$expected = "Rental Record for Joe\n\tRambo 1 1.5\n\tRambo 2 3\nAmount owed is 4.5\nYou earned 2 frequent renter points";
$this->assertEquals($expected, $s);
}
/**
* @test
*/
public function statment_TwoRentals_NewRelease()
{
// Arrange
$this->addRental("Rambo 1", \Refactoring\Movie::CHILDRENS, 1);
$this->addRental("Rambo 2", \Refactoring\Movie::NEW_RELEASE, 2);
// Act
$s = $this->customer->statement();
// Assert
$expected = "Rental Record for Joe\n\tRambo 1 1.5\n\tRambo 2 6\nAmount owed is 7.5\nYou earned 3 frequent renter points";
$this->assertEquals($expected, $s);
}
/**
* @test
*/
public function statment_ThreeRentals_NewRelease()
{
// Arrange
$this->addRental("Rambo 1", \Refactoring\Movie::CHILDRENS, 1);
$this->addRental("Rambo 2", \Refactoring\Movie::NEW_RELEASE, 2);
$this->addRental("Rambo 3", \Refactoring\Movie::REGULAR, 1);
// Act
$s = $this->customer->statement();
//Assert
$expected = "Rental Record for Joe\n\tRambo 1 1.5\n\tRambo 2 6\n\tRambo 3 2\nAmount owed is 9.5\nYou earned 4 frequent renter points";
$this->assertEquals($expected, $s);
}
/**
* @test
*/
public function statment_ThreeRentalsManyDays()
{
// Arrange
$this->addRental("Rambo 1", \Refactoring\Movie::CHILDRENS, 4);
$this->addRental("Rambo 2", \Refactoring\Movie::NEW_RELEASE, 4);
$this->addRental("Rambo 3", \Refactoring\Movie::REGULAR, 4);
// Act
$s = $this->customer->statement();
//Assert
$expected = "Rental Record for Joe\n\tRambo 1 3\n\tRambo 2 12\n\tRambo 3 5\nAmount owed is 20\nYou earned 4 frequent renter points";
$this->assertEquals($expected, $s);
}
/**
* @test
*/
public function statmentHTML_OneRental_Childrens()
{
//Arrange
$this->addRental("Rambo 1", \Refactoring\Movie::CHILDRENS, 1);
// Act
$s = $this->customer->statementHTML();
// Assert
$expected = "<HTML><BODY>Rental Record for Joe<br/>Rambo 1: 1.5<br/>Amount owed is 1.5<br/>You earned 1 frequent renter points</BODY></HTML>";
$this->assertEquals($expected, $s);
}
/**
* @param $title
* @param $priceCode
* @param $days
*/
public function addRental($title, $priceCode, $days)
{
$this->customer->addRental(new \Refactoring\Rental(new \Refactoring\Movie($title, $priceCode), $days));
}
}