コード例 #1
0
 /**
  * @covers WPGlobus_Utils::domain_tld
  */
 public static function test_domain_tld()
 {
     $schemes = array('http://', 'https://', '//', '');
     $domains = array('example', 'with-dashes', 'localhost');
     $prefixes = array('', 'www.', 'develop.', '127.', 'multiple.prefixes.');
     $tlds = array('.com', '.co.uk', '.com.au', '.a.bg', '.edu.hk', '.bg.it');
     foreach ($schemes as $scheme) {
         foreach ($prefixes as $prefix) {
             foreach ($domains as $domain) {
                 foreach ($tlds as $tld) {
                     self::assertEquals($domain . $tld, WPGlobus_Utils::domain_tld($scheme . $prefix . $domain . $tld));
                 }
             }
         }
     }
     // Example of parse_url failure (we return the input as-is)
     self::assertEquals('http://', WPGlobus_Utils::domain_tld('http://'));
     // Special cases
     self::assertEquals('localhost', WPGlobus_Utils::domain_tld('http://localhost'));
     self::assertEquals('127.0.0.1', WPGlobus_Utils::domain_tld('http://127.0.0.1'));
     self::assertEquals('example.special-public-suffix.it', WPGlobus_Utils::domain_tld('http://www.example.special-public-suffix.it'));
 }