mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-16 08:03:45 +03:00
33 lines
957 B
PHP
33 lines
957 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace ShlinkioTest\Shlink\Core\Exception;
|
|
|
|
use Exception;
|
|
use Fig\Http\Message\StatusCodeInterface;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Shlinkio\Shlink\Core\Exception\InvalidUrlException;
|
|
use Throwable;
|
|
|
|
class InvalidUrlExceptionTest extends TestCase
|
|
{
|
|
/**
|
|
* @test
|
|
* @dataProvider providePrevious
|
|
*/
|
|
public function properlyCreatesExceptionFromUrl(?Throwable $prev): void
|
|
{
|
|
$e = InvalidUrlException::fromUrl('http://the_url.com', $prev);
|
|
|
|
$this->assertEquals('Provided URL http://the_url.com is invalid. Try with a different one.', $e->getMessage());
|
|
$this->assertEquals(StatusCodeInterface::STATUS_BAD_REQUEST, $e->getCode());
|
|
$this->assertEquals($prev, $e->getPrevious());
|
|
}
|
|
|
|
public function providePrevious(): iterable
|
|
{
|
|
yield 'null previous' => [null];
|
|
yield 'instance previous' => [new Exception('Previous error', 10)];
|
|
}
|
|
}
|