Failed Conditions
Pull Request — master (#103)
by Matthias
04:28
created

testCoreExtensionsResolvesToPHP()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ComposerRequireCheckerTest\DependencyGuesser;
4
5
use ComposerRequireChecker\DependencyGuesser\DependencyGuesser;
6
use PHPUnit\Framework\TestCase;
7
8
class DependencyGuesserTest extends TestCase
9
{
10
11
    /**
12
     * @var DependencyGuesser
13
     */
14
    private $guesser;
15
16
    public function setUp()
17
    {
18
        $this->guesser = new DependencyGuesser(null);
19
    }
20
21
    public function testGuessExtJson()
22
    {
23
        if (!extension_loaded('json')) {
24
            $this->markTestSkipped('extension json is not available');
25
        }
26
        $result = $this->guesser->__invoke('json_decode');
27
        $this->assertNotEmpty($result);
28
        $this->assertContains('ext-json', $result);
29
    }
30
31
    public function testDoesNotSuggestAnything()
32
    {
33
        $result = $this->guesser->__invoke('an_hopefully_unique_unknown_symbol');
34
        $this->assertFalse($result->valid());
35
    }
36
37
    public function testCoreExtensionsResolvesToPHP()
38
    {
39
        $this->guesser = new DependencyGuesser(['php_core_extensions' => ['SPL']]);
40
        $result = $this->guesser->__invoke('RecursiveDirectoryIterator');
41
        $this->assertNotEmpty($result);
42
        $this->assertContains('php', $result);
43
    }
44
}
45