diff options
Diffstat (limited to 'tests/Unit/Http/Exceptions')
-rw-r--r-- | tests/Unit/Http/Exceptions/HttpPermanentRedirectTest.php | 20 | ||||
-rw-r--r-- | tests/Unit/Http/Exceptions/HttpRedirectTest.php | 26 | ||||
-rw-r--r-- | tests/Unit/Http/Exceptions/HttpTemporaryRedirectTest.php | 20 |
3 files changed, 66 insertions, 0 deletions
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 @@ +<?php + +namespace Engelsystem\Test\Unit\Http; + +use Engelsystem\Http\Exceptions\HttpPermanentRedirect; +use Engelsystem\Http\Exceptions\HttpRedirect; +use PHPUnit\Framework\TestCase; + +class HttpPermanentRedirectTest extends TestCase +{ + /** + * @covers \Engelsystem\Http\Exceptions\HttpPermanentRedirect::__construct + */ + public function testConstruct() + { + $exception = new HttpPermanentRedirect('https://lorem.ipsum/foo/bar'); + $this->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 @@ +<?php + +namespace Engelsystem\Test\Unit\Http; + +use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; +use Engelsystem\Http\Exceptions\HttpRedirect; +use PHPUnit\Framework\TestCase; + +class HttpRedirectTest extends TestCase +{ + use ArraySubsetAsserts; + + /** + * @covers \Engelsystem\Http\Exceptions\HttpRedirect::__construct + */ + public function testConstruct() + { + $exception = new HttpRedirect('https://lorem.ipsum/foo/bar'); + $this->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 @@ +<?php + +namespace Engelsystem\Test\Unit\Http; + +use Engelsystem\Http\Exceptions\HttpRedirect; +use Engelsystem\Http\Exceptions\HttpTemporaryRedirect; +use PHPUnit\Framework\TestCase; + +class HttpTemporaryRedirectTest extends TestCase +{ + /** + * @covers \Engelsystem\Http\Exceptions\HttpTemporaryRedirect::__construct + */ + public function testConstruct() + { + $exception = new HttpTemporaryRedirect('https://lorem.ipsum/foo/bar'); + $this->assertInstanceOf(HttpRedirect::class, $exception); + $this->assertEquals(302, $exception->getStatusCode()); + } +} |