Test Failed
Push — master ( 2920f5...ecce63 )
by James
01:32
created

EventSubjectTest::testGetEnvPushEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 24
rs 9.7
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Tests\Service;
4
5
use Exception;
6
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Psr\Log\LoggerInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Log\LoggerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use App\Service\EventSubject;
9
use App\Service\EventObserver;
10
11
final class EventSubjectTest extends TestCase
12
{
13
    /**
14
     * @var \App\Service\EventSubject
15
     */
16
    private $subject;
17
18
    protected function setUp(): void
19
    {
20
        $this->subject = new EventSubject;
21
    }
22
23
    public function testNotifySuccess()
24
    {
25
        // Arrange
26
        $observer = $this->createMock(EventObserver::class);
27
        // Assert
28
        $observer->expects($this->once())->method('update');
29
        // Act
30
        $this->subject->attach($observer);
31
        $this->subject->notify();
32
    }
33
34
    public function testNotifyFailed()
35
    {
36
        // Arrange
37
        $observer = $this->createMock(EventObserver::class);
38
        $logger = $this->createMock(LoggerInterface::class);
39
        // Assert
40
        $observer->expects($this->once())->method('update')->will($this->throwException(new Exception));
41
        $logger->expects($this->once())->method('error');
42
        // Act
43
        $this->subject->setLogger($logger);
44
        $this->subject->attach($observer);
45
        $this->subject->notify();
46
    }
47
48
    public function testNotifyNever()
49
    {
50
        // Arrange
51
        $observer = $this->createMock(EventObserver::class);
52
        // Assert
53
        $observer->expects($this->never())->method('update');
54
        // Act
55
        $this->subject->attach($observer);
56
        $this->subject->detach($observer);
57
        $this->subject->notify();
58
    }
59
60
    public function testGetEnvOtherEvent()
61
    {
62
        // Arrange
63
        $this->subject->exchangeArray(['object_kind' => 'tag_push']);
64
        // Act
65
        $env = $this->subject->getEnv();
66
        // Assert
67
        $this->assertEquals([], $env);
68
    }
69
}
70