| @@ 187-217 (lines=31) @@ | ||
| 184 | $this->assertEquals(($weight + $weight_option) * $quantity, $this->basket->weight()); |
|
| 185 | } |
|
| 186 | ||
| 187 | public function testPriceOption() |
|
| 188 | { |
|
| 189 | $weight = rand(200, 300); |
|
| 190 | $weight_option = rand(50, 800); |
|
| 191 | $quantity = rand(1, 10); |
|
| 192 | ||
| 193 | $this->basket->insert([ |
|
| 194 | 'id' => 'foo', |
|
| 195 | 'name' => 'bar', |
|
| 196 | 'price' => 100, |
|
| 197 | 'tax' => 25, |
|
| 198 | 'quantity' => 1, |
|
| 199 | 'weight' => $weight, |
|
| 200 | 'options' => [ |
|
| 201 | [ |
|
| 202 | 'name' => 'size', |
|
| 203 | 'price' => 50, |
|
| 204 | 'weight' => $weight_option, |
|
| 205 | ], |
|
| 206 | [ |
|
| 207 | 'name' => 'color', |
|
| 208 | 'price' => 50, |
|
| 209 | 'weight' => $weight_option, |
|
| 210 | ], |
|
| 211 | ], |
|
| 212 | ]); |
|
| 213 | ||
| 214 | // Test that the total price is being calculated successfully |
|
| 215 | $this->assertEquals(250, $this->basket->total(true)); |
|
| 216 | $this->assertEquals(200, $this->basket->total(false)); |
|
| 217 | } |
|
| 218 | ||
| 219 | public function testPriceDistractOption() |
|
| 220 | { |
|
| @@ 219-248 (lines=30) @@ | ||
| 216 | $this->assertEquals(200, $this->basket->total(false)); |
|
| 217 | } |
|
| 218 | ||
| 219 | public function testPriceDistractOption() |
|
| 220 | { |
|
| 221 | $weight = rand(200, 300); |
|
| 222 | $weight_option = rand(50, 800); |
|
| 223 | ||
| 224 | $this->basket->insert([ |
|
| 225 | 'id' => 'foo', |
|
| 226 | 'name' => 'bar', |
|
| 227 | 'price' => 100, |
|
| 228 | 'tax' => 25, |
|
| 229 | 'quantity' => 1, |
|
| 230 | 'weight' => $weight, |
|
| 231 | 'options' => [ |
|
| 232 | [ |
|
| 233 | 'name' => 'size', |
|
| 234 | 'price' => -20, |
|
| 235 | 'weight' => $weight_option, |
|
| 236 | ], |
|
| 237 | [ |
|
| 238 | 'name' => 'color', |
|
| 239 | 'price' => 50, |
|
| 240 | 'weight' => $weight_option, |
|
| 241 | ], |
|
| 242 | ], |
|
| 243 | ]); |
|
| 244 | ||
| 245 | // Test that the total price is being calculated successfully |
|
| 246 | $this->assertEquals(162.50, $this->basket->total(true)); |
|
| 247 | $this->assertEquals(130, $this->basket->total(false)); |
|
| 248 | } |
|
| 249 | ||
| 250 | public function testFind() |
|
| 251 | { |
|