Example #1
0
 public function testExampleNumbersAgainstPossible()
 {
     $this->validator->allowPossible(true);
     foreach ($this->phone as $country => $parameters) {
         $this->validator->setCountry($country);
         foreach ($parameters['patterns']['example'] as $type => $value) {
             $this->validator->allowedTypes(array($type));
             $this->assertTrue($this->validator->isValid($value));
             // check with country code:
             $value = $parameters['code'] . $value;
             $this->assertTrue($this->validator->isValid($value));
         }
     }
 }
Example #2
0
 /**
  * @TODO: use dataProvider for this in order to enforce clean context
  */
 public function testExampleNumbersAgainstPossible()
 {
     $this->validator->allowPossible(true);
     foreach ($this->phone as $country => $parameters) {
         $this->validator->setCountry($country);
         foreach ($parameters['patterns']['example'] as $type => $values) {
             $values = is_array($values) ? $values : array($values);
             foreach ($values as $value) {
                 $this->validator->allowedTypes(array($type));
                 $this->assertTrue($this->validator->isValid($value));
                 // check with country code:
                 $countryCodePrefixed = $parameters['code'] . $value;
                 $this->assertTrue($this->validator->isValid($countryCodePrefixed));
                 // check fully qualified E.123/E.164 international variants
                 $fullyQualifiedDoubleO = '00' . $parameters['code'] . $value;
                 $this->assertTrue($this->validator->isValid($fullyQualifiedDoubleO), $fullyQualifiedDoubleO);
                 $fullyQualifiedPlus = '+' . $parameters['code'] . $value;
                 $this->assertTrue($this->validator->isValid($fullyQualifiedPlus), $fullyQualifiedPlus);
             }
         }
     }
 }