コード例 #1
0
 /**
  * test the phone method of BrValidation
  *
  * @return void
  * @access public
  */
 function testPhone()
 {
     $this->assertFalse(BrValidation::phone('teststring'));
     $this->assertFalse(BrValidation::phone('1-(33)-(333)-(4444)'));
     $this->assertFalse(BrValidation::phone('1-(33)-3333-4444'));
     $this->assertFalse(BrValidation::phone('1-(33)-33-4444'));
     $this->assertFalse(BrValidation::phone('1-(33)-3-44444'));
     $this->assertFalse(BrValidation::phone('1-(33)-3-444'));
     $this->assertFalse(BrValidation::phone('1-(33)-3-44'));
     $this->assertFalse(BrValidation::phone('2345678'));
     $this->assertTrue(BrValidation::phone('55 (48) 2345 6789'));
     $this->assertTrue(BrValidation::phone('+55 (48) 2345 6789'));
     $this->assertTrue(BrValidation::phone('+55 (048) 2345 6789'));
     $this->assertTrue(BrValidation::phone('+55 (48) 2345-6789'));
     $this->assertTrue(BrValidation::phone('+55 (48) 2345.6789'));
     $this->assertTrue(BrValidation::phone('(48) 2345 6789'));
     $this->assertTrue(BrValidation::phone('2345-6789'));
     $this->assertTrue(BrValidation::phone('2345.6789'));
     $this->assertTrue(BrValidation::phone('23456789'));
 }
コード例 #2
0
 /**
  * test the phone method of BrValidation
  *
  * @return void
  */
 public function testPhone()
 {
     $this->assertFalse(BrValidation::phone('teststring'));
     $this->assertFalse(BrValidation::phone('1-(33)-(333)-(4444)'));
     $this->assertFalse(BrValidation::phone('1-(33)-3333-4444'));
     $this->assertFalse(BrValidation::phone('1-(33)-33-4444'));
     $this->assertFalse(BrValidation::phone('1-(33)-3-44444'));
     $this->assertFalse(BrValidation::phone('1-(33)-3-444'));
     $this->assertFalse(BrValidation::phone('1-(33)-3-44'));
     $this->assertFalse(BrValidation::phone('2345678'));
     // with the wrong extra digit
     $this->assertFalse(BrValidation::phone('55 (48) 12345 6789'));
     $this->assertFalse(BrValidation::phone('+55 (48) 22345 6789'));
     $this->assertFalse(BrValidation::phone('+55 (048) 32345 6789'));
     $this->assertFalse(BrValidation::phone('+55 (48) 42345-6789'));
     $this->assertFalse(BrValidation::phone('+55 (48) 52345.6789'));
     $this->assertFalse(BrValidation::phone('(48) 12345 6789'));
     $this->assertTrue(BrValidation::phone('55 (48) 2345 6789'));
     $this->assertTrue(BrValidation::phone('+55 (48) 2345 6789'));
     $this->assertTrue(BrValidation::phone('+55 (048) 2345 6789'));
     $this->assertTrue(BrValidation::phone('+55 (48) 2345-6789'));
     $this->assertTrue(BrValidation::phone('+55 (48) 2345.6789'));
     $this->assertTrue(BrValidation::phone('(48) 2345 6789'));
     $this->assertTrue(BrValidation::phone('2345-6789'));
     $this->assertTrue(BrValidation::phone('2345.6789'));
     $this->assertTrue(BrValidation::phone('23456789'));
     // // with the extra digit
     $this->assertTrue(BrValidation::phone('55 (48) 92345 6789'));
     $this->assertTrue(BrValidation::phone('+55 (48) 92345 6789'));
     $this->assertTrue(BrValidation::phone('+55 (048) 92345 6789'));
     $this->assertTrue(BrValidation::phone('+55 (48) 92345-6789'));
     $this->assertTrue(BrValidation::phone('+55 (48) 92345.6789'));
     $this->assertTrue(BrValidation::phone('(48) 92345 6789'));
     $this->assertTrue(BrValidation::phone('92345-6789'));
     $this->assertTrue(BrValidation::phone('92345.6789'));
     $this->assertTrue(BrValidation::phone('923456789'));
 }
コード例 #3
0
 /**
  * Valida telefones
  * 
  * @param  string $data O telefone
  * 
  * @return boolean
  */
 public function phone($data)
 {
     return BrValidation::phone(array_shift($data));
 }