|
@@ 14-27 (lines=14) @@
|
| 11 |
|
*/ |
| 12 |
|
final class InvalidArgumentExceptionTest extends \PHPUnit_Framework_TestCase |
| 13 |
|
{ |
| 14 |
|
public function testFromInvalidKeyCharacters() |
| 15 |
|
{ |
| 16 |
|
$invalidKey = uniqid('invalidKey', true); |
| 17 |
|
$exception = InvalidArgumentException::fromInvalidKeyCharacters($invalidKey); |
| 18 |
|
self::assertInstanceOf(InvalidArgumentException::class, $exception); |
| 19 |
|
self::assertInstanceOf(PsrInvalidArgumentException::class, $exception); |
| 20 |
|
self::assertSame( |
| 21 |
|
sprintf( |
| 22 |
|
'Key "%s" is in an invalid format - must not contain characters: {}()/\@:', |
| 23 |
|
$invalidKey |
| 24 |
|
), |
| 25 |
|
$exception->getMessage() |
| 26 |
|
); |
| 27 |
|
} |
| 28 |
|
|
| 29 |
|
public function testFromInvalidType() |
| 30 |
|
{ |
|
@@ 29-39 (lines=11) @@
|
| 26 |
|
); |
| 27 |
|
} |
| 28 |
|
|
| 29 |
|
public function testFromInvalidType() |
| 30 |
|
{ |
| 31 |
|
$invalidKey = random_int(100, 200); |
| 32 |
|
$exception = InvalidArgumentException::fromInvalidType($invalidKey); |
| 33 |
|
self::assertInstanceOf(InvalidArgumentException::class, $exception); |
| 34 |
|
self::assertInstanceOf(PsrInvalidArgumentException::class, $exception); |
| 35 |
|
self::assertSame( |
| 36 |
|
'Key was not a valid type. Expected string, received integer', |
| 37 |
|
$exception->getMessage() |
| 38 |
|
); |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
public function testFromEmptyKey() |
| 42 |
|
{ |
|
@@ 52-62 (lines=11) @@
|
| 49 |
|
); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
public function testFromNonIterableKeys() |
| 53 |
|
{ |
| 54 |
|
$invalidKey = random_int(100, 200); |
| 55 |
|
$exception = InvalidArgumentException::fromNonIterableKeys($invalidKey); |
| 56 |
|
self::assertInstanceOf(InvalidArgumentException::class, $exception); |
| 57 |
|
self::assertInstanceOf(PsrInvalidArgumentException::class, $exception); |
| 58 |
|
self::assertSame( |
| 59 |
|
'Keys passed were not iterable (i.e. \Traversable or array), received: integer', |
| 60 |
|
$exception->getMessage() |
| 61 |
|
); |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
public function testFromNonIterableValues() |
| 65 |
|
{ |
|
@@ 64-74 (lines=11) @@
|
| 61 |
|
); |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
public function testFromNonIterableValues() |
| 65 |
|
{ |
| 66 |
|
$invalidValue = random_int(100, 200); |
| 67 |
|
$exception = InvalidArgumentException::fromNonIterableValues($invalidValue); |
| 68 |
|
self::assertInstanceOf(InvalidArgumentException::class, $exception); |
| 69 |
|
self::assertInstanceOf(PsrInvalidArgumentException::class, $exception); |
| 70 |
|
self::assertSame( |
| 71 |
|
'Values passed were not iterable (i.e. \Traversable or array), received: integer', |
| 72 |
|
$exception->getMessage() |
| 73 |
|
); |
| 74 |
|
} |
| 75 |
|
} |
| 76 |
|
|