Esempio n. 1
0
 /**
  * Ensure the IDN check works on ressource files as expected
  *
  */
 public function testRessourceIDN()
 {
     $validator = new Hostname();
     // Check IDN matching
     $valuesExpected = array(array(true, array('bürger.com', 'hãllo.com', 'hållo.com')), array(true, array('bÜrger.com', 'hÃllo.com', 'hÅllo.com')), array(false, array('hãllo.lt', 'bürger.lt', 'hãllo.lt')));
     foreach ($valuesExpected as $element) {
         foreach ($element[1] as $input) {
             $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()) . $input);
         }
     }
     // Check no IDN matching
     $validator->setValidateIdn(false);
     $valuesExpected = array(array(false, array('bürger.com', 'hãllo.com', 'hållo.com')));
     foreach ($valuesExpected as $element) {
         foreach ($element[1] as $input) {
             $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()) . $input);
         }
     }
     // Check setting no IDN matching via constructor
     unset($validator);
     $validator = new Hostname(Hostname::ALLOW_DNS, false);
     $valuesExpected = array(array(false, array('bürger.com', 'hãllo.com', 'hållo.com')));
     foreach ($valuesExpected as $element) {
         foreach ($element[1] as $input) {
             $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()) . $input);
         }
     }
 }