Completed
Push — master ( 170fde...562033 )
by Jan
03:08
created

CartItemTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
c 4
b 0
f 0
lcom 0
cbo 2
dl 0
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testNullDescription() 0 6 1
B testValidation() 0 26 4
1
<?php
2
3
namespace SlevomatCsobGateway;
4
5
class CartItemTest extends \PHPUnit_Framework_TestCase
6
{
7
8
	public function testNullDescription()
9
	{
10
		$cartItem = new CartItem('foo name', 1, 99);
11
12
		$this->assertNull($cartItem->getDescription());
13
	}
14
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
42
}
43