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\Pna; |
18
|
|
|
|
19
|
|
|
class PnaTest extends TestCase |
20
|
|
|
{ |
21
|
|
View Code Duplication |
public function testPnaValidShort() |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
$defNr = '90019'; |
24
|
|
|
$this->assertTrue(Pna::isValid($defNr, false)); |
25
|
|
|
$res = new Pna($defNr); |
26
|
|
|
$this->assertEquals('90019', $res->get()); |
27
|
|
|
$this->assertEquals('90019', $res->getShort()); |
28
|
|
|
$this->assertEquals('90-019', $res->getLong()); |
29
|
|
|
} |
30
|
|
View Code Duplication |
public function testPnaValidLong() |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
$defNr = '90-019'; |
33
|
|
|
$this->assertTrue(Pna::isValid($defNr, false)); |
34
|
|
|
$res = new Pna($defNr); |
35
|
|
|
$this->assertEquals('90019', $res->get()); |
36
|
|
|
$this->assertEquals('90019', $res->getShort()); |
37
|
|
|
$this->assertEquals('90-019', $res->getLong()); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testCreate() |
41
|
|
|
{ |
42
|
|
|
$res = Pna::create('01-234'); |
43
|
|
|
$this->assertEquals('01234', $res->get()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @expectedException \mrcnpdlk\Validator\Exception |
48
|
|
|
*/ |
49
|
|
|
public function testPnaInvalid() |
50
|
|
|
{ |
51
|
|
|
Pna::isValid('1-2345', true); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
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.