Completed
Push — master ( d068c5...99fa9d )
by Antonio
03:22 queued 58s
created

testValidationThrowsException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 15

Duplication

Lines 23
Ratio 100 %
Metric Value
dl 23
loc 23
rs 9.0857
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
namespace Da\Mailer\Test\Validator;
3
4
use Da\Mailer\Validator\SmtpCredentialsValidator;
5
use Exception;
6
use Mockery;
7
use PHPUnit_Framework_TestCase;
8
use Swift_SmtpTransport;
9
10
/**
11
 * @runTestsInSeparateProcesses
12
 * @preserveGlobalState disabled
13
 */
14
class SmtpCredentialsValidatorTest extends PHPUnit_Framework_TestCase
15
{
16 View Code Duplication
    public function testValidationPassed()
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...
17
    {
18
        $mock = Mockery::mock('overload:' . Swift_SmtpTransport::class);
19
        $mock->shouldReceive('start')->once()->andReturn(true);
20
        $mock->shouldReceive('setUsername')->once()->with('Obiwoan');
21
        $mock->shouldReceive('setPassword')->once()->with('Kenovi');
22
        $mock->shouldReceive('setEncryption')->once()->with('ssl');
23
        $mock->shouldReceive('setAuthMode')->once()->with('Plain');
24
25
        $validator = SmtpCredentialsValidator::fromArray(
26
            [
27
                'host' => 'localhost',
28
                'port' => 587,
29
                'username' => 'Obiwoan',
30
                'password' => 'Kenovi',
31
                'encryption' => 'ssl',
32
                'authMode' => 'Plain'
33
            ]
34
        );
35
36
        $this->assertTrue($validator->validate());
37
    }
38
39 View Code Duplication
    public function testValidationThrowsException()
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...
40
    {
41
        $mock = Mockery::mock('overload:' . Swift_SmtpTransport::class);
42
43
        $mock->shouldReceive('start')->once()->andThrow(Exception::class);
44
        $mock->shouldReceive('setUsername')->once()->with('Obiwoan');
45
        $mock->shouldReceive('setPassword')->once()->with('Kenovi');
46
        $mock->shouldReceive('setEncryption')->once()->with('ssl');
47
        $mock->shouldReceive('setAuthMode')->once()->with('Plain');
48
49
        $validator = SmtpCredentialsValidator::fromArray(
50
            [
51
                'host' => 'localhost',
52
                'port' => 587,
53
                'username' => 'Obiwoan',
54
                'password' => 'Kenovi',
55
                'encryption' => 'ssl',
56
                'authMode' => 'Plain'
57
            ]
58
        );
59
60
        $this->assertTrue($validator->validate() === false);
61
    }
62
}
63