3535 */
3636final class VersionMarkerWireFormatTest extends TestCase
3737{
38- /** @var list<string> */
39- private const FROZEN_COMMAND_KEYS = [
40- 'type ' ,
41- 'change_id ' ,
42- 'version ' ,
43- 'min_supported ' ,
44- 'max_supported ' ,
45- ];
46-
47- /** @var list<string> */
38+ /**
39+ * @var list<string>
40+ */
41+ private const FROZEN_COMMAND_KEYS = ['type ' , 'change_id ' , 'version ' , 'min_supported ' , 'max_supported ' ];
42+
43+ /**
44+ * @var list<string>
45+ */
4846 private const FROZEN_EVENT_PAYLOAD_KEYS = [
4947 'sequence ' ,
5048 'change_id ' ,
@@ -110,9 +108,9 @@ public function testNormalizedCommandKeySetIsFrozen(): void
110108 $ expected ,
111109 $ keys ,
112110 'record_version_marker command wire format has shifted — this is a protocol break. '
113- .'If a new field is required, introduce a new command type (e.g. '
114- .'record_version_marker_v2) and update docs/api-stability.md; do NOT extend '
115- .'the existing shape. ' ,
111+ . 'If a new field is required, introduce a new command type (e.g. '
112+ . 'record_version_marker_v2) and update docs/api-stability.md; do NOT extend '
113+ . 'the existing shape. ' ,
116114 );
117115
118116 $ this ->assertSame ('record_version_marker ' , $ out [0 ]['type ' ]);
@@ -158,39 +156,24 @@ public function testCommandValidationRequiresEveryFrozenField(): void
158156 unset($ command [$ missing ]);
159157
160158 $ this ->expectExceptionOnce (
161- fn () => WorkflowCommandNormalizer::normalize ([$ command ]),
159+ static fn () => WorkflowCommandNormalizer::normalize ([$ command ]),
162160 sprintf (
163161 'Expected normalization to fail when "%s" is missing — the frozen contract '
164- .'requires every field on every command. ' ,
162+ . 'requires every field on every command. ' ,
165163 $ missing ,
166164 ),
167165 );
168166 }
169167 }
170168
171- private function expectExceptionOnce (callable $ callable , string $ message ): void
172- {
173- try {
174- $ callable ();
175- } catch (ValidationException ) {
176- $ this ->addToAssertionCount (1 );
177-
178- return ;
179- }
180-
181- $ this ->fail ($ message );
182- }
183-
184169 public function testBridgeEmissionSiteStillUsesFrozenEventPayloadKeys (): void
185170 {
186171 // Source-level guard: the bridge emits VersionMarkerRecorded with an
187172 // inline array literal. Refactoring it to a helper or struct would
188173 // silently remove the frozen-key assertion expressed by this test.
189174 // Read the source, find the applyRecordVersionMarker() function, and
190175 // verify its payload literal still contains exactly the frozen keys.
191- $ source = file_get_contents (
192- dirname (__DIR__ , 3 ).'/src/V2/Support/DefaultWorkflowTaskBridge.php ' ,
193- );
176+ $ source = file_get_contents (dirname (__DIR__ , 3 ) . '/src/V2/Support/DefaultWorkflowTaskBridge.php ' );
194177 $ this ->assertIsString ($ source );
195178
196179 // Extract the body between `applyRecordVersionMarker(...) { ... }` and
@@ -208,7 +191,7 @@ public function testBridgeEmissionSiteStillUsesFrozenEventPayloadKeys(): void
208191 $ this ->assertNotFalse (
209192 $ eventOffset ,
210193 'applyRecordVersionMarker() no longer emits HistoryEventType::VersionMarkerRecorded. '
211- .'This is a protocol break — see docs/api-stability.md#frozen-history-event-wire-formats. ' ,
194+ . 'This is a protocol break — see docs/api-stability.md#frozen-history-event-wire-formats. ' ,
212195 );
213196
214197 // Collect every `'key' =>` pair on the lines immediately after the
@@ -225,9 +208,22 @@ public function testBridgeEmissionSiteStillUsesFrozenEventPayloadKeys(): void
225208 $ expected ,
226209 $ foundKeys ,
227210 'VersionMarkerRecorded payload keys in applyRecordVersionMarker() have shifted — '
228- .'this is a protocol break. Old workflow rows still carry the old keys, and '
229- .'replayers on other SDKs still read them by name. Introduce a parallel event '
230- .'type (e.g. VersionMarkerRecordedV2) instead of changing this shape. ' ,
211+ . 'this is a protocol break. Old workflow rows still carry the old keys, and '
212+ . 'replayers on other SDKs still read them by name. Introduce a parallel event '
213+ . 'type (e.g. VersionMarkerRecordedV2) instead of changing this shape. ' ,
231214 );
232215 }
216+
217+ private function expectExceptionOnce (callable $ callable , string $ message ): void
218+ {
219+ try {
220+ $ callable ();
221+ } catch (ValidationException ) {
222+ $ this ->addToAssertionCount (1 );
223+
224+ return ;
225+ }
226+
227+ $ this ->fail ($ message );
228+ }
233229}
0 commit comments