Improved public API in ShortUrl entity, reducing anemic model

This commit is contained in:
Alejandro Celaya
2018-10-28 16:00:54 +01:00
parent 877b098b09
commit 8e1e8ba7de
26 changed files with 96 additions and 148 deletions

View File

@@ -54,8 +54,7 @@ class CreateShortUrlActionTest extends TestCase
{
$this->urlShortener->urlToShortCode(Argument::type(Uri::class), Argument::type('array'), Argument::cetera())
->willReturn(
(new ShortUrl())->setShortCode('abc123')
->setLongUrl('')
(new ShortUrl(''))->setShortCode('abc123')
)
->shouldBeCalledTimes(1);

View File

@@ -82,7 +82,9 @@ class EditShortUrlActionTest extends TestCase
->withParsedBody([
'maxVisits' => 5,
]);
$updateMeta = $this->shortUrlService->updateMetadataByShortCode(Argument::cetera())->willReturn(new ShortUrl());
$updateMeta = $this->shortUrlService->updateMetadataByShortCode(Argument::cetera())->willReturn(
new ShortUrl('')
);
$resp = $this->action->handle($request);

View File

@@ -60,7 +60,7 @@ class EditShortUrlTagsActionTest extends TestCase
public function tagsListIsReturnedIfCorrectShortCodeIsProvided()
{
$shortCode = 'abc123';
$this->shortUrlService->setTagsByShortCode($shortCode, [])->willReturn(new ShortUrl())
$this->shortUrlService->setTagsByShortCode($shortCode, [])->willReturn(new ShortUrl(''))
->shouldBeCalledTimes(1);
$response = $this->action->handle(

View File

@@ -55,7 +55,7 @@ class ResolveShortUrlActionTest extends TestCase
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode)->willReturn(
(new ShortUrl())->setLongUrl('http://domain.com/foo/bar')
new ShortUrl('http://domain.com/foo/bar')
)->shouldBeCalledTimes(1);
$request = ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode);

View File

@@ -103,7 +103,7 @@ class SingleStepCreateShortUrlActionTest extends TestCase
null,
null,
null
)->willReturn((new ShortUrl())->setLongUrl(''));
)->willReturn(new ShortUrl(''));
$resp = $this->action->handle($request);