| @@ 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 | { |
|
| @@ 141-160 (lines=20) @@ | ||
| 138 | } |
|
| 139 | } |
|
| 140 | ||
| 141 | public function testTtlSec() |
|
| 142 | { |
|
| 143 | Validator::checkTtlSec(500); |
|
| 144 | ||
| 145 | try { |
|
| 146 | Validator::checkTtlSec(200); |
|
| 147 | $this->fail(); |
|
| 148 | ||
| 149 | } catch (\InvalidArgumentException $e) { |
|
| 150 | $this->assertSame('TTL sec is out of range (300 - 1800). Current value is 200.', $e->getMessage()); |
|
| 151 | } |
|
| 152 | ||
| 153 | try { |
|
| 154 | Validator::checkTtlSec(3000); |
|
| 155 | $this->fail(); |
|
| 156 | ||
| 157 | } catch (\InvalidArgumentException $e) { |
|
| 158 | $this->assertSame('TTL sec is out of range (300 - 1800). Current value is 3000.', $e->getMessage()); |
|
| 159 | } |
|
| 160 | } |
|
| 161 | ||
| 162 | } |
|
| 163 | ||