| @@ 42-72 (lines=31) @@ | ||
| 39 | parent::tearDown(); |
|
| 40 | } |
|
| 41 | ||
| 42 | public function testConcatenationInEntityValues() |
|
| 43 | { |
|
| 44 | $c = i18nTextCollector::create(); |
|
| 45 | $module = ModuleLoader::instance()->getManifest()->getModule('i18ntestmodule'); |
|
| 46 | ||
| 47 | $php = <<<PHP |
|
| 48 | _t( |
|
| 49 | 'Test.CONCATENATED', |
|
| 50 | 'Line 1 and ' . |
|
| 51 | 'Line \'2\' and ' . |
|
| 52 | 'Line "3"', |
|
| 53 | ||
| 54 | 'Comment' |
|
| 55 | ); |
|
| 56 | ||
| 57 | _t( |
|
| 58 | 'Test.CONCATENATED2', |
|
| 59 | "Line \"4\" and " . |
|
| 60 | "Line 5"); |
|
| 61 | PHP; |
|
| 62 | $this->assertEquals( |
|
| 63 | array( |
|
| 64 | 'Test.CONCATENATED' => [ |
|
| 65 | 'default' => "Line 1 and Line '2' and Line \"3\"", |
|
| 66 | 'comment' => 'Comment' |
|
| 67 | ], |
|
| 68 | 'Test.CONCATENATED2' => "Line \"4\" and Line 5" |
|
| 69 | ), |
|
| 70 | $c->collectFromCode($php, null, $module) |
|
| 71 | ); |
|
| 72 | } |
|
| 73 | ||
| 74 | public function testCollectFromNewTemplateSyntaxUsingParserSubclass() |
|
| 75 | { |
|
| @@ 318-355 (lines=38) @@ | ||
| 315 | ); |
|
| 316 | } |
|
| 317 | ||
| 318 | public function testCollectFromCodeNamespace() |
|
| 319 | { |
|
| 320 | $c = i18nTextCollector::create(); |
|
| 321 | $mymodule = ModuleLoader::instance()->getManifest()->getModule('i18ntestmodule'); |
|
| 322 | $php = <<<PHP |
|
| 323 | <?php |
|
| 324 | namespace SilverStripe\Framework\Core; |
|
| 325 | ||
| 326 | class MyClass extends Base implements SomeService { |
|
| 327 | public function getNewLines() { |
|
| 328 | return _t( |
|
| 329 | __CLASS__.'.NEWLINES', |
|
| 330 | 'New Lines' |
|
| 331 | ); |
|
| 332 | } |
|
| 333 | public function getAnotherString() { |
|
| 334 | return _t( |
|
| 335 | 'SilverStripe\\\\Framework\\\\MyClass.ANOTHER_STRING', |
|
| 336 | 'Slash=\\\\, Quote=\\'' |
|
| 337 | ); |
|
| 338 | } |
|
| 339 | public function getDoubleQuotedString() { |
|
| 340 | return _t( |
|
| 341 | "SilverStripe\\\\Framework\\\\MyClass.DOUBLE_STRING", |
|
| 342 | "Slash=\\\\, Quote=\\"" |
|
| 343 | ); |
|
| 344 | } |
|
| 345 | } |
|
| 346 | PHP; |
|
| 347 | $this->assertEquals( |
|
| 348 | [ |
|
| 349 | 'SilverStripe\\Framework\\Core\\MyClass.NEWLINES' => "New Lines", |
|
| 350 | 'SilverStripe\\Framework\\MyClass.ANOTHER_STRING' => 'Slash=\\, Quote=\'', |
|
| 351 | 'SilverStripe\\Framework\\MyClass.DOUBLE_STRING' => 'Slash=\\, Quote="' |
|
| 352 | ], |
|
| 353 | $c->collectFromCode($php, null, $mymodule) |
|
| 354 | ); |
|
| 355 | } |
|
| 356 | ||
| 357 | ||
| 358 | public function testNewlinesInEntityValues() |
|