Passed
Push — main ( f0911f...cd99fe )
by Sebastian
05:24
created

AskConfirmationTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testExecute() 0 14 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\Hook\UserInput;
13
14
use CaptainHook\App\Config\Mockery as ConfigMockery;
15
use CaptainHook\App\Config\Options;
16
use CaptainHook\App\Console\IO\NullIO;
17
use CaptainHook\App\Hook\Message\Action\CacheOnFail;
18
use CaptainHook\App\Hook\Message\EventHandler\WriteCacheFile;
19
use CaptainHook\App\Mockery as CHMockery;
20
use Exception;
21
use PHPUnit\Framework\TestCase;
22
23
class AskConfirmationTest extends TestCase
24
{
25
    use ConfigMockery;
26
    use CHMockery;
27
28
    /**
29
     * Tests CacheOnFail::getEventHandlers
30
     */
31
    public function testExecute(): void
32
    {
33
        $io     = new NullIO();
34
        $config = $this->createConfigMock();
35
        $action = $this->createActionConfigMock();
36
        $action->method('getOptions')->willReturn(new Options(['message' => 'what?']));
37
        $repo   = $this->createRepositoryMock();
38
39
        $exe = new AskConfirmation();
40
        $exe->execute($config, $io, $repo, $action);
41
42
        $handlers = AskConfirmation::getEventHandlers($action);
43
        $this->assertFalse(empty($handlers));
44
        $this->assertInstanceOf(EventHandler\AskConfirmation::class, $handlers['onHookSuccess'][0]);
45
    }
46
}
47