@@ -138,9 +138,17 @@ class: AttributeResources::class,
138
138
139
139
public function testCreateWithDefaults (): void
140
140
{
141
- $ attributeResourceMetadataCollectionFactory = new AttributesResourceMetadataCollectionFactory (null , null , ['cache_headers ' => ['max_age ' => 60 ], 'non_existing_attribute ' => 'foo ' ]);
142
-
143
- $ operation = new HttpOperation (shortName: 'AttributeDefaultOperations ' , class: AttributeDefaultOperations::class, cacheHeaders: ['max_age ' => 60 ], paginationItemsPerPage: 10 , extraProperties: ['non_existing_attribute ' => 'foo ' ]);
141
+ $ attributeResourceMetadataCollectionFactory = new AttributesResourceMetadataCollectionFactory (null , null , [
142
+ 'cache_headers ' => [
143
+ 'max_age ' => 60 ,
144
+ 'shared_max_age ' => 120 ,
145
+ 'public ' => true ,
146
+ ],
147
+ 'non_existing_attribute ' => 'foo ' ,
148
+ ]);
149
+
150
+ // Check the AttributeDefaultOperations it specifies a shared_max_age that should not be overridden
151
+ $ operation = new HttpOperation (shortName: 'AttributeDefaultOperations ' , class: AttributeDefaultOperations::class, cacheHeaders: ['max_age ' => 60 , 'shared_max_age ' => 60 , 'public ' => true ], paginationItemsPerPage: 10 , extraProperties: ['non_existing_attribute ' => 'foo ' ]);
144
152
145
153
$ this ->assertEquals (new ResourceMetadataCollection (AttributeDefaultOperations::class, [
146
154
new ApiResource (
@@ -155,7 +163,7 @@ class: AttributeDefaultOperations::class,
155
163
'_api_AttributeDefaultOperations_patch ' => (new Patch ())->withOperation ($ operation ),
156
164
'_api_AttributeDefaultOperations_delete ' => (new Delete ())->withOperation ($ operation ),
157
165
],
158
- cacheHeaders: ['max_age ' => 60 ],
166
+ cacheHeaders: ['max_age ' => 60 , ' shared_max_age ' => 60 , ' public ' => true ],
159
167
paginationItemsPerPage: 10 ,
160
168
extraProperties: ['non_existing_attribute ' => 'foo ' ]
161
169
),
@@ -170,7 +178,7 @@ public function testCreateShouldNotOverrideWithDefault(): void
170
178
]
171
179
);
172
180
173
- $ operation = new HttpOperation (shortName: 'AttributeDefaultOperations ' , class: AttributeDefaultOperations::class, paginationItemsPerPage: 10 );
181
+ $ operation = new HttpOperation (shortName: 'AttributeDefaultOperations ' , class: AttributeDefaultOperations::class, paginationItemsPerPage: 10 , cacheHeaders: [ ' shared_max_age ' => 60 ] );
174
182
$ this ->assertEquals (new ResourceMetadataCollection (AttributeDefaultOperations::class, [
175
183
new ApiResource (
176
184
shortName: 'AttributeDefaultOperations ' ,
@@ -183,6 +191,7 @@ class: AttributeDefaultOperations::class,
183
191
'_api_AttributeDefaultOperations_patch ' => (new Patch ())->withOperation ($ operation ),
184
192
'_api_AttributeDefaultOperations_delete ' => (new Delete ())->withOperation ($ operation ),
185
193
],
194
+ cacheHeaders: ['shared_max_age ' => 60 ],
186
195
graphQlOperations: [],
187
196
paginationItemsPerPage: 10
188
197
),
0 commit comments