Added support for domain param to command and action to resolve a short URL

This commit is contained in:
Alejandro Celaya
2019-10-04 21:17:02 +02:00
parent 8d3a49a319
commit baf3093893
7 changed files with 47 additions and 23 deletions

View File

@@ -30,11 +30,11 @@ class ResolveShortUrlActionTest extends TestCase
}
/** @test */
public function incorrectShortCodeReturnsError()
public function incorrectShortCodeReturnsError(): void
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode)->willThrow(EntityDoesNotExistException::class)
->shouldBeCalledOnce();
$this->urlShortener->shortCodeToUrl($shortCode, null)->willThrow(EntityDoesNotExistException::class)
->shouldBeCalledOnce();
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode);
$response = $this->action->handle($request);
@@ -43,10 +43,10 @@ class ResolveShortUrlActionTest extends TestCase
}
/** @test */
public function correctShortCodeReturnsSuccess()
public function correctShortCodeReturnsSuccess(): void
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode)->willReturn(
$this->urlShortener->shortCodeToUrl($shortCode, null)->willReturn(
new ShortUrl('http://domain.com/foo/bar')
)->shouldBeCalledOnce();
@@ -57,11 +57,11 @@ class ResolveShortUrlActionTest extends TestCase
}
/** @test */
public function invalidShortCodeExceptionReturnsError()
public function invalidShortCodeExceptionReturnsError(): void
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode)->willThrow(InvalidShortCodeException::class)
->shouldBeCalledOnce();
$this->urlShortener->shortCodeToUrl($shortCode, null)->willThrow(InvalidShortCodeException::class)
->shouldBeCalledOnce();
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode);
$response = $this->action->handle($request);
@@ -70,11 +70,11 @@ class ResolveShortUrlActionTest extends TestCase
}
/** @test */
public function unexpectedExceptionWillReturnError()
public function unexpectedExceptionWillReturnError(): void
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode)->willThrow(Exception::class)
->shouldBeCalledOnce();
$this->urlShortener->shortCodeToUrl($shortCode, null)->willThrow(Exception::class)
->shouldBeCalledOnce();
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode);
$response = $this->action->handle($request);