From 2e51fbff9d8472a0e98af39aff52d30f0b67706b Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 21 Nov 2018 12:17:28 +0100 Subject: Added / route with redirects --- .../Http/Exceptions/HttpPermanentRedirectTest.php | 20 +++++++++++++++++ tests/Unit/Http/Exceptions/HttpRedirectTest.php | 26 ++++++++++++++++++++++ .../Http/Exceptions/HttpTemporaryRedirectTest.php | 20 +++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 tests/Unit/Http/Exceptions/HttpPermanentRedirectTest.php create mode 100644 tests/Unit/Http/Exceptions/HttpRedirectTest.php create mode 100644 tests/Unit/Http/Exceptions/HttpTemporaryRedirectTest.php (limited to 'tests/Unit/Http') diff --git a/tests/Unit/Http/Exceptions/HttpPermanentRedirectTest.php b/tests/Unit/Http/Exceptions/HttpPermanentRedirectTest.php new file mode 100644 index 00000000..3f6a832c --- /dev/null +++ b/tests/Unit/Http/Exceptions/HttpPermanentRedirectTest.php @@ -0,0 +1,20 @@ +assertInstanceOf(HttpRedirect::class, $exception); + $this->assertEquals(301, $exception->getStatusCode()); + } +} diff --git a/tests/Unit/Http/Exceptions/HttpRedirectTest.php b/tests/Unit/Http/Exceptions/HttpRedirectTest.php new file mode 100644 index 00000000..04190f28 --- /dev/null +++ b/tests/Unit/Http/Exceptions/HttpRedirectTest.php @@ -0,0 +1,26 @@ +assertEquals(302, $exception->getStatusCode()); + $this->assertArraySubset(['Location' => 'https://lorem.ipsum/foo/bar'], $exception->getHeaders()); + + $exception = new HttpRedirect('/test', 301, ['lorem' => 'ipsum']); + $this->assertEquals(301, $exception->getStatusCode()); + $this->assertArraySubset(['lorem' => 'ipsum'], $exception->getHeaders()); + } +} diff --git a/tests/Unit/Http/Exceptions/HttpTemporaryRedirectTest.php b/tests/Unit/Http/Exceptions/HttpTemporaryRedirectTest.php new file mode 100644 index 00000000..6096830f --- /dev/null +++ b/tests/Unit/Http/Exceptions/HttpTemporaryRedirectTest.php @@ -0,0 +1,20 @@ +assertInstanceOf(HttpRedirect::class, $exception); + $this->assertEquals(302, $exception->getStatusCode()); + } +} -- cgit v1.2.3-54-g00ecf