@@ -362,4 +362,29 @@ public function testLoadVersion2WithName()
362
362
363
363
$ this ->assertEquals (['foo ' => 'bar ' , 'bar ' => 'baz ' , 'baz ' => 'foo ' , 'qux ' => 'qux source ' ], $ catalogue ->all ('domain1 ' ));
364
364
}
365
+
366
+ public function testLoadVersion2WithSegmentAttributes ()
367
+ {
368
+ $ loader = new XliffFileLoader ();
369
+ $ resource = __DIR__ .'/../Fixtures/resources-2.0-segment-attributes.xlf ' ;
370
+ $ catalogue = $ loader ->load ($ resource , 'en ' , 'domain1 ' );
371
+
372
+ // test for "foo" metadata
373
+ $ this ->assertTrue ($ catalogue ->defines ('foo ' , 'domain1 ' ));
374
+ $ metadata = $ catalogue ->getMetadata ('foo ' , 'domain1 ' );
375
+ $ this ->assertNotEmpty ($ metadata );
376
+ $ this ->assertCount (1 , $ metadata ['segment-attributes ' ]);
377
+ $ this ->assertArrayHasKey ('state ' , $ metadata ['segment-attributes ' ]);
378
+ $ this ->assertSame ('translated ' , $ metadata ['segment-attributes ' ]['state ' ]);
379
+
380
+ // test for "key" metadata
381
+ $ this ->assertTrue ($ catalogue ->defines ('key ' , 'domain1 ' ));
382
+ $ metadata = $ catalogue ->getMetadata ('key ' , 'domain1 ' );
383
+ $ this ->assertNotEmpty ($ metadata );
384
+ $ this ->assertCount (2 , $ metadata ['segment-attributes ' ]);
385
+ $ this ->assertArrayHasKey ('state ' , $ metadata ['segment-attributes ' ]);
386
+ $ this ->assertSame ('translated ' , $ metadata ['segment-attributes ' ]['state ' ]);
387
+ $ this ->assertArrayHasKey ('subState ' , $ metadata ['segment-attributes ' ]);
388
+ $ this ->assertSame ('My Value ' , $ metadata ['segment-attributes ' ]['subState ' ]);
389
+ }
365
390
}
0 commit comments