postLink: change relative path to absolute path
This commit is contained in:
parent
78c2f122e0
commit
b37ca79072
2 changed files with 5 additions and 5 deletions
|
@ -130,7 +130,7 @@ public function postLink($request, $response)
|
|||
|
||||
$this->bookmarkService->add($bookmark);
|
||||
$out = ApiUtils::formatLink($bookmark, index_url($this->ci['environment']));
|
||||
$redirect = $this->ci->router->relativePathFor('getLink', ['id' => $bookmark->getId()]);
|
||||
$redirect = $this->ci->router->pathFor('getLink', ['id' => $bookmark->getId()]);
|
||||
return $response->withAddedHeader('Location', $redirect)
|
||||
->withJson($out, 201, $this->jsonStyle);
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ public function setUp()
|
|||
|
||||
$mock = $this->createMock(Router::class);
|
||||
$mock->expects($this->any())
|
||||
->method('relativePathFor')
|
||||
->willReturn('api/v1/bookmarks/1');
|
||||
->method('pathFor')
|
||||
->willReturn('/api/v1/bookmarks/1');
|
||||
|
||||
// affect @property-read... seems to work
|
||||
$this->controller->getCi()->router = $mock;
|
||||
|
@ -126,7 +126,7 @@ public function testPostLinkMinimal()
|
|||
|
||||
$response = $this->controller->postLink($request, new Response());
|
||||
$this->assertEquals(201, $response->getStatusCode());
|
||||
$this->assertEquals('api/v1/bookmarks/1', $response->getHeader('Location')[0]);
|
||||
$this->assertEquals('/api/v1/bookmarks/1', $response->getHeader('Location')[0]);
|
||||
$data = json_decode((string) $response->getBody(), true);
|
||||
$this->assertEquals(self::NB_FIELDS_LINK, count($data));
|
||||
$this->assertEquals(43, $data['id']);
|
||||
|
@ -171,7 +171,7 @@ public function testPostLinkFull()
|
|||
$response = $this->controller->postLink($request, new Response());
|
||||
|
||||
$this->assertEquals(201, $response->getStatusCode());
|
||||
$this->assertEquals('api/v1/bookmarks/1', $response->getHeader('Location')[0]);
|
||||
$this->assertEquals('/api/v1/bookmarks/1', $response->getHeader('Location')[0]);
|
||||
$data = json_decode((string) $response->getBody(), true);
|
||||
$this->assertEquals(self::NB_FIELDS_LINK, count($data));
|
||||
$this->assertEquals(43, $data['id']);
|
||||
|
|
Loading…
Reference in a new issue