* @author JoakimLofgren
*/
-use PhpXmlRpc\Helper\Charset;
-
include_once __DIR__ . '/PolyfillTestCase.php';
+use PhpXmlRpc\Helper\Charset;
+
/**
* Test conversion between encodings
*
* and run the following in cmd:
* chcp 28591 (latin1)
* chcp 65001 (utf8)
+ *
+ * @todo add tests for conversion: utf8 -> ascii
+ * @todo add tests for conversion: latin1 -> utf8
*/
class CharsetTest extends PhpXmlRpc_PolyfillTestCase
{
protected $chinese = "我能吞下玻璃而不伤身体。";
protected $latinString;
+ /// @todo move to usage of a dataProvider and create the latinString there
protected function set_up()
{
// construct a latin string with all chars (except control ones)
}
}
- protected function utfToLatin($data)
+ protected function utf8ToLatin1($data)
{
return Charset::instance()->encodeEntities(
$data,
'Setup latinString is not ISO-8859-1 encoded...'
);*/
$string = utf8_encode($this->latinString);
- $encoded = $this->utfToLatin($string);
+ $encoded = $this->utf8ToLatin1($string);
$this->assertEquals(str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $this->latinString), $encoded);
}
public function testUtf8ToLatin1EuroSymbol()
{
$string = 'a.b.c.å.ä.ö.€.';
- $encoded = $this->utfToLatin($string);
+ $encoded = $this->utf8ToLatin1($string);
$this->assertEquals(utf8_decode('a.b.c.å.ä.ö.€.'), $encoded);
}
public function testUtf8ToLatin1Runes()
{
$string = $this->runes;
- $encoded = $this->utfToLatin($string);
+ $encoded = $this->utf8ToLatin1($string);
$this->assertEquals('ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ', $encoded);
}
public function testUtf8ToLatin1Greek()
{
$string = $this->greek;
- $encoded = $this->utfToLatin($string);
+ $encoded = $this->utf8ToLatin1($string);
$this->assertEquals('Τὴ γλῶσσα μοῦ ἔδωσαν ἑλληνικὴ', $encoded);
}
public function testUtf8ToLatin1Russian()
{
$string = $this->russian;
- $encoded = $this->utfToLatin($string);
+ $encoded = $this->utf8ToLatin1($string);
$this->assertEquals('Река неслася; бедный чёлн', $encoded);
}
public function testUtf8ToLatin1Chinese()
{
$string = $this->chinese;
- $encoded = $this->utfToLatin($string);
+ $encoded = $this->utf8ToLatin1($string);
$this->assertEquals('我能吞下玻璃而不伤身体。', $encoded);
}
}