@@ -61,11 +61,7 @@ public function testResolveVirtualField(): void
61
61
$ contentGateway ->expects ($ this ->never ())
62
62
->method ('insertNewField ' );
63
63
64
- $ eventDispatcher = new TraceableEventDispatcher (
65
- new EventDispatcher (),
66
- new Stopwatch ()
67
- );
68
-
64
+ $ eventDispatcher = $ this ->getEventDispatcher ();
69
65
$ eventDispatcher ->addSubscriber (
70
66
new ResolveVirtualFieldSubscriber (
71
67
$ converterRegistry ,
@@ -123,6 +119,7 @@ public function testResolveVirtualExternalStorageField(): void
123
119
124
120
$ storageRegistry = $ this ->createMock (StorageRegistry::class);
125
121
$ storageRegistry ->method ('getStorage ' )
122
+ // Multiple interface mocks are deprecated in PHPUnit 9+
126
123
->willReturn (new class () implements FieldStorage, DefaultDataFieldStorage {
127
124
public function getDefaultFieldData (VersionInfo $ versionInfo , Field $ field ): void
128
125
{
@@ -133,42 +130,47 @@ public function getDefaultFieldData(VersionInfo $versionInfo, Field $field): voi
133
130
134
131
public function storeFieldData (VersionInfo $ versionInfo , Field $ field , array $ context ): void
135
132
{
133
+ // Mock
136
134
}
137
135
138
136
public function getFieldData (VersionInfo $ versionInfo , Field $ field , array $ context ): void
139
137
{
138
+ // Mock
140
139
}
141
140
142
141
public function deleteFieldData (VersionInfo $ versionInfo , array $ fieldIds , array $ context ): void
143
142
{
143
+ // Mock
144
144
}
145
145
146
146
public function hasFieldData (): void
147
147
{
148
+ // Mock
148
149
}
149
150
150
151
public function getIndexData (VersionInfo $ versionInfo , Field $ field , array $ context ): void
151
152
{
153
+ // Mock
152
154
}
153
155
});
154
156
155
- $ eventDispatcher = new TraceableEventDispatcher (
156
- new EventDispatcher (),
157
- new Stopwatch ()
158
- );
157
+ $ contentGateway = $ this ->createMock (ContentGateway::class);
158
+ $ contentGateway ->expects ($ this ->never ())
159
+ ->method ('insertNewField ' );
159
160
161
+ $ eventDispatcher = $ this ->getEventDispatcher ();
160
162
$ eventDispatcher ->addSubscriber (
161
163
new ResolveVirtualFieldSubscriber (
162
164
$ converterRegistry ,
163
165
$ storageRegistry ,
164
- $ this -> createMock (ContentGateway::class)
166
+ $ contentGateway
165
167
)
166
168
);
167
169
168
170
$ content = $ this ->getContent ();
169
171
$ fieldDefinition = new FieldDefinition ([
170
- 'id ' => 123 ,
171
- 'identifier ' => 'example_field ' ,
172
+ 'id ' => 678 ,
173
+ 'identifier ' => 'example_external_field ' ,
172
174
'fieldType ' => 'external_type_virtual ' ,
173
175
'defaultValue ' => new Content \FieldValue (),
174
176
]);
@@ -183,7 +185,7 @@ public function getIndexData(VersionInfo $versionInfo, Field $field, array $cont
183
185
184
186
$ expected = new Content \Field ([
185
187
'id ' => null ,
186
- 'fieldDefinitionId ' => 123 ,
188
+ 'fieldDefinitionId ' => 678 ,
187
189
'type ' => 'external_type_virtual ' ,
188
190
'value ' => new Content \FieldValue ([
189
191
'externalData ' => [
@@ -233,11 +235,7 @@ public function testPersistEmptyExternalStorageField(): void
233
235
->method ('insertNewField ' )
234
236
->willReturn (567 );
235
237
236
- $ eventDispatcher = new TraceableEventDispatcher (
237
- new EventDispatcher (),
238
- new Stopwatch ()
239
- );
240
-
238
+ $ eventDispatcher = $ this ->getEventDispatcher ();
241
239
$ eventDispatcher ->addSubscriber (
242
240
new ResolveVirtualFieldSubscriber (
243
241
$ converterRegistry ,
@@ -316,11 +314,7 @@ public function testPersistExternalStorageField(): void
316
314
->method ('insertNewField ' )
317
315
->willReturn (456 );
318
316
319
- $ eventDispatcher = new TraceableEventDispatcher (
320
- new EventDispatcher (),
321
- new Stopwatch ()
322
- );
323
-
317
+ $ eventDispatcher = $ this ->getEventDispatcher ();
324
318
$ eventDispatcher ->addSubscriber (
325
319
new ResolveVirtualFieldSubscriber (
326
320
$ converterRegistry ,
@@ -378,4 +372,12 @@ public function testPersistExternalStorageField(): void
378
372
array_column ($ eventDispatcher ->getCalledListeners (), 'pretty ' )
379
373
);
380
374
}
375
+
376
+ private function getEventDispatcher (): TraceableEventDispatcher
377
+ {
378
+ return new TraceableEventDispatcher (
379
+ new EventDispatcher (),
380
+ new Stopwatch ()
381
+ );
382
+ }
381
383
}
0 commit comments