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
|
|
|
|