You are here

public function PhoneFrenchTest::testPhoneFRInvalid in Phone 7

Same name and namespace in other branches
  1. 6 tests/phone-fr.test \PhoneFrenchTest::testPhoneFRInvalid()

File

tests/phone.fr.test, line 62

Class

PhoneFrenchTest
Unit tests for Phone module.

Code

public function testPhoneFRInvalid() {
  $this
    ->assertFalse(valid_phone_number('fr', '+33 123456789a'), "'+33 123456789a' should not be valid because wrong char");
  $this
    ->assertFalse(valid_phone_number('fr', '+33 1234567a89'), "'+33 1234567a89' should not be valid because wrong char");
  $this
    ->assertFalse(valid_phone_number('fr', '0 123456789a'), "'0 123456789a' should not be valid because wrong char");
  $this
    ->assertFalse(valid_phone_number('fr', '0 1234567a89'), "'0 1234567a89' should not be valid because wrong char");
  $this
    ->assertFalse(valid_phone_number('fr', '+33 1234567890'), "'+33 1234567890' should not be valid because too long");
  $this
    ->assertFalse(valid_phone_number('fr', '+33 12345678'), "'+33 12345678' should not be valid because too short");
  $this
    ->assertFalse(valid_phone_number('fr', '0 1234567890'), "'0 1234567890' should not be valid because too long");
  $this
    ->assertFalse(valid_phone_number('fr', '0 12345678'), "'0 12345678' should not be valid because too short");

  // 07... not assigned
  $this
    ->assertFalse(valid_phone_number('fr', '+33723456789'), "'+33723456789' is unassigned so should not be valid");
  $this
    ->assertFalse(valid_phone_number('fr', '0723456789'), "'0723456789' is unassigned so should not be valid");

  // except 0876... not assigned
  $this
    ->assertFalse(valid_phone_number('fr', '+33876456789'), "'+33873456789' is unassigned so should not be valid");
  $this
    ->assertFalse(valid_phone_number('fr', '0876456789'), "'0873456789' is unassigned so should not be valid");

  // 80... 81... 82... 83... 84... 86... 88... 89... not assigned
  foreach (array(
    '80',
    '81',
    '82',
    '83',
    '84',
    '86',
    '88',
    '89',
  ) as $za) {
    $this
      ->assertFalse(valid_phone_number('fr', '+33' . $za . '1234567'), "'+33'. {$za} .'1234567' is unassigned so should not be valid");
    $this
      ->assertFalse(valid_phone_number('fr', '0' . $za . '1234567'), "'0'. {$za} .'1234567' is unassigned so should not be valid");
  }

  // 09... not assigned
  $this
    ->assertFalse(valid_phone_number('fr', '+33923456789'), "'+33923456789' is unassigned so should not be valid");
  $this
    ->assertFalse(valid_phone_number('fr', '0923456789'), "'0923456789' is unassigned so should not be valid");

  // 00... not assigned
  $this
    ->assertFalse(valid_phone_number('fr', '+33023456789'), "'+33023456789' is unassigned so should not be valid");
  $this
    ->assertFalse(valid_phone_number('fr', '0023456789'), "'0023456789' is unassigned so should not be valid");
}