Completed
Branch guard_coverage (f2aaf0)
by Pablo
03:07
created

GitIgnoreExtractorQueryHandlerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A itShouldReturnNotNull() 0 20 1
1
<?php
2
3
namespace PhpGitHooks\Module\Git\Tests\Behaviour;
4
5
use PhpGitHooks\Module\Git\Contract\Query\GitIgnoreExtractorQuery;
6
use PhpGitHooks\Module\Git\Contract\QueryHandler\GitIgnoreExtractorQueryHandler;
7
use PhpGitHooks\Module\Git\Contract\Response\GitIgnoreDataResponse;
8
use PhpGitHooks\Module\Git\Service\GitIgnoreExtractor;
9
use PhpGitHooks\Module\Git\Tests\Infrastructure\GitUnitTestCase;
10
11
class GitIgnoreExtractorQueryHandlerTest extends GitUnitTestCase
12
{
13
    /**
14
     * @var GitIgnoreExtractorQueryHandler
15
     */
16
    private $gitIgnoreExtractorQueryHandler;
17
18
    protected function setUp()
19
    {
20
        $this->gitIgnoreExtractorQueryHandler = new GitIgnoreExtractorQueryHandler(
21
            new GitIgnoreExtractor($this->getGitIgnoreFileReader())
0 ignored issues
show
Bug introduced by
It seems like $this->getGitIgnoreFileReader() targeting PhpGitHooks\Module\Git\T...etGitIgnoreFileReader() can also be of type object<Mockery\MockInterface>; however, PhpGitHooks\Module\Git\S...xtractor::__construct() does only seem to accept object<PhpGitHooks\Modul...\Model\ReaderInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
22
        );
23
    }
24
25
    /**
26
     * @test
27
     */
28
    public function itShouldReturnNotNull()
29
    {
30
        $content = 'composer.phar
31
        vendor/
32
        bin/
33
        php-git-hooks.yml
34
        # Commit your application\'s lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
35
        # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
36
        # composer.lock
37
        ';
38
39
        $this->shouldReadGitIgnoreFile($content);
40
41
        $query = new GitIgnoreExtractorQuery();
42
43
        $data = $this->gitIgnoreExtractorQueryHandler->handle($query);
44
45
        $this->assertInstanceOf(GitIgnoreDataResponse::class, $data);
46
        $this->assertNotNull($data->getContent());
47
    }
48
}
49