Conditions | 4 |
Paths | 27 |
Total Lines | 26 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | public function testValidation() |
||
16 | { |
||
17 | try { |
||
18 | new CartItem('foo name', 0, 99); |
||
19 | $this->fail(); |
||
20 | |||
21 | } catch (\InvalidArgumentException $e) { |
||
22 | $this->assertSame('Quantity must be greater than 0. 0 given.', $e->getMessage()); |
||
23 | } |
||
24 | |||
25 | try { |
||
26 | new CartItem('very long long long cart item name', 1, 99); |
||
27 | $this->fail(); |
||
28 | |||
29 | } catch (\InvalidArgumentException $e) { |
||
30 | $this->assertSame('Cart item name can have maximum of 20 characters.', $e->getMessage()); |
||
31 | } |
||
32 | |||
33 | try { |
||
34 | new CartItem('foo name', 1, 99, 'very long long long long long long long long long long cart item description'); |
||
35 | $this->fail(); |
||
36 | |||
37 | } catch (\InvalidArgumentException $e) { |
||
38 | $this->assertSame('Cart item description can have maximum of 40 characters.', $e->getMessage()); |
||
39 | } |
||
40 | } |
||
41 | |||
43 |