mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Created RestUtilsTest
This commit is contained in:
parent
f701e65f75
commit
6f7e4f7e7f
1 changed files with 40 additions and 0 deletions
40
module/Rest/test/Util/RestUtilsTest.php
Normal file
40
module/Rest/test/Util/RestUtilsTest.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
namespace ShlinkioTest\Shlink\Rest\Util;
|
||||
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
use Shlinkio\Shlink\Common\Exception\InvalidArgumentException;
|
||||
use Shlinkio\Shlink\Common\Exception\WrongIpException;
|
||||
use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;
|
||||
use Shlinkio\Shlink\Core\Exception\InvalidUrlException;
|
||||
use Shlinkio\Shlink\Rest\Exception\AuthenticationException;
|
||||
use Shlinkio\Shlink\Rest\Util\RestUtils;
|
||||
|
||||
class RestUtilsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function correctCodeIsReturnedFromException()
|
||||
{
|
||||
$this->assertEquals(
|
||||
RestUtils::INVALID_SHORTCODE_ERROR,
|
||||
RestUtils::getRestErrorCodeFromException(new InvalidShortCodeException())
|
||||
);
|
||||
$this->assertEquals(
|
||||
RestUtils::INVALID_URL_ERROR,
|
||||
RestUtils::getRestErrorCodeFromException(new InvalidUrlException())
|
||||
);
|
||||
$this->assertEquals(
|
||||
RestUtils::INVALID_ARGUMENT_ERROR,
|
||||
RestUtils::getRestErrorCodeFromException(new InvalidArgumentException())
|
||||
);
|
||||
$this->assertEquals(
|
||||
RestUtils::INVALID_CREDENTIALS_ERROR,
|
||||
RestUtils::getRestErrorCodeFromException(new AuthenticationException())
|
||||
);
|
||||
$this->assertEquals(
|
||||
RestUtils::UNKNOWN_ERROR,
|
||||
RestUtils::getRestErrorCodeFromException(new WrongIpException())
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue