@@ -52,11 +52,11 @@ protected function setUp(): void
52
52
->willReturn (
53
53
new ResourceMetadataCollection ('DummyResource ' , [ // todo mock $dummy_resource
54
54
new ApiResource (operations: [
55
- new Get (uriTemplate: '/dummy_resources/{dummyResourceId}{._format} ' , name: 'get ' ),
56
- new GetCollection (uriTemplate: '/dummy_resources{._format} ' , name: 'get_collections ' ),
57
- new Post (uriTemplate: '/dummy_resources{._format} ' , outputFormats: ['jsonld ' => ['application/ld+json ' ], 'text/turtle ' => ['text/turtle ' ]], name: 'post ' ),
58
- new Delete (uriTemplate: '/dummy_resources/{dummyResourceId}{._format} ' , name: 'delete ' ),
59
- new Put (uriTemplate: '/dummy_resources/{dummyResourceId}{._format} ' , name: 'put ' ),
55
+ new Get (uriTemplate: '/dummy_resources/{dummyResourceId}{._format} ' , class: ' DummyResource ' , name: 'get ' ),
56
+ new GetCollection (uriTemplate: '/dummy_resources{._format} ' , class: ' DummyResource ' , name: 'get_collections ' ),
57
+ new Post (uriTemplate: '/dummy_resources{._format} ' , outputFormats: ['jsonld ' => ['application/ld+json ' ], 'text/turtle ' => ['text/turtle ' ]], class: ' DummyResource ' , name: 'post ' ),
58
+ new Delete (uriTemplate: '/dummy_resources/{dummyResourceId}{._format} ' , class: ' DummyResource ' , name: 'delete ' ),
59
+ new Put (uriTemplate: '/dummy_resources/{dummyResourceId}{._format} ' , class: ' DummyResource ' , name: 'put ' ),
60
60
]),
61
61
])
62
62
);
@@ -67,7 +67,7 @@ protected function setUp(): void
67
67
68
68
public function testHeadersAcceptPostIsReturnWhenPostAllowed (): void
69
69
{
70
- $ operation = (new HttpOperation ('GET ' , '/dummy_resources{._format} ' ));
70
+ $ operation = (new HttpOperation ('GET ' , '/dummy_resources{._format} ' , class: ' DummyResource ' ));
71
71
72
72
$ context = $ this ->getContext ();
73
73
@@ -84,7 +84,7 @@ public function testHeadersAcceptPostIsReturnWhenPostAllowed(): void
84
84
85
85
public function testHeadersAcceptPostIsNotSetWhenPostIsNotAllowed (): void
86
86
{
87
- $ operation = (new HttpOperation ('GET ' , '/dummy_resources/{dummyResourceId}{._format} ' ));
87
+ $ operation = (new HttpOperation ('GET ' , '/dummy_resources/{dummyResourceId}{._format} ' , class: ' DummyResource ' ));
88
88
$ context = $ this ->getContext ();
89
89
90
90
$ processor = new LinkedDataPlatformProcessor (
@@ -100,7 +100,7 @@ public function testHeadersAcceptPostIsNotSetWhenPostIsNotAllowed(): void
100
100
101
101
public function testHeaderAllowReflectsResourceAllowedMethods (): void
102
102
{
103
- $ operation = (new HttpOperation ('GET ' , '/dummy_resources{._format} ' ));
103
+ $ operation = (new HttpOperation ('GET ' , '/dummy_resources{._format} ' , class: ' DummyResource ' ));
104
104
$ context = $ this ->getContext ();
105
105
106
106
$ processor = new LinkedDataPlatformProcessor (
@@ -116,7 +116,7 @@ public function testHeaderAllowReflectsResourceAllowedMethods(): void
116
116
$ this ->assertStringContainsString ('GET ' , $ allowHeader );
117
117
$ this ->assertStringContainsString ('POST ' , $ allowHeader );
118
118
119
- $ operation = (new HttpOperation ('GET ' , '/dummy_resources/{dummyResourceId}{._format} ' ));
119
+ $ operation = (new HttpOperation ('GET ' , '/dummy_resources/{dummyResourceId}{._format} ' , class: ' DummyResource ' ));
120
120
121
121
/** @var Response $response */
122
122
$ processor = new LinkedDataPlatformProcessor (
@@ -136,32 +136,12 @@ public function testHeaderAllowReflectsResourceAllowedMethods(): void
136
136
137
137
public function testProcessorWithoutRequiredConditionReturnOriginalResponse (): void
138
138
{
139
- $ operation = (new HttpOperation ('GET ' , '/dummy_resources/{dummyResourceId}{._format} ' ));
140
-
141
- // No collection factory
142
- $ processor = new LinkedDataPlatformProcessor ($ this ->decorated , $ this ->resourceClassResolver , null );
143
- /** @var Response $response */
144
- $ response = $ processor ->process (null , $ operation , [], $ this ->getContext ());
145
-
146
- $ this ->assertNull ($ response ->headers ->get ('Allow ' ));
147
-
148
- // No uri variable in context
149
- $ processor = new LinkedDataPlatformProcessor ($ this ->decorated , null , $ this ->resourceMetadataCollectionFactory );
150
- $ response = $ processor ->process (null , $ operation , [], $ this ->getContext ());
151
- $ this ->assertNull ($ response ->headers ->get ('Allow ' ));
139
+ $ operation = (new HttpOperation ('GET ' , '/dummy_resources/{dummyResourceId}{._format} ' , class: 'DummyResource ' ));
152
140
153
141
// Operation is an Error
154
142
$ processor = new LinkedDataPlatformProcessor ($ this ->decorated , $ this ->resourceClassResolver , $ this ->resourceMetadataCollectionFactory );
155
143
$ response = $ processor ->process (null , new Error (), $ this ->getContext ());
156
144
$ this ->assertNull ($ response ->headers ->get ('Allow ' ));
157
-
158
- // Not a resource class
159
- $ this ->resourceClassResolver
160
- ->method ('isResourceClass ' )
161
- ->willReturn (false );
162
- $ processor = new LinkedDataPlatformProcessor ($ this ->decorated , $ this ->resourceClassResolver , $ this ->resourceMetadataCollectionFactory );
163
- $ response = $ processor ->process (null , $ operation , []);
164
- $ this ->assertNull ($ response ->headers ->get ('Allow ' ));
165
145
}
166
146
167
147
private function createGetRequest (): Request
0 commit comments