Migrated rest actions to psr-15 middleware

This commit is contained in:
Alejandro Celaya
2017-03-25 10:04:48 +01:00
parent 288249d0b8
commit 2e5a7d76df
13 changed files with 93 additions and 100 deletions

View File

@@ -8,7 +8,7 @@ use Shlinkio\Shlink\Common\Exception\InvalidArgumentException;
use Shlinkio\Shlink\Common\Util\DateRange;
use Shlinkio\Shlink\Core\Service\VisitsTracker;
use Shlinkio\Shlink\Rest\Action\GetVisitsAction;
use Zend\Diactoros\Response;
use ShlinkioTest\Shlink\Common\Util\TestUtils;
use Zend\Diactoros\ServerRequestFactory;
use Zend\I18n\Translator\Translator;
@@ -38,9 +38,9 @@ class GetVisitsActionTest extends TestCase
$this->visitsTracker->info($shortCode, Argument::type(DateRange::class))->willReturn([])
->shouldBeCalledTimes(1);
$response = $this->action->__invoke(
$response = $this->action->process(
ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode),
new Response()
TestUtils::createDelegateMock()->reveal()
);
$this->assertEquals(200, $response->getStatusCode());
}
@@ -55,9 +55,9 @@ class GetVisitsActionTest extends TestCase
InvalidArgumentException::class
)->shouldBeCalledTimes(1);
$response = $this->action->__invoke(
$response = $this->action->process(
ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode),
new Response()
TestUtils::createDelegateMock()->reveal()
);
$this->assertEquals(404, $response->getStatusCode());
}
@@ -72,9 +72,9 @@ class GetVisitsActionTest extends TestCase
\Exception::class
)->shouldBeCalledTimes(1);
$response = $this->action->__invoke(
$response = $this->action->process(
ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode),
new Response()
TestUtils::createDelegateMock()->reveal()
);
$this->assertEquals(500, $response->getStatusCode());
}
@@ -89,10 +89,10 @@ class GetVisitsActionTest extends TestCase
->willReturn([])
->shouldBeCalledTimes(1);
$response = $this->action->__invoke(
$response = $this->action->process(
ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode)
->withQueryParams(['endDate' => '2016-01-01 00:00:00']),
new Response()
TestUtils::createDelegateMock()->reveal()
);
$this->assertEquals(200, $response->getStatusCode());
}