FactoryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvalidEvent() 0 10 1
A testCreateEvent() 0 10 1
1
<?php
2
3
/**
4
 * This file is part of CaptainHook.
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Event;
13
14
use Exception;
15
use PHPUnit\Framework\TestCase;
16
use CaptainHook\App\Config\Mockery as ConfigMockery;
17
use CaptainHook\App\Console\IO\Mockery as IOMockery;
18
use CaptainHook\App\Mockery as CHMockery;
19
20
class FactoryTest extends TestCase
21
{
22
    use ConfigMockery;
23
    use CHMockery;
24
    use IOMockery;
25
26
    /**
27
     * Tests HookFailed
28
     */
29
    public function testCreateEvent(): void
30
    {
31
        $io     = $this->createIOMock();
32
        $config = $this->createConfigMock();
33
        $repo   = $this->createRepositoryMock();
34
35
        $factory = new Factory($io, $config, $repo);
36
        $event   = $factory->createEvent('onHookFailure');
37
38
        $this->assertInstanceOf(HookFailed::class, $event);
39
    }
40
41
    /**
42
     * Tests HookFailed
43
     */
44
    public function testInvalidEvent(): void
45
    {
46
        $this->expectException(Exception::class);
47
48
        $io     = $this->createIOMock();
49
        $config = $this->createConfigMock();
50
        $repo   = $this->createRepositoryMock();
51
52
        $factory = new Factory($io, $config, $repo);
53
        $event   = $factory->createEvent('invalidEventName');
0 ignored issues
show
Unused Code introduced by
The assignment to $event is dead and can be removed.
Loading history...
54
    }
55
}
56