/** * @covers Patchwork\PHP\Override\Normalizer::normalize */ function testNormalize() { $c = in::normalize("déjà ", pn::NFC) . in::normalize("훈쇼™", pn::NFD); $this->assertSame($c, pn::normalize($c, pn::NONE)); $this->assertSame($c, in::normalize($c, pn::NONE)); $c = "déjà 훈쇼™"; $d = in::normalize($c, pn::NFD); $kc = in::normalize($c, pn::NFKC); $kd = in::normalize($c, pn::NFKD); $this->assertSame('', pn::normalize('')); $this->assertSame($c, pn::normalize($d)); $this->assertSame($c, pn::normalize($d, pn::NFC)); $this->assertSame($d, pn::normalize($c, pn::NFD)); $this->assertSame($kc, pn::normalize($d, pn::NFKC)); $this->assertSame($kd, pn::normalize($c, pn::NFKD)); $this->assertFalse(pn::normalize($c, -1)); $this->assertFalse(pn::normalize("ÿ")); }
/** * @covers Patchwork\PHP\Override\Normalizer::normalize */ function testNormalize() { $t = file(__DIR__ . '/NormalizationTest.' . $this->unicodeVersion . '.txt'); $c = array(); foreach ($t as $s) { $t = explode("#", $s); $t = explode(';', $t[0]); if (6 === count($t)) { foreach ($t as $k => $s) { $t = explode(' ', $s); $t = array_map('hexdec', $t); $t = array_map('Patchwork\\Utf8::chr', $t); $c[$k] = implode('', $t); } $this->assertSame($c[1], n::normalize($c[0], n::NFC)); $this->assertSame($c[1], n::normalize($c[1], n::NFC)); $this->assertSame($c[1], n::normalize($c[2], n::NFC)); $this->assertSame($c[3], n::normalize($c[3], n::NFC)); $this->assertSame($c[3], n::normalize($c[4], n::NFC)); $this->assertSame($c[2], n::normalize($c[0], n::NFD)); $this->assertSame($c[2], n::normalize($c[1], n::NFD)); $this->assertSame($c[2], n::normalize($c[2], n::NFD)); $this->assertSame($c[4], n::normalize($c[3], n::NFD)); $this->assertSame($c[4], n::normalize($c[4], n::NFD)); $this->assertSame($c[3], n::normalize($c[0], n::NFKC)); $this->assertSame($c[3], n::normalize($c[1], n::NFKC)); $this->assertSame($c[3], n::normalize($c[2], n::NFKC)); $this->assertSame($c[3], n::normalize($c[3], n::NFKC)); $this->assertSame($c[3], n::normalize($c[4], n::NFKC)); $this->assertSame($c[4], n::normalize($c[0], n::NFKD)); $this->assertSame($c[4], n::normalize($c[1], n::NFKD)); $this->assertSame($c[4], n::normalize($c[2], n::NFKD)); $this->assertSame($c[4], n::normalize($c[3], n::NFKD)); $this->assertSame($c[4], n::normalize($c[4], n::NFKD)); } } }