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

testSymbolAutoloadedByComposerResolvesToPackageName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
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