assertEquals($expected, $result); } /** * @expectedException Requests_Exception */ public function testASCIITooLong() { $data = str_repeat("abcd", 20); $result = Requests_IDNAEncoder::encode($data); } /** * @expectedException Requests_Exception */ public function testEncodedTooLong() { $data = str_repeat("\xe4\xbb\x96", 60); $result = Requests_IDNAEncoder::encode($data); } /** * @expectedException Requests_Exception */ public function testAlreadyPrefixed() { $result = Requests_IDNAEncoder::encode("xn--\xe4\xbb\x96"); } public function testASCIICharacter() { $result = Requests_IDNAEncoder::encode("a"); $this->assertEquals('a', $result); } public function testTwoByteCharacter() { $result = Requests_IDNAEncoder::encode("\xc2\xb6"); // Pilcrow character $this->assertEquals('xn--tba', $result); } public function testThreeByteCharacter() { $result = Requests_IDNAEncoder::encode("\xe2\x82\xac"); // Euro symbol $this->assertEquals('xn--lzg', $result); } public function testFourByteCharacter() { $result = Requests_IDNAEncoder::encode("\xf0\xa4\xad\xa2"); // Chinese symbol? $this->assertEquals('xn--ww6j', $result); } /** * @expectedException Requests_Exception */ public function testFiveByteCharacter() { $result = Requests_IDNAEncoder::encode("\xfb\xb6\xb6\xb6\xb6"); } /** * @expectedException Requests_Exception */ public function testSixByteCharacter() { $result = Requests_IDNAEncoder::encode("\xfd\xb6\xb6\xb6\xb6\xb6"); } /** * @expectedException Requests_Exception */ public function testInvalidASCIICharacterWithMultibyte() { $result = Requests_IDNAEncoder::encode("\0\xc2\xb6"); } /** * @expectedException Requests_Exception */ public function testUnfinishedMultibyte() { $result = Requests_IDNAEncoder::encode("\xc2"); } /** * @expectedException Requests_Exception */ public function testPartialMultibyte() { $result = Requests_IDNAEncoder::encode("\xc2\xc2\xb6"); } }