Deleted local Common module and used external one

This commit is contained in:
Alejandro Celaya
2019-08-12 18:34:52 +02:00
parent d88f535444
commit d767c415d1
70 changed files with 15 additions and 2678 deletions

View File

@@ -6,6 +6,7 @@ namespace ShlinkioTest\Shlink\Core\Action;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Http\Server\RequestHandlerInterface;
use Shlinkio\Shlink\Common\Response\PixelResponse;
use Shlinkio\Shlink\Core\Action\PixelAction;
use Shlinkio\Shlink\Core\Action\RedirectAction;
@@ -13,7 +14,6 @@ use Shlinkio\Shlink\Core\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Options\AppOptions;
use Shlinkio\Shlink\Core\Service\UrlShortener;
use Shlinkio\Shlink\Core\Service\VisitsTracker;
use ShlinkioTest\Shlink\Common\Util\TestUtils;
use Zend\Diactoros\ServerRequest;
class PixelActionTest extends TestCase
@@ -38,7 +38,7 @@ class PixelActionTest extends TestCase
}
/** @test */
public function imageIsReturned()
public function imageIsReturned(): void
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode)->willReturn(
@@ -47,7 +47,7 @@ class PixelActionTest extends TestCase
$this->visitTracker->track(Argument::cetera())->shouldBeCalledOnce();
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode);
$response = $this->action->process($request, TestUtils::createReqHandlerMock()->reveal());
$response = $this->action->process($request, $this->prophesize(RequestHandlerInterface::class)->reveal());
$this->assertInstanceOf(PixelResponse::class, $response);
$this->assertEquals(200, $response->getStatusCode());

View File

@@ -14,7 +14,6 @@ use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException;
use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;
use Shlinkio\Shlink\Core\Service\UrlShortener;
use Shlinkio\Shlink\PreviewGenerator\Service\PreviewGenerator;
use ShlinkioTest\Shlink\Common\Util\TestUtils;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequest;
@@ -39,7 +38,7 @@ class PreviewActionTest extends TestCase
}
/** @test */
public function invalidShortCodeFallsBackToNextMiddleware()
public function invalidShortCodeFallsBackToNextMiddleware(): void
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode)->willThrow(EntityDoesNotExistException::class)
@@ -52,7 +51,7 @@ class PreviewActionTest extends TestCase
}
/** @test */
public function correctShortCodeReturnsImageResponse()
public function correctShortCodeReturnsImageResponse(): void
{
$shortCode = 'abc123';
$url = 'foobar.com';
@@ -63,7 +62,7 @@ class PreviewActionTest extends TestCase
$resp = $this->action->process(
(new ServerRequest())->withAttribute('shortCode', $shortCode),
TestUtils::createReqHandlerMock()->reveal()
$this->prophesize(RequestHandlerInterface::class)->reveal()
);
$this->assertEquals(filesize($path), $resp->getHeaderLine('Content-length'));
@@ -71,7 +70,7 @@ class PreviewActionTest extends TestCase
}
/** @test */
public function invalidShortCodeExceptionFallsBackToNextMiddleware()
public function invalidShortCodeExceptionFallsBackToNextMiddleware(): void
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode)->willThrow(InvalidShortCodeException::class)

View File

@@ -13,7 +13,6 @@ use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException;
use Shlinkio\Shlink\Core\Options;
use Shlinkio\Shlink\Core\Service\UrlShortener;
use Shlinkio\Shlink\Core\Service\VisitsTracker;
use ShlinkioTest\Shlink\Common\Util\TestUtils;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequest;
@@ -43,7 +42,7 @@ class RedirectActionTest extends TestCase
}
/** @test */
public function redirectionIsPerformedToLongUrl()
public function redirectionIsPerformedToLongUrl(): void
{
$shortCode = 'abc123';
$expectedUrl = 'http://domain.com/foo/bar';
@@ -53,7 +52,7 @@ class RedirectActionTest extends TestCase
$this->visitTracker->track(Argument::cetera())->shouldBeCalledOnce();
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode);
$response = $this->action->process($request, TestUtils::createReqHandlerMock()->reveal());
$response = $this->action->process($request, $this->prophesize(RequestHandlerInterface::class)->reveal());
$this->assertInstanceOf(Response\RedirectResponse::class, $response);
$this->assertEquals(302, $response->getStatusCode());
@@ -62,7 +61,7 @@ class RedirectActionTest extends TestCase
}
/** @test */
public function nextMiddlewareIsInvokedIfLongUrlIsNotFound()
public function nextMiddlewareIsInvokedIfLongUrlIsNotFound(): void
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode)->willThrow(EntityDoesNotExistException::class)
@@ -79,7 +78,7 @@ class RedirectActionTest extends TestCase
}
/** @test */
public function redirectToCustomUrlIsReturnedIfConfiguredSoAndShortUrlIsNotFound()
public function redirectToCustomUrlIsReturnedIfConfiguredSoAndShortUrlIsNotFound(): void
{
$shortCode = 'abc123';
$shortCodeToUrl = $this->urlShortener->shortCodeToUrl($shortCode)->willThrow(
@@ -102,7 +101,7 @@ class RedirectActionTest extends TestCase
}
/** @test */
public function visitIsNotTrackedIfDisableParamIsProvided()
public function visitIsNotTrackedIfDisableParamIsProvided(): void
{
$shortCode = 'abc123';
$expectedUrl = 'http://domain.com/foo/bar';
@@ -113,7 +112,7 @@ class RedirectActionTest extends TestCase
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode)
->withQueryParams(['foobar' => true]);
$response = $this->action->process($request, TestUtils::createReqHandlerMock()->reveal());
$response = $this->action->process($request, $this->prophesize(RequestHandlerInterface::class)->reveal());
$this->assertInstanceOf(Response\RedirectResponse::class, $response);
$this->assertEquals(302, $response->getStatusCode());