/** * @group exporter */ public function testExportWithValues() { $outFile = __DIR__ . $this->outFileName; $exporter = new XliffExporter(); // export array with values $exporter->export($outFile, array('key.a' => 'aaa', 'key.b' => 'bbb', 'key.c' => 'ccc')); $expectedContent = <<<C <?xml version="1.0" encoding="utf-8"?> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2"> <file source-language="en" datatype="plaintext" original="file.ext" target-language="en"> <body> <trans-unit id="1" approved="yes"> <source><![CDATA[key.a]]></source> <target><![CDATA[aaa]]></target> </trans-unit> <trans-unit id="2" approved="yes"> <source><![CDATA[key.b]]></source> <target><![CDATA[bbb]]></target> </trans-unit> <trans-unit id="3" approved="yes"> <source><![CDATA[key.c]]></source> <target><![CDATA[ccc]]></target> </trans-unit> </body> </file> </xliff> C; $this->assertXmlStringEqualsXmlFile($outFile, $expectedContent); }
/** * @group exporter */ public function testExport() { $outFile = __DIR__ . $this->outFileName; $exporter = new XliffExporter(); // export empty array $exporter->export($outFile, array()); $expectedContent = <<<C <?xml version="1.0"?> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <file source-language="en" datatype="plaintext" original="file.ext"> <body/> </file> </xliff> C; $this->assertEquals($expectedContent, file_get_contents($outFile)); // export array with values $exporter->export($outFile, array('key.a' => 'aaa', 'key.b' => 'bbb', 'key.c' => 'ccc')); $expectedContent = <<<C <?xml version="1.0"?> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <file source-language="en" datatype="plaintext" original="file.ext"> <body> <trans-unit id="1"> <source><![CDATA[key.a]]></source> <target><![CDATA[aaa]]></target> </trans-unit> <trans-unit id="2"> <source><![CDATA[key.b]]></source> <target><![CDATA[bbb]]></target> </trans-unit> <trans-unit id="3"> <source><![CDATA[key.c]]></source> <target><![CDATA[ccc]]></target> </trans-unit> </body> </file> </xliff> C; $this->assertEquals($expectedContent, file_get_contents($outFile)); }