protected function _readValidation($path, $locale) { if (!($territory = Locale::territory($locale))) { return null; } $data = array(); $file = "{$path}/supplemental/postalCodeData.xml"; $query = "/supplementalData/postalCodeData"; $query .= "/postCodeRegex[@territoryId=\"{$territory}\"]"; $nodes = $this->_parseXml($file, $query); $regex = (string) current($nodes); return $this->_merge($data, array('id' => 'postalCode', 'translated' => "/^{$regex}\$/")); }
/** * 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'); }); }