Failed Conditions
Pull Request — master (#162)
by
unknown
05:20
created

DependencyGuesserTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 6
eloc 20
c 4
b 0
f 0
dl 0
loc 47
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testSymbolAutoloadedByComposerResolvesToPackageName() 0 6 1
A testCoreExtensionsResolvesToPHP() 0 7 1
A testGuessExtJson() 0 8 2
A testDoesNotSuggestAnything() 0 4 1
1
<?php
2
3
namespace ComposerRequireCheckerTest\DependencyGuesser;
4
5
use ComposerRequireChecker\Cli\Options;
6
use ComposerRequireChecker\DependencyGuesser\DependencyGuesser;
7
use PHPUnit\Framework\TestCase;
8
9
final class DependencyGuesserTest extends TestCase
10
{
11
12
    /**
13
     * @var DependencyGuesser
14
     */
15
    private $guesser;
16
17
    protected function setUp(): void
18
    {
19
        $options = new Options([
20
            'autoloader-path' => dirname(__DIR__, 3) . '/vendor/autoload.php'
21
        ]);
22
        $this->guesser = new DependencyGuesser($options);
23
    }
24
25
    public function testGuessExtJson(): void
26
    {
27
        if (!extension_loaded('json')) {
28
            $this->markTestSkipped('extension json is not available');
29
        }
30
        $result = $this->guesser->__invoke('json_decode');
31
        $this->assertNotEmpty($result);
32
        $this->assertContains('ext-json', $result);
33
    }
34
35
    public function testDoesNotSuggestAnything(): void
36
    {
37
        $result = $this->guesser->__invoke('an_hopefully_unique_unknown_symbol');
38
        $this->assertFalse($result->valid());
39
    }
40
41
    public function testCoreExtensionsResolvesToPHP(): void
42
    {
43
        $options = new Options(['php-core-extensions' => ['SPL', 'something-else']]);
44
        $this->guesser = new DependencyGuesser($options);
45
        $result = $this->guesser->__invoke('RecursiveDirectoryIterator');
46
        $this->assertNotEmpty($result);
47
        $this->assertContains('php', $result);
48
    }
49
50
    public function testSymbolAutoloadedByComposerResolvesToPackageName(): void
51
    {
52
        $result = $this->guesser->__invoke('\PHPUnit\Framework\TestCase');
53
54
        $this->assertNotEmpty($result);
55
        $this->assertContains('phpunit/phpunit', $result);
56
    }
57
}
58