| @@ 8-27 (lines=20) @@ | ||
| 5 | class ValidatorTest extends \PHPUnit_Framework_TestCase |
|
| 6 | { |
|
| 7 | ||
| 8 | public function testCheckCartItemName() |
|
| 9 | { |
|
| 10 | Validator::checkCartItemName('foo name'); |
|
| 11 | ||
| 12 | try { |
|
| 13 | Validator::checkCartItemName('very long long long cart item name'); |
|
| 14 | $this->fail(); |
|
| 15 | ||
| 16 | } catch (\InvalidArgumentException $e) { |
|
| 17 | $this->assertSame('Cart item name can have maximum of 20 characters.', $e->getMessage()); |
|
| 18 | } |
|
| 19 | ||
| 20 | try { |
|
| 21 | Validator::checkCartItemName(' whitespace'); |
|
| 22 | $this->fail(); |
|
| 23 | ||
| 24 | } catch (\InvalidArgumentException $e) { |
|
| 25 | $this->assertSame('Argument starts or ends with whitespace.', $e->getMessage()); |
|
| 26 | } |
|
| 27 | } |
|
| 28 | ||
| 29 | public function testCheckCartItemDescription() |
|
| 30 | { |
|
| @@ 55-74 (lines=20) @@ | ||
| 52 | } |
|
| 53 | } |
|
| 54 | ||
| 55 | public function testCheckOrderId() |
|
| 56 | { |
|
| 57 | Validator::checkOrderId('123'); |
|
| 58 | ||
| 59 | try { |
|
| 60 | Validator::checkOrderId('123456789123456789'); |
|
| 61 | $this->fail(); |
|
| 62 | ||
| 63 | } catch (\InvalidArgumentException $e) { |
|
| 64 | $this->assertSame('OrderId can have maximum of 10 characters.', $e->getMessage()); |
|
| 65 | } |
|
| 66 | ||
| 67 | try { |
|
| 68 | Validator::checkOrderId('abc'); |
|
| 69 | $this->fail(); |
|
| 70 | ||
| 71 | } catch (\InvalidArgumentException $e) { |
|
| 72 | $this->assertSame('OrderId must be numeric value. abc given.', $e->getMessage()); |
|
| 73 | } |
|
| 74 | } |
|
| 75 | ||
| 76 | public function testCheckReturnUrl() |
|
| 77 | { |
|