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.
Completed
Push — master ( 48aa34...e9e817 )
by Mario
29:19 queued 01:50
created

EmailActionTest::testAct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Action;
4
5
use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
6
use Netgen\Bundle\EzFormsBundle\Form\Payload\InformationCollectionStruct;
7
use Netgen\Bundle\InformationCollectionBundle\Action\EmailAction;
8
use Netgen\Bundle\InformationCollectionBundle\Event\InformationCollected;
9
use Netgen\Bundle\InformationCollectionBundle\Exception\EmailNotSentException;
10
use Netgen\Bundle\InformationCollectionBundle\Factory\EmailDataFactory;
11
use Netgen\Bundle\InformationCollectionBundle\Mailer\MailerInterface;
12
use Netgen\Bundle\InformationCollectionBundle\Value\EmailData;
13
use PHPUnit\Framework\TestCase;
14
15
class EmailActionTest extends TestCase
16
{
17
    /**
18
     * @var EmailAction
19
     */
20
    protected $action;
21
22
    /**
23
     * @var \PHPUnit_Framework_MockObject_MockObject
24
     */
25
    protected $factory;
26
27
    /**
28
     * @var \PHPUnit_Framework_MockObject_MockObject
29
     */
30
    protected $mailer;
31
32
    /**
33
     * @var \PHPUnit_Framework_MockObject_MockObject
34
     */
35
    protected $emailData;
36
37
    public function setUp()
38
    {
39
        $this->factory = $this->getMockBuilder(EmailDataFactory::class)
40
            ->disableOriginalConstructor()
41
            ->setMethods(array('build'))
42
            ->getMock();
43
44
        $this->mailer = $this->getMockBuilder(MailerInterface::class)
45
            ->disableOriginalConstructor()
46
            ->setMethods(array('createAndSendMessage'))
47
            ->getMock();
48
49
        $this->emailData = $this->getMockBuilder(EmailData::class)
50
            ->disableOriginalConstructor()
51
            ->setMethods(array('getSubject', 'getRecipient', 'getSender', 'getBody'))
52
            ->getMock();
53
54
        $this->action = new EmailAction($this->factory, $this->mailer);
55
        parent::setUp();
56
    }
57
58
    public function testAct()
59
    {
60
        $informationCollectionStruct = new InformationCollectionStruct();
61
        $dataWrapper = new DataWrapper($informationCollectionStruct, null, null);
62
        $event = new InformationCollected($dataWrapper);
63
64
        $this->factory->expects($this->once())
65
            ->method('build')
66
            ->with($event)
67
            ->willReturn($this->emailData);
68
69
        $this->mailer->expects($this->once())
70
            ->method('createAndSendMessage')
71
            ->with($this->emailData);
72
73
        $this->action->act($event);
74
    }
75
76
    /**
77
     * @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\ActionFailedException
78
     * @expectedExceptionMessage Error occurred while trying to send email: [email protected] failed with error invalid email address
79
     */
80
    public function testActWithException()
81
    {
82
        $informationCollectionStruct = new InformationCollectionStruct();
83
        $dataWrapper = new DataWrapper($informationCollectionStruct, null, null);
84
        $event = new InformationCollected($dataWrapper);
85
86
        $this->factory->expects($this->once())
87
            ->method('build')
88
            ->with($event)
89
            ->willReturn($this->emailData);
90
91
        $exception = new EmailNotSentException('[email protected]', 'invalid email address');
92
93
        $this->mailer->expects($this->once())
94
            ->method('createAndSendMessage')
95
            ->with($this->emailData)
96
            ->willThrowException($exception);
97
98
        $this->action->act($event);
99
    }
100
}
101