Completed
Push — master ( d90020...eca10a )
by Rob
04:28
created

EmailTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 53
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace devtoolboxuk\cerberus;
4
5
use devtoolboxuk\cerberus\Handlers\EmailHandler;
6
use PHPUnit\Framework\TestCase;
7
8
class EmailTest extends TestCase
9
{
10
11
    private $options = [];
12
13
    function __construct($name = null, array $data = [], $dataName = '')
14
    {
15
        parent::__construct($name, $data, $dataName);
16
        $this->options = $this->getTestData();
17
    }
18
19
    private function getTestData()
20
    {
21
        /** @noinspection PhpIncludeInspection */
22
        return include __DIR__ . '/options.php';
23
    }
24
25
    function testDisposableEmail()
26
    {
27
28
        $cerberus = new CerberusService();
29
        $cerberus->setOptions($this->getOptions());
30
31
        $email_data = '[email protected]';
32
        $detection = $cerberus
33
            ->pushHandler(new EmailHandler($email_data));
34
35
        $this->assertEquals(46, $detection->getScore());
36
        $this->assertEquals('{"DisposableEmail":"46"}', $detection->getResult());
37
38
    }
39
40
    private function getOptions()
41
    {
42
        return $this->options;
43
    }
44
45
    function testValidEmail()
46
    {
47
48
        $cerberus = new CerberusService();
49
        $cerberus->setOptions($this->getOptions());
50
51
        $email_data = '[email protected]';
52
        $detection = $cerberus
53
            ->pushHandler(new EmailHandler($email_data));
54
55
        $this->assertEquals(0, $detection->getScore());
56
        $this->assertEquals('[]', $detection->getResult());
57
58
    }
59
60
}
61