testDoesNotSuggestAnything()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
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
        $this->guesser = new DependencyGuesser();
20
    }
21
22
    public function testGuessExtJson(): void
23
    {
24
        if (!extension_loaded('json')) {
25
            $this->markTestSkipped('extension json is not available');
26
        }
27
        $result = $this->guesser->__invoke('json_decode');
28
        $this->assertNotEmpty($result);
29
        $this->assertContains('ext-json', $result);
30
    }
31
32
    public function testDoesNotSuggestAnything(): void
33
    {
34
        $result = $this->guesser->__invoke('an_hopefully_unique_unknown_symbol');
35
        $this->assertFalse($result->valid());
36
    }
37
38
    public function testCoreExtensionsResolvesToPHP(): void
39
    {
40
        $options = new Options(['php-core-extensions' => ['SPL', 'something-else']]);
41
        $this->guesser = new DependencyGuesser($options);
42
        $result = $this->guesser->__invoke('RecursiveDirectoryIterator');
43
        $this->assertNotEmpty($result);
44
        $this->assertContains('php', $result);
45
    }
46
}
47