Test Failed
Pull Request — master (#194)
by
unknown
02:39
created

MailboxCheckValidationTest::testValidMailbox()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 25
Ratio 100 %

Importance

Changes 0
Metric Value
dl 25
loc 25
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Egulias\Tests\EmailValidator\Validation;
4
5
use Egulias\EmailValidator\EmailLexer;
6
use Egulias\EmailValidator\Helper\SmtpSocketHelper;
7
use Egulias\EmailValidator\Validation\Error\IllegalMailbox;
8
use Egulias\EmailValidator\Validation\MailboxCheckValidation;
9
use Egulias\EmailValidator\Warning\NoDNSMXRecord;
10
use PHPUnit\Framework\TestCase;
11
12
class MailboxCheckValidationTest extends TestCase
13
{
14 View Code Duplication
    public function testValidMailbox()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
15
    {
16
        $socketHelperMock = $this->getMockBuilder(SmtpSocketHelper::class)
17
            ->disableOriginalConstructor()
18
            ->disableOriginalClone()
19
            ->disableArgumentCloning()
20
            ->disallowMockingUnknownTypes()
21
            ->getMock();
22
23
        $socketHelperMock
24
            ->expects($this->any())
25
            ->method('isResource')
26
            ->willReturn(true)
27
        ;
28
29
        $socketHelperMock
30
            ->expects($this->any())
31
            ->method('getResponseCode')
32
            ->willReturnOnConsecutiveCalls(220, 250, 250, 250)
33
        ;
34
35
        $validation = new MailboxCheckValidation($socketHelperMock, '[email protected]');
36
37
        $this->assertTrue($validation->isValid('[email protected]', new EmailLexer()));
38
    }
39
40 View Code Duplication
    public function testDNSWarnings()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
41
    {
42
        $validation = new MailboxCheckValidation(new SmtpSocketHelper(), '[email protected]');
43
        $expectedWarnings = [NoDNSMXRecord::CODE => new NoDNSMXRecord()];
44
        $validation->isValid('[email protected]', new EmailLexer());
45
        $this->assertEquals($expectedWarnings, $validation->getWarnings());
46
    }
47
48 View Code Duplication
    public function testIllegalMailboxError()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
49
    {
50
        $socketHelperMock = $this->getMockBuilder(SmtpSocketHelper::class)
51
            ->disableOriginalConstructor()
52
            ->disableOriginalClone()
53
            ->disableArgumentCloning()
54
            ->disallowMockingUnknownTypes()
55
            ->getMock();
56
57
        $socketHelperMock
58
            ->expects($this->any())
59
            ->method('isResource')
60
            ->willReturn(true)
61
        ;
62
63
        $socketHelperMock
64
            ->expects($this->any())
65
            ->method('getResponseCode')
66
            ->willReturnOnConsecutiveCalls(220, 250, 250, 550)
67
        ;
68
69
        $validation = new MailboxCheckValidation($socketHelperMock, '[email protected]');
70
        $validation->isValid('[email protected]', new EmailLexer());
71
        $this->assertEquals(new IllegalMailbox(550), $validation->getError());
72
    }
73
}
74