mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-08 16:23:12 +08:00
Migrated rest actions to psr-15 middleware
This commit is contained in:
@@ -8,7 +8,7 @@ use Shlinkio\Shlink\Core\Exception\InvalidUrlException;
|
||||
use Shlinkio\Shlink\Core\Service\UrlShortener;
|
||||
use Shlinkio\Shlink\Rest\Action\CreateShortcodeAction;
|
||||
use Shlinkio\Shlink\Rest\Util\RestUtils;
|
||||
use Zend\Diactoros\Response;
|
||||
use ShlinkioTest\Shlink\Common\Util\TestUtils;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\Diactoros\Uri;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
@@ -38,7 +38,10 @@ class CreateShortcodeActionTest extends TestCase
|
||||
*/
|
||||
public function missingLongUrlParamReturnsError()
|
||||
{
|
||||
$response = $this->action->__invoke(ServerRequestFactory::fromGlobals(), new Response());
|
||||
$response = $this->action->process(
|
||||
ServerRequestFactory::fromGlobals(),
|
||||
TestUtils::createDelegateMock()->reveal()
|
||||
);
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
}
|
||||
|
||||
@@ -54,7 +57,7 @@ class CreateShortcodeActionTest extends TestCase
|
||||
$request = ServerRequestFactory::fromGlobals()->withParsedBody([
|
||||
'longUrl' => 'http://www.domain.com/foo/bar',
|
||||
]);
|
||||
$response = $this->action->__invoke($request, new Response());
|
||||
$response = $this->action->process($request, TestUtils::createDelegateMock()->reveal());
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue(strpos($response->getBody()->getContents(), 'http://foo.com/abc123') > 0);
|
||||
}
|
||||
@@ -71,7 +74,7 @@ class CreateShortcodeActionTest extends TestCase
|
||||
$request = ServerRequestFactory::fromGlobals()->withParsedBody([
|
||||
'longUrl' => 'http://www.domain.com/foo/bar',
|
||||
]);
|
||||
$response = $this->action->__invoke($request, new Response());
|
||||
$response = $this->action->process($request, TestUtils::createDelegateMock()->reveal());
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
$this->assertTrue(strpos($response->getBody()->getContents(), RestUtils::INVALID_URL_ERROR) > 0);
|
||||
}
|
||||
@@ -88,7 +91,7 @@ class CreateShortcodeActionTest extends TestCase
|
||||
$request = ServerRequestFactory::fromGlobals()->withParsedBody([
|
||||
'longUrl' => 'http://www.domain.com/foo/bar',
|
||||
]);
|
||||
$response = $this->action->__invoke($request, new Response());
|
||||
$response = $this->action->process($request, TestUtils::createDelegateMock()->reveal());
|
||||
$this->assertEquals(500, $response->getStatusCode());
|
||||
$this->assertTrue(strpos($response->getBody()->getContents(), RestUtils::UNKNOWN_ERROR) > 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user