Failed Conditions
Push — master ( b9670c...4ba57f )
by Zac
16:20 queued 37s
created

ResultReporterManagerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 55
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 18 1
A testAdd() 0 13 1
A testNotifyLogsExceptions() 0 13 1
1
<?php
2
3
namespace Overwatch\ResultBundle\Tests\Reporter;
4
5
use Overwatch\ResultBundle\Entity\TestResult;
6
use Overwatch\ResultBundle\Reporter\ResultReporterManager;
7
8
/**
9
 * ResultReporterManagerTest
10
 * Unit test of ResultReporterManager
11
 */
12
class ResultReporterManagerTest extends \PHPUnit_Framework_TestCase
13
{
14
    protected $rrm;
15
16
    protected $loggerSpy;
17
18
    protected $emailReporterMock;
19
20
    public function setUp()
21
    {
22
        $loggerMock = $this->getMockBuilder('Symfony\Bridge\Monolog\Logger')
23
            ->disableOriginalConstructor()
24
            ->getMock();
25
26
        $loggerMock
27
            ->expects($this->loggerSpy = $this->any())
28
            ->method('error')
29
            ->willReturn(null)
30
        ;
31
32
        $this->emailReporterMock = $this->getMockBuilder('Overwatch\ServiceBundle\Reporter\EmailReporter')
33
            ->disableOriginalConstructor()
34
            ->getMock();
35
36
        $this->rrm = new ResultReporterManager($loggerMock);
37
    }
38
39
    public function testAdd()
40
    {
41
        $this->emailReporterMock
42
            ->expects($notifySpy = $this->any())
43
            ->method('notify')
44
            ->willReturn(null)
45
        ;
46
47
        $this->rrm->add($this->emailReporterMock);
48
        $this->rrm->notifyAll(new TestResult);
49
50
        $this->assertCount(1, $notifySpy->getInvocations());
51
    }
52
53
    public function testNotifyLogsExceptions()
54
    {
55
        $this->emailReporterMock
56
            ->expects($this->any())
57
            ->method('notify')
58
            ->willThrowException(new \Exception('Beard error #4'))
59
        ;
60
61
        $this->rrm->add($this->emailReporterMock);
62
        $this->rrm->notifyAll(new TestResult);
63
64
        $this->assertCount(1, $this->loggerSpy->getInvocations());
65
    }
66
}
67