| 1 | <?php |
||
| 7 | class CodeCoverageTest extends \PHPUnit_Framework_TestCase |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var PhoneNumberUtil |
||
| 11 | */ |
||
| 12 | private $phoneUtil; |
||
| 13 | |||
| 14 | public function setUp() |
||
| 15 | { |
||
| 16 | PhoneNumberUtil::resetInstance(); |
||
| 17 | $this->phoneUtil = PhoneNumberUtil::getInstance(); |
||
| 18 | } |
||
| 19 | |||
| 20 | public function testNullException() |
||
| 21 | { |
||
| 22 | try { |
||
| 23 | $this->phoneUtil->parse(null, null); |
||
| 24 | } catch (\Exception $e) { |
||
| 25 | $this->assertEquals("libphonenumber\\NumberParseException", get_class($e)); |
||
| 26 | $this->assertEquals("The phone number supplied was null.", $e->getMessage()); |
||
| 27 | |||
| 28 | $this->assertEquals("Error type: 1. The phone number supplied was null.", (string)$e); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | public function testTooShortNumber() |
||
| 33 | { |
||
| 34 | try { |
||
| 35 | $this->phoneUtil->parse("+441", "GB"); |
||
| 36 | } catch (\Exception $e) { |
||
| 37 | $this->assertEquals("libphonenumber\\NumberParseException", get_class($e)); |
||
| 38 | $this->assertEquals("The string supplied is too short to be a phone number.", $e->getMessage()); |
||
| 39 | $this->assertEquals(3, $e->getCode()); |
||
| 40 | |||
| 41 | $this->assertEquals("Error type: 3. The string supplied is too short to be a phone number.", (string)$e); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 |