Passed
Push — upstream-8.9.2 ( 6a22e8 )
by Joshua
25:34 queued 09:29
created

CodeCoverageTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 38
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace libphonenumber\Tests\Issues;
4
5
use libphonenumber\PhoneNumberUtil;
6
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