Completed
Push — master ( 3ced6b...53bd9f )
by Marcin
01:36
created

MacTest::testVendor()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
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\Mac;
18
19
class MacTest extends TestCase
20
{
21
    public function testMacValid()
22
    {
23
        $defNr = '00:01:02:aa:BB:EF';
24
        $this->assertTrue(Mac::isValid($defNr, false));
25
        $res = new Mac($defNr);
26
        $this->assertEquals('000102aabbef', $res->get());
27
        $this->assertEquals('000102AABBEF', $res->getShort(true));
28
        $this->assertEquals('00-01-02-AA-BB-EF', $res->getLong('-', true));
29
        $this->assertEquals('00-01-02-aa-bb-ef', $res->getLong('-', false));
30
    }
31
32
    /**
33
     * @expectedException \mrcnpdlk\Validator\Exception
34
     */
35
    public function testMacInvalidValidOne()
36
    {
37
        Mac::isValid('00:1122:33:44:55:66', true);
38
    }
39
40
    public function testMacInvalidValidTwo()
41
    {
42
        $this->assertFalse(Mac::isValid('00:1122:33:44:55:66', false));
43
    }
44
45
    /**
46
     * @expectedException \mrcnpdlk\Validator\Exception
47
     */
48
    public function testMacInvalidRegexOne()
49
    {
50
        new Mac('001122334455667');
51
    }
52
53
    /**
54
     * @expectedException \mrcnpdlk\Validator\Exception
55
     */
56
    public function testMacInvalidRegexTwo()
57
    {
58
        new Mac('0011223344556g');
59
    }
60
61
    /**
62
     * @expectedException \mrcnpdlk\Validator\Exception
63
     */
64
    public function testMacInvalidRegexThree()
65
    {
66
        new Mac(112233445566);
67
    }
68
69
    public function testVendor()
70
    {
71
        $sVendor = Mac::create('00:02:9b:3a:a0:d7')->getVendor();
72
        $this->assertTrue(is_string($sVendor) || is_null($sVendor));
73
    }
74
75
}
76