Skip to content

Commit f2b929d

Browse files
authored
IBX-9587: Fixed failing REST requests after Symfony 6 upgrade (#145)
* Fixed OPTIONS controller reference * [Tests] Aligned MapperTest with OPTIONS controller reference fix * [Tests] Fixed incorrect case for named test prefix in LocationTest * Fixed obsolete single-colon SessionController reference * [Tests] Fixed functional BookmarkTest to be self-contained
1 parent d87f621 commit f2b929d

File tree

5 files changed

+39
-24
lines changed

5 files changed

+39
-24
lines changed

src/bundle/Resources/config/routing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ibexa.rest.delete_section:
4040

4141
ibexa.rest.refresh_session:
4242
path: /user/sessions/{sessionId}/refresh
43-
controller: Ibexa\Rest\Server\Controller\SessionController:refreshSessionAction
43+
controller: Ibexa\Rest\Server\Controller\SessionController::refreshSessionAction
4444
defaults:
4545
csrf_protection: false
4646
methods: [POST]

src/bundle/Routing/OptionsLoader/Mapper.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@
1414
*/
1515
class Mapper
1616
{
17-
/**
18-
* @param $route Route REST route
19-
*
20-
* @return \Symfony\Component\Routing\Route
21-
*/
22-
public function mapRoute(Route $route)
17+
public function mapRoute(Route $route): Route
2318
{
2419
$optionsRoute = clone $route;
2520
$optionsRoute->setMethods(['OPTIONS']);
2621
$optionsRoute->setDefault(
2722
'_controller',
28-
'Ibexa\Rest\Server\Controller\Options:getRouteOptions'
23+
'Ibexa\Rest\Server\Controller\Options::getRouteOptions'
2924
);
3025

3126
$optionsRoute->setDefault(

tests/bundle/Functional/BookmarkTest.php

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
class BookmarkTest extends RESTFunctionalTestCase
1515
{
16+
/**
17+
* @throws \Psr\Http\Client\ClientExceptionInterface
18+
*/
1619
public function testCreateBookmark(): int
1720
{
1821
$content = $this->createFolder(__FUNCTION__, '/api/ibexa/v2/content/locations/1/2');
@@ -28,13 +31,15 @@ public function testCreateBookmark(): int
2831

2932
$response = $this->sendHttpRequest($request);
3033

31-
self::assertHttpResponseCodeEquals($response, Response::HTTP_CREATED);
34+
$this->assertHttpResponseCodeEquals($response, Response::HTTP_CREATED);
3235

3336
return $locationId;
3437
}
3538

3639
/**
3740
* @depends testCreateBookmark
41+
*
42+
* @throws \Psr\Http\Client\ClientExceptionInterface
3843
*/
3944
public function testCreateBookmarkIfAlreadyExists(int $locationId): void
4045
{
@@ -45,11 +50,13 @@ public function testCreateBookmarkIfAlreadyExists(int $locationId): void
4550

4651
$response = $this->sendHttpRequest($request);
4752

48-
self::assertHttpResponseCodeEquals($response, Response::HTTP_CONFLICT);
53+
$this->assertHttpResponseCodeEquals($response, Response::HTTP_CONFLICT);
4954
}
5055

5156
/**
5257
* @depends testCreateBookmark
58+
*
59+
* @throws \Psr\Http\Client\ClientExceptionInterface
5360
*/
5461
public function testIsBookmarked(int $locationId): void
5562
{
@@ -60,27 +67,32 @@ public function testIsBookmarked(int $locationId): void
6067

6168
$response = $this->sendHttpRequest($request);
6269

63-
self::assertHttpResponseCodeEquals($response, Response::HTTP_OK);
70+
$this->assertHttpResponseCodeEquals($response, Response::HTTP_OK);
6471
}
6572

66-
public function testIsBookmarkedReturnsNotFound(): void
73+
/**
74+
* @depends testDeleteBookmark
75+
*
76+
* @throws \Psr\Http\Client\ClientExceptionInterface
77+
*/
78+
public function testIsBookmarkedReturnsNotFound(int $locationId): void
6779
{
68-
$locationId = 43;
69-
7080
$request = $this->createHttpRequest(
7181
'HEAD',
7282
'/api/ibexa/v2/bookmark/' . $locationId
7383
);
7484

7585
$response = $this->sendHttpRequest($request);
7686

77-
self::assertHttpResponseCodeEquals($response, Response::HTTP_NOT_FOUND);
87+
$this->assertHttpResponseCodeEquals($response, Response::HTTP_NOT_FOUND);
7888
}
7989

8090
/**
8191
* @depends testCreateBookmark
92+
*
93+
* @throws \Psr\Http\Client\ClientExceptionInterface
8294
*/
83-
public function testDeleteBookmark(int $locationId): void
95+
public function testDeleteBookmark(int $locationId): int
8496
{
8597
$request = $this->createHttpRequest(
8698
'DELETE',
@@ -89,9 +101,14 @@ public function testDeleteBookmark(int $locationId): void
89101

90102
$response = $this->sendHttpRequest($request);
91103

92-
self::assertHttpResponseCodeEquals($response, Response::HTTP_NO_CONTENT);
104+
$this->assertHttpResponseCodeEquals($response, Response::HTTP_NO_CONTENT);
105+
106+
return $locationId;
93107
}
94108

109+
/**
110+
* @throws \Psr\Http\Client\ClientExceptionInterface
111+
*/
95112
public function testLoadBookmarks(): void
96113
{
97114
$request = $this->createHttpRequest(
@@ -103,20 +120,23 @@ public function testLoadBookmarks(): void
103120

104121
$response = $this->sendHttpRequest($request);
105122

106-
self::assertHttpResponseCodeEquals($response, Response::HTTP_OK);
123+
$this->assertHttpResponseCodeEquals($response, Response::HTTP_OK);
107124
}
108125

109-
public function testDeleteBookmarkReturnNotFound(): void
126+
/**
127+
* @depends testDeleteBookmark
128+
*
129+
* @throws \Psr\Http\Client\ClientExceptionInterface
130+
*/
131+
public function testDeleteBookmarkReturnNotFound(int $locationId): void
110132
{
111-
$locationId = 43;
112-
113133
$request = $this->createHttpRequest(
114134
'DELETE',
115135
'/api/ibexa/v2/bookmark/' . $locationId
116136
);
117137

118138
$response = $this->sendHttpRequest($request);
119139

120-
self::assertHttpResponseCodeEquals($response, Response::HTTP_NOT_FOUND);
140+
$this->assertHttpResponseCodeEquals($response, Response::HTTP_NOT_FOUND);
121141
}
122142
}

tests/bundle/Functional/LocationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testCreateLocation()
2121
$content = $this->createFolder('testCreateLocation', '/api/ibexa/v2/content/locations/1/2');
2222
$contentHref = $content['_href'];
2323

24-
$remoteId = $this->addTestSuffix('testCreatelocation');
24+
$remoteId = $this->addTestSuffix('testCreateLocation');
2525

2626
$body = <<< XML
2727
<?xml version="1.0" encoding="UTF-8"?>

tests/bundle/Routing/OptionsLoader/MapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function testMapRoute()
7777
);
7878

7979
self::assertEquals(
80-
'Ibexa\Rest\Server\Controller\Options:getRouteOptions',
80+
'Ibexa\Rest\Server\Controller\Options::getRouteOptions',
8181
$optionsRoute->getDefault('_controller')
8282
);
8383
}

0 commit comments

Comments
 (0)