GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SwiftMailerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 58
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
B testSendingMailWorks() 0 38 1
1
<?php
2
3
namespace Hautzi\SystemMailBundle\Tests\SystemMailer\Mailer;
4
5
use Hautzi\SystemMailBundle\SystemMailer\Mailer\SwiftMailer;
6
use Hautzi\SystemMailBundle\SystemMailer\ParsedMessage;
7
use Prophecy\Argument;
8
9
class SwiftMailerTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var SwiftMailer
13
     */
14
    protected $fixture;
15
16
    /**
17
     * @var \Twig_Environment
18
     */
19
    protected $mailer;
20
21
    protected function setUp()
22
    {
23
        $this->mailer = $this->prophesize(\Swift_Mailer::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->prophesize(\Swift_Mailer::class) of type object<Prophecy\Prophecy\ObjectProphecy> is incompatible with the declared type object<Twig_Environment> of property $mailer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24
25
        $this->fixture = new SwiftMailer($this->mailer->reveal());
26
    }
27
28
    public function testSendingMailWorks()
29
    {
30
        $message = new ParsedMessage();
31
        $message->setFrom('[email protected]', 'from');
32
        $message->setReplyTo('[email protected]');
33
        $message->addTo('[email protected]', 'to1');
34
        $message->addTo('[email protected]', 'to2');
35
        $message->addCc('[email protected]', 'cc1');
36
        $message->addCc('[email protected]', 'cc2');
37
        $message->addBcc('[email protected]', 'bcc1');
38
        $message->addBcc('[email protected]', 'bcc2');
39
        $message->setSubject('_subject');
40
        $message->setMessageText('_text_message');
41
        $message->setMessageHtml('_html_message');
42
43
        $this->mailer->send(Argument::type(\Swift_Message::class))->shouldBeCalled();
44
45
        $closureExceuted = false;
46
        $this->fixture->send($message, function (\Swift_Message $message) use (&$closureExceuted) {
47
            // from
48
            $this->assertEquals(['[email protected]' => 'from'], $message->getFrom());
49
            // reply-to
50
            $this->assertEquals(['[email protected]' => null], $message->getReplyTo());
51
            // to
52
            $this->assertEquals(['[email protected]' => 'to1', '[email protected]' => 'to2'], $message->getTo());
53
            // cc
54
            $this->assertEquals(['[email protected]' => 'cc1', '[email protected]' => 'cc2'], $message->getCc());
55
            // bcc
56
            $this->assertEquals(['[email protected]' => 'bcc1', '[email protected]' => 'bcc2'], $message->getBcc());
57
58
            $this->assertEquals('_subject', $message->getSubject());
59
            $this->assertEquals('_text_message', $message->getBody());
60
61
            $closureExceuted = true;
62
        });
63
64
        $this->assertTrue($closureExceuted, 'closure was not executed.');
65
    }
66
}
67