Completed
Push — master ( 027b92...c7a3ba )
by Marcin
01:41
created

PhoneTest::testFixed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 12
loc 12
rs 9.4285
c 1
b 1
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
/**
3
 * Validator
4
 *
5
 * Copyright (c) 2017 pudelek.org.pl
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For the full copyright and license information, please view source file
10
 * that is bundled with this package in the file LICENSE
11
 *
12
 * @author  Marcin Pudełek <[email protected]>
13
 */
14
15
namespace mrcnpdlk\Validator;
16
17
use mrcnpdlk\Validator\Types\Phone;
18
19
class PhoneTest extends TestCase
20
{
21
    public function testCreate()
22
    {
23
        $res = Phone::create('48123123123');
24
        $this->assertEquals('123123123', $res->get());
25
    }
26
27 View Code Duplication
    public function testMobile()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
    {
29
        $defNr = '48601123123';
30
        $res   = new Phone($defNr);
31
        $this->assertTrue($res->isMobile());
32
        $this->assertFalse($res->isFixed());
33
        $this->assertFalse($res->isVoip());
34
        $this->assertFalse($res->isUAN());
35
        $this->assertFalse($res->isSharedCost());
36
        $this->assertFalse($res->isPremiumRate());
37
        $this->assertFalse($res->isTollFree());
38
    }
39 View Code Duplication
    public function testFixed()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $defNr = '48421123123';
42
        $res   = new Phone($defNr);
43
        $this->assertFalse($res->isMobile());
44
        $this->assertTrue($res->isFixed());
45
        $this->assertFalse($res->isVoip());
46
        $this->assertFalse($res->isUAN());
47
        $this->assertFalse($res->isSharedCost());
48
        $this->assertFalse($res->isPremiumRate());
49
        $this->assertFalse($res->isTollFree());
50
    }
51
52
    /**
53
     * @expectedException \mrcnpdlk\Validator\Exception
54
     */
55
    public function testPhoneEmpty()
56
    {
57
        new Phone('');
58
    }
59
60
    /**
61
     * @expectedException \mrcnpdlk\Validator\Exception
62
     */
63
    public function testPhoneInvalid()
64
    {
65
        new Phone('44123123123');
66
    }
67
68
    public function testPhoneValid()
69
    {
70
        $defNr = '48123123123';
71
        $res   = new Phone($defNr);
72
        $this->assertEquals('123123123', $res->get());
73
    }
74
75
}
76