EmailAddressCharacteristicTest::testValidate()   A
last analyzed

Complexity

Conditions 4
Paths 27

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 24
rs 9.6666
c 0
b 0
f 0
cc 4
nc 27
nop 0
1
<?php
2
3
namespace Tests\Common\BasicAttribute;
4
5
use Bpost\BpostApiClient\BpostException;
6
use Bpost\BpostApiClient\Common\BasicAttribute\EmailAddressCharacteristic;
7
use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException;
8
use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidPatternException;
9
use PHPUnit_Framework_TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit_Framework_TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
class EmailAddressCharacteristicTest extends PHPUnit_Framework_TestCase
12
{
13
    public function testValidate()
14
    {
15
        $value = '[email protected]';
16
        try {
17
            $test = new EmailAddressCharacteristic($value);
18
            $this->assertEquals($value, $test->getValue());
19
        } catch (BpostException $ex) {
20
            $this->fail('Exception launched for valid value: "' . $value . '"');
21
        }
22
23
        $value = 'myBeautifulAndLongEmailAddressFor2016@antidot-company-based-at-Brussels.com';
24
        try {
25
            new EmailAddressCharacteristic($value);
26
            $this->fail('Exception uncaught for invalid value: "' . $value . '"');
27
        } catch (BpostInvalidLengthException $ex) {
28
            $this->assertTrue(true);
29
        }
30
31
        $value = '[email protected]';
32
        try {
33
            new EmailAddressCharacteristic($value);
34
            $this->fail('Exception uncaught for invalid value: "' . $value . '"');
35
        } catch (BpostInvalidPatternException $ex) {
36
            $this->assertTrue(true);
37
        }
38
    }
39
}
40