@@ -25,28 +25,30 @@ protected function setUp(): void
2525
2626 /**
2727 * Test annotation to JSON conversion
28+ *
29+ * @since 2.9.0 Annotation keys now match Ti2Order directly (no offset)
2830 */
2931 public function testAnnotationToJson (): void
3032 {
3133 // Empty annotation
3234 $ this ->assertEquals ('{} ' , $ this ->annotationService ->annotationToJson ('' ));
3335
34- // Single annotation
36+ // Single annotation - key should match the order value (1)
3537 $ annotation = "1 \tword \t5 \ttranslation " ;
3638 $ result = $ this ->annotationService ->annotationToJson ($ annotation );
3739 $ this ->assertJson ($ result );
3840 $ decoded = json_decode ($ result , true );
39- $ this ->assertArrayHasKey (0 , $ decoded );
40- $ this ->assertEquals (['word ' , '5 ' , 'translation ' ], $ decoded [0 ]);
41+ $ this ->assertArrayHasKey (1 , $ decoded );
42+ $ this ->assertEquals (['word ' , '5 ' , 'translation ' ], $ decoded [1 ]);
4143
42- // Multiple annotations
44+ // Multiple annotations - keys should match order values (1 and 2)
4345 $ annotation = "1 \tword1 \t5 \ttrans1 \n2 \tword2 \t3 \ttrans2 " ;
4446 $ result = $ this ->annotationService ->annotationToJson ($ annotation );
4547 $ this ->assertJson ($ result );
4648 $ decoded = json_decode ($ result , true );
4749 $ this ->assertCount (2 , $ decoded );
48- $ this ->assertEquals (['word1 ' , '5 ' , 'trans1 ' ], $ decoded [0 ]);
49- $ this ->assertEquals (['word2 ' , '3 ' , 'trans2 ' ], $ decoded [1 ]);
50+ $ this ->assertEquals (['word1 ' , '5 ' , 'trans1 ' ], $ decoded [1 ]);
51+ $ this ->assertEquals (['word2 ' , '3 ' , 'trans2 ' ], $ decoded [2 ]);
5052 }
5153
5254 /**
@@ -69,11 +71,11 @@ public function testAnnotationToJsonEdgeCases(): void
6971 $ result = $ this ->annotationService ->annotationToJson ($ annotation );
7072 $ this ->assertJson ($ result );
7173
72- // Unicode in annotations
74+ // Unicode in annotations - key should match order value (1)
7375 $ annotation = "1 \t日本語 \t5 \ttranslation " ;
7476 $ result = $ this ->annotationService ->annotationToJson ($ annotation );
7577 $ this ->assertJson ($ result );
7678 $ decoded = json_decode ($ result , true );
77- $ this ->assertStringContainsString ('日本語 ' , $ decoded [0 ][0 ]);
79+ $ this ->assertStringContainsString ('日本語 ' , $ decoded [1 ][0 ]);
7880 }
7981}
0 commit comments