/** * Tests parsing of locales using shortcut methods. * * @return void */ public function testDecomposeUsingShortcutMethods() { $this->assertEqual('zh', Locale::language('zh_Hans_HK_REVISED')); $this->assertEqual('Hans', Locale::script('zh_Hans_HK_REVISED')); $this->assertEqual('HK', Locale::territory('zh_Hans_HK_REVISED')); $this->assertEqual('REVISED', Locale::variant('zh_Hans_HK_REVISED')); $this->assertNull(Locale::script('zh_HK')); $this->assertNull(Locale::territory('zh')); $this->assertNull(Locale::variant('zh')); $this->expectException(); try { Locale::notAValidTag('zh_Hans_HK_REVISED'); $this->assert(false); } catch (Exception $e) { $this->assert(true); } }
/** * Tests parsing of locales using shortcut methods. */ public function testDecomposeUsingShortcutMethods() { $this->assertEqual('zh', Locale::language('zh_Hans_HK_REVISED')); $this->assertEqual('Hans', Locale::script('zh_Hans_HK_REVISED')); $this->assertEqual('HK', Locale::territory('zh_Hans_HK_REVISED')); $this->assertEqual('REVISED', Locale::variant('zh_Hans_HK_REVISED')); $this->assertNull(Locale::script('zh_HK')); $this->assertNull(Locale::territory('zh')); $this->assertNull(Locale::variant('zh')); $this->assertException('/.*/', function () { Locale::notAValidTag('zh_Hans_HK_REVISED'); }); }