Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit d4867c6

Browse files
committed
Test for invalid URIs
- Also, ensure that `InvalidArgumentException` is imported!
1 parent cd5a24f commit d4867c6

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Response/RedirectResponse.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Zend\Diactoros\Response;
1111

12+
use InvalidArgumentException;
1213
use Psr\Http\Message\UriInterface;
1314
use Zend\Diactoros\Response;
1415
use Zend\Diactoros\Stream;

test/Response/RedirectResponseTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,28 @@ public function testConstructorAllowsSpecifyingHeaders()
4949
$this->assertTrue($response->hasHeader('X-Foo'));
5050
$this->assertEquals('Bar', $response->getHeaderLine('X-Foo'));
5151
}
52+
53+
public function invalidUris()
54+
{
55+
return [
56+
'null' => [ null ],
57+
'false' => [ false ],
58+
'true' => [ true ],
59+
'zero' => [ 0 ],
60+
'int' => [ 1 ],
61+
'zero-float' => [ 0.0 ],
62+
'float' => [ 1.1 ],
63+
'array' => [ [ '/foo/bar' ] ],
64+
'object' => [ (object) [ '/foo/bar' ] ],
65+
];
66+
}
67+
68+
/**
69+
* @dataProvider invalidUris
70+
* @expectedException InvalidArgumentException Uri
71+
*/
72+
public function testConstructorRaisesExceptionOnInvalidUri($uri)
73+
{
74+
$response = new RedirectResponse($uri);
75+
}
5276
}

0 commit comments

Comments
 (0)