CartItemTest::testNullDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php declare(strict_types = 1);
2
3
namespace SlevomatCsobGateway;
4
5
use InvalidArgumentException;
6
use PHPUnit\Framework\TestCase;
7
8
class CartItemTest extends TestCase
9
{
10
11
	public function testNullDescription(): void
12
	{
13
		$cartItem = new CartItem('foo name', 1, 99);
14
15
		self::assertNull($cartItem->getDescription());
16
	}
17
18
	public function testValidation(): void
19
	{
20
		try {
21
			new CartItem('foo name', 0, 99);
22
			self::fail();
23
24
		} catch (InvalidArgumentException $e) {
25
			self::assertSame('Quantity must be greater than 0. 0 given.', $e->getMessage());
26
		}
27
28
		try {
29
			new CartItem('very long long long cart item name', 1, 99);
30
			self::fail();
31
32
		} catch (InvalidArgumentException $e) {
33
			self::assertSame('Cart item name can have maximum of 20 characters.', $e->getMessage());
34
		}
35
36
		try {
37
			new CartItem('foo name', 1, 99, 'very long long long long long long long long long long cart item description');
38
			self::fail();
39
40
		} catch (InvalidArgumentException $e) {
41
			self::assertSame('Cart item description can have maximum of 40 characters.', $e->getMessage());
42
		}
43
	}
44
45
}
46