Skip to content

Commit 2b2a253

Browse files
committed
Upgraded to APIP4 - except upload put
1 parent dccc2a4 commit 2b2a253

15 files changed

Lines changed: 54 additions & 47 deletions

File tree

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
}
1919
],
2020
"require": {
21-
"php": ">=8.3",
21+
"php": ">=8.4",
2222
"ext-exif": "*",
2323
"ext-fileinfo": "*",
2424
"ext-json": "*",
2525
"ext-pdo": "*",
2626
"ext-simplexml": "*",
27-
"api-platform/core": "^3.3.1 || 3.3.x-dev",
27+
"api-platform/core": "^4.2",
2828
"cocur/slugify": "^4.1",
2929
"doctrine/annotations": "^1.7.0",
3030
"doctrine/dbal": "^3.4",
@@ -136,7 +136,6 @@
136136
}
137137
},
138138
"conflict": {
139-
"api-platform/core": "dev-main",
140139
"willdurand/negotiation": "^2",
141140
"symfony/serializer": "<=6.1.2",
142141
"symfony/var-exporter": "<6.1",

features/bootstrap/DoctrineContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Silverback\ApiComponentsBundle\Features\Bootstrap;
1515

16-
use ApiPlatform\Exception\ItemNotFoundException;
16+
use ApiPlatform\Metadata\Exception\ItemNotFoundException;
1717
use ApiPlatform\Metadata\IriConverterInterface;
1818
use Behat\Behat\Context\Context;
1919
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
@@ -618,7 +618,7 @@ public function iPatchPageDataWithThePropertyAndResource(string $property, strin
618618
{
619619
$iri = $this->restContext->resources[$resource];
620620
$this->restContext->iSendARequestToTheResourceWithBody(
621-
'PUT',
621+
'PATCH',
622622
'page_data',
623623
null,
624624
new PyStringNode([\sprintf('{ "%s": "%s" }', $property, $iri)], 0)

features/bootstrap/RestContext.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public function castFromJson(string $value)
142142
*/
143143
public function iSendARequestToWithData($method, $url, TableNode $tableNode): void
144144
{
145+
$this->setContentTypeForMethod($method);
145146
$this->restContext->iSendARequestToWithBody($method, $url, new PyStringNode([json_encode($this->castTableNodeToArray($tableNode))], 0));
146147
}
147148

@@ -166,10 +167,15 @@ public function iSendARequestToTheResourceWithBody(string $method, string $resou
166167
throw new ExpectationException(\sprintf("The resource with name $resource has not been defined. (Components that exist are `%s`)", implode('`, `', array_keys($this->resources))), $this->minkContext->getSession()->getDriver());
167168
}
168169
$endpoint = $this->resources[$resource] . ($postfix ?: '');
170+
$this->setContentTypeForMethod($method);
169171

170172
return $this->restContext->iSendARequestToWithBody($method, $endpoint, $body ?? new PyStringNode([], 0));
171173
}
172174

175+
private function setContentTypeForMethod(string $method) {
176+
$this->restContext->iAddHeaderEqualTo('Content-Type', $method === 'PATCH' ? 'application/merge-patch+json' : 'application/ld+json');
177+
}
178+
173179
/**
174180
* @When /^I send a "([^"]*)" request to the resource "([^"]*)"(?: and the postfix "([^"]*)"|)? with data:$/i
175181
*/

features/main/route.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Feature: Route resources
8383
@loginUser
8484
Scenario: I update a route path. A new redirect will be created.
8585
Given there is a PageData resource with the route path "/original"
86-
When I send a "PUT" request to "/_/routes//original" with data:
86+
When I send a "PATCH" request to "/_/routes//original" with data:
8787
| path |
8888
| /new |
8989
Then the response status code should be 200

features/publishable/publishable.feature

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ Feature: Access to unpublished/draft resources should be configurable
203203
Scenario: As a user with draft access, when I update a published resource, it should create and return a draft resource. Draft resource should not have the component position.
204204
Given there is a publishable resource set to publish at "1970-12-31T23:59:59+00:00"
205205
And there is a ComponentPosition with the resource "publishable_published"
206-
When I send a "PUT" request to the resource "publishable_published" with body:
206+
When I send a "PATCH" request to the resource "publishable_published" with body:
207207
"""
208208
{
209209
"reference": "updated"
@@ -247,7 +247,7 @@ Feature: Access to unpublished/draft resources should be configurable
247247
@loginAdmin
248248
Scenario Outline: As a user with draft access, when I update a published resource with a publication date in the past (or now), it should be ignored.
249249
Given there is a publishable resource set to publish at "1970-12-31T23:59:59+00:00"
250-
When I send a "PUT" request to the resource "publishable_published" with data:
250+
When I send a "PATCH" request to the resource "publishable_published" with data:
251251
| publishedAt |
252252
| <publishedAt> |
253253
Then the response status code should be 200
@@ -260,7 +260,7 @@ Feature: Access to unpublished/draft resources should be configurable
260260
@loginAdmin
261261
Scenario Outline: As a user with draft access, when I update a published/draft resource with a draft resource available, and set a publication date in the past (or now), it should update the draft resource, merge it with the public resource, and remove the draft resource.
262262
Given there is a published resource with a draft set to publish at "2999-12-31T23:59:59+00:00"
263-
When I send a "PUT" request to the resource "<component>" with data:
263+
When I send a "PATCH" request to the resource "<component>" with data:
264264
| publishedAt | reference |
265265
| <publishedAt> | updated |
266266
Then the response status code should be 200
@@ -278,7 +278,7 @@ Feature: Access to unpublished/draft resources should be configurable
278278
@loginAdmin
279279
Scenario: As a user with draft access, when I update a published resource with a draft resource available, and set a publication date in the future, it should update and return the draft resource.
280280
Given there is a published resource with a draft set to publish at "2999-12-31T23:59:59+00:00"
281-
When I send a "PUT" request to the resource "publishable_published" with body:
281+
When I send a "PATCH" request to the resource "publishable_published" with body:
282282
"""
283283
{
284284
"publishedAt": "2991-11-11T23:59:59+00:00"
@@ -291,7 +291,7 @@ Feature: Access to unpublished/draft resources should be configurable
291291
@loginUser
292292
Scenario: As a user with no draft access, when I update a published resource, it should update and return the published resource.
293293
Given there is a publishable resource set to publish at "1970-12-31T23:59:59+00:00"
294-
When I send a "PUT" request to the resource "publishable_published" with body:
294+
When I send a "PATCH" request to the resource "publishable_published" with body:
295295
"""
296296
{
297297
"reference": "updated"
@@ -304,7 +304,7 @@ Feature: Access to unpublished/draft resources should be configurable
304304
@loginUser
305305
Scenario: As a user with no draft access, I cannot update a draft resource.
306306
Given there is a publishable resource set to publish at "2999-12-31T23:59:59+00:00"
307-
When I send a "PUT" request to the resource "publishable_draft" with body:
307+
When I send a "PATCH" request to the resource "publishable_draft" with body:
308308
"""
309309
{
310310
"reference": "updated"
@@ -315,7 +315,7 @@ Feature: Access to unpublished/draft resources should be configurable
315315
@loginAdmin
316316
Scenario: I cannot modify the publishedResource property via the API
317317
Given there is a publishable resource set to publish at "2999-12-31T23:59:59+00:00"
318-
When I send a "PUT" request to the resource "publishable_draft" with body:
318+
When I send a "PATCH" request to the resource "publishable_draft" with body:
319319
"""
320320
{
321321
"reference": "updated",
@@ -410,7 +410,7 @@ Feature: Access to unpublished/draft resources should be configurable
410410
Scenario: When I publish a draft component where there is an existing published component, the newly published draft should inherit the old published component positions
411411
Given there is a published resource with a draft set to publish at "2999-12-31T23:59:59+00:00"
412412
And there is a ComponentPosition with the resource "publishable_published"
413-
When I send a "PUT" request to the resource "publishable_draft" with body:
413+
When I send a "PATCH" request to the resource "publishable_draft" with body:
414414
"""
415415
{
416416
"publishedAt": "1970-11-11T23:59:59+00:00"

features/publishable/publishable_soft_validation.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Feature: Soft validation on draft resources
3939
@loginAdmin
4040
Scenario Outline: When I update a draft resource, there should be a header to indicate whether validation is passing if I were to try and publish it
4141
Given there is a DummyPublishableWithValidation resource
42-
When I send a "PUT" request to the resource "publishable_draft" with data:
42+
When I send a "PATCH" request to the resource "publishable_draft" with data:
4343
| resourceData |
4444
| <data> |
4545
Then the response status code should be 200
@@ -53,7 +53,7 @@ Feature: Soft validation on draft resources
5353
@loginAdmin
5454
Scenario Outline: I update a draft resource with data that is OK for a draft, but not for published
5555
Given there is a DummyPublishableWithValidation resource
56-
When I send a "PUT" request to the resource "publishable_draft" and the postfix "?<postfix>" with data:
56+
When I send a "PATCH" request to the resource "publishable_draft" and the postfix "?<postfix>" with data:
5757
| publishedAt | resourceData |
5858
| <publishedAt> | <data> |
5959
Then the response status code should be <httpStatus>
@@ -66,7 +66,7 @@ Feature: Soft validation on draft resources
6666
@loginAdmin
6767
Scenario Outline: I update a draft resource with data that is valid to make it published when ready
6868
Given there is a DummyPublishableWithValidation resource
69-
When I send a "PUT" request to the resource "publishable_draft" and the postfix "?<postfix>" with data:
69+
When I send a "PATCH" request to the resource "publishable_draft" and the postfix "?<postfix>" with data:
7070
| publishedAt | resourceData |
7171
| <publishedAt> | <data> |
7272
Then the response status code should be <httpStatus>
@@ -80,7 +80,7 @@ Feature: Soft validation on draft resources
8080
@loginAdmin
8181
Scenario Outline: I update a draft resource and expect to see a hard fail with validation errors and no need to populate metadata as the output is the violations
8282
Given there is a DummyPublishableWithValidation resource
83-
When I send a "PUT" request to the resource "publishable_draft" and the postfix "?<postfix>" with data:
83+
When I send a "PATCH" request to the resource "publishable_draft" and the postfix "?<postfix>" with data:
8484
| publishedAt | resourceData |
8585
| <publishedAt> | <data> |
8686
Then the response status code should be <httpStatus>
@@ -100,7 +100,7 @@ Feature: Soft validation on draft resources
100100
@loginAdmin
101101
Scenario Outline: Updating a resource to published. The querystring should make no difference and the response is published so no header should exist
102102
Given there is a DummyPublishableWithValidation resource
103-
When I send a "PUT" request to the resource "publishable_draft" and the postfix "?<postfix>" with data:
103+
When I send a "PATCH" request to the resource "publishable_draft" and the postfix "?<postfix>" with data:
104104
| publishedAt | resourceData |
105105
| <publishedAt> | <data> |
106106
Then the response status code should be <httpStatus>
@@ -114,7 +114,7 @@ Feature: Soft validation on draft resources
114114
@loginAdmin
115115
Scenario: I update a published resource with the querystring "validate_published=false" and "published=true" should have no effect and published resource validation should still apply
116116
Given there is a DummyPublishableWithValidation resource set to publish at "1970-12-31T23:59:59+00:00"
117-
When I send a "PUT" request to the resource "publishable_published" and the postfix "?validate_published=false&published=true" with body:
117+
When I send a "PATCH" request to the resource "publishable_published" and the postfix "?validate_published=false&published=true" with body:
118118
"""
119119
{
120120
"description": ""

features/user/new_email_address.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Feature: Register process via a form
9898
Given there is a "new_email" form
9999
And there is a user with the username "another_user" password "password" and role "ROLE_USER"
100100
And I add "referer" header equal to "http://www.website.com"
101-
When I send a "PUT" request to the resource "user" with body:
101+
When I send a "PATCH" request to the resource "user" with body:
102102
"""
103103
{
104104
"newEmailAddress": ""
@@ -115,7 +115,7 @@ Feature: Register process via a form
115115
Given there is a "new_email" form
116116
And there is a user with the username "another_user" password "password" and role "ROLE_USER"
117117
And I add "referer" header equal to "http://www.website.com"
118-
When I send a "PUT" request to the resource "user" with body:
118+
When I send a "PATCH" request to the resource "user" with body:
119119
"""
120120
{
121121
"newEmailAddress": null

features/user/verify_email_address.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Feature: Email address verification
3131
Scenario: Email becomes unverified when the email address is changed by the API
3232
Given there is a user with the username "my_username" password "password" and role "ROLE_USER"
3333
And I add "referer" header equal to "http://www.website.com"
34-
When I send a "PUT" request to the resource "user" with body:
34+
When I send a "PATCH" request to the resource "user" with body:
3535
"""
3636
{
3737
"emailAddress": "new@email.com"

src/ApiPlatform/Metadata/Resource/UploadableResourceMetadataCollectionFactory.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,20 @@ private static function configurePostOperation(Operation $postOperation, array $
110110
return $postOperation
111111
->withController(UploadAction::class)
112112
->withDeserialize(false)
113-
->withStateless(null)
114-
->withOpenapiContext([
115-
'requestBody' => [
116-
'content' => [
117-
'multipart/form-data' => [
118-
'schema' => [
119-
'type' => 'object',
120-
'properties' => $openApiRequestMultipartProperties,
121-
],
122-
],
123-
],
124-
],
125-
]);
113+
->withStateless(null);
114+
// todo: re-instatate..
115+
// ->withOpenapiContext([
116+
// 'requestBody' => [
117+
// 'content' => [
118+
// 'multipart/form-data' => [
119+
// 'schema' => [
120+
// 'type' => 'object',
121+
// 'properties' => $openApiRequestMultipartProperties,
122+
// ],
123+
// ],
124+
// ],
125+
// ],
126+
// ]);
126127
}
127128

128129
#[Pure]

src/Doctrine/Extension/ORM/RoutableExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use ApiPlatform\Doctrine\Orm\Extension\QueryCollectionExtensionInterface;
1717
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
1818
use ApiPlatform\Metadata\Operation;
19-
use ApiPlatform\Symfony\Security\ResourceAccessCheckerInterface;
19+
use ApiPlatform\Metadata\ResourceAccessCheckerInterface;
2020
use Doctrine\ORM\QueryBuilder;
2121
use Silverback\ApiComponentsBundle\Entity\Core\RoutableInterface;
2222

0 commit comments

Comments
 (0)