Skip to content

Commit

Permalink
Wrapped node values in DOMTextNode elements
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasnoback committed Dec 16, 2012
1 parent 6f9c74b commit 1cb0789
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Expand Up @@ -37,7 +37,8 @@ public function getRequestContent()
$document->appendChild($rootElement);

foreach ($this->texts as $text) {
$stringElement = $document->createElement('string', $text);
$stringElement = $document->createElement('string');
$stringElement->appendChild($document->createTextNode($text));
$rootElement->appendChild($stringElement);
}

Expand Down
Expand Up @@ -31,7 +31,8 @@ public function getRequestContent()
$document->appendChild($rootElement);

foreach ($this->languageCodes as $languageCode) {
$stringElement = $document->createElement('string', $languageCode);
$stringElement = $document->createElement('string');
$stringElement->appendChild($document->createTextNode($languageCode));
$rootElement->appendChild($stringElement);
}

Expand Down
Expand Up @@ -52,18 +52,21 @@ public function getRequestContent()
$appIdElement = $document->createElement('AppId');
$rootElement->appendChild($appIdElement);

$fromElement = $document->createElement('From', $this->from);
$fromElement = $document->createElement('From');
$fromElement->appendChild($document->createTextNode($this->from));
$rootElement->appendChild($fromElement);

$textsElement = $document->createElement('Texts');
$rootElement->appendChild($textsElement);

foreach ($this->texts as $text) {
$stringElement = $document->createElementNS('http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'string', $text);
$stringElement = $document->createElementNS('http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'string');
$stringElement->appendChild($document->createTextNode($text));
$textsElement->appendChild($stringElement);
}

$toElement = $document->createElement('To', $this->to);
$toElement = $document->createElement('To');
$toElement->appendChild($document->createTextNode($this->to));
$rootElement->appendChild($toElement);

return $document->saveXML();
Expand Down
Expand Up @@ -48,11 +48,13 @@ public function testTranslateArray()
$translatedTexts = $this->translator->translateArray(array(
'This is a test',
'My name is Matthias',
'You are naïve!',
), 'nl', 'en');

$this->assertSame(array(
'Dit is een test',
'Mijn naam is Matthias'
'Mijn naam is Matthias',
'U bent naïef!',
), $translatedTexts);
}

Expand Down

0 comments on commit 1cb0789

Please sign in to comment.