for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types = 1);
namespace SlevomatCsobGateway;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
class CartItemTest extends TestCase
{
public function testNullDescription(): void
$cartItem = new CartItem('foo name', 1, 99);
self::assertNull($cartItem->getDescription());
}
public function testValidation(): void
try {
new CartItem('foo name', 0, 99);
self::fail();
} catch (InvalidArgumentException $e) {
self::assertSame('Quantity must be greater than 0. 0 given.', $e->getMessage());
new CartItem('very long long long cart item name', 1, 99);
self::assertSame('Cart item name can have maximum of 20 characters.', $e->getMessage());
new CartItem('foo name', 1, 99, 'very long long long long long long long long long long cart item description');
self::assertSame('Cart item description can have maximum of 40 characters.', $e->getMessage());