/** * Input for langArrayCodeForEntitySpec() should be suitable for insertion * into single-quoted strings, so needs to be escaped already. */ function testLangArrayCodeForEntity() { $c = new i18nTextCollector(); $locale = $c->getDefaultLocale(); $this->assertEquals($c->langArrayCodeForEntitySpec('Test.SIMPLE', array('Simple Value')), "\$lang['{$locale}']['Test']['SIMPLE'] = 'Simple Value';" . PHP_EOL); $this->assertEquals($c->langArrayCodeForEntitySpec('Test.ESCAPEDSINGLEQUOTES', array("Value with \\'Escaped Single Quotes\\'")), "\$lang['{$locale}']['Test']['ESCAPEDSINGLEQUOTES'] = 'Value with \\'Escaped Single Quotes\\'';" . PHP_EOL); $this->assertEquals($c->langArrayCodeForEntitySpec('Test.DOUBLEQUOTES', array('Value with "Double Quotes"')), "\$lang['{$locale}']['Test']['DOUBLEQUOTES'] = 'Value with \"Double Quotes\"';" . PHP_EOL); $php = <<<PHP \$lang['{$locale}']['Test']['PRIOANDCOMMENT'] = array( \t'Value with \\'Single Quotes\\'', \tPR_MEDIUM, \t'Comment with \\'Single Quotes\\'' ); PHP; $this->assertEquals($c->langArrayCodeForEntitySpec('Test.PRIOANDCOMMENT', array("Value with \\'Single Quotes\\'", 'PR_MEDIUM', "Comment with 'Single Quotes'")), $php); $php = <<<PHP \$lang['{$locale}']['Test']['PRIOANDCOMMENT'] = array( \t'Value with "Double Quotes"', \tPR_MEDIUM, \t'Comment with "Double Quotes"' ); PHP; $this->assertEquals($c->langArrayCodeForEntitySpec('Test.PRIOANDCOMMENT', array('Value with "Double Quotes"', 'PR_MEDIUM', 'Comment with "Double Quotes"')), $php); }