Completed
Branch feature/add-scrutinizer (27b569)
by Matthias
02:05
created

testExtensionsAreReturned()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace ComposerRequireCheckerTest\DefinedExtensionsResolver;
4
5
use ComposerRequireChecker\DefinedExtensionsResolver\DefinedExtensionsResolver;
6
use org\bovigo\vfs\vfsStream;
7
use org\bovigo\vfs\vfsStreamDirectory;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * @covers \ComposerRequireChecker\DefinedExtensionsResolver\DefinedExtensionsResolver
12
 */
13
class DefinedExtensionsResolverTest extends TestCase
14
{
15
    /** @var DefinedExtensionsResolver */
16
    private $resolver;
17
    /** @var vfsStreamDirectory */
18
    private $root;
19
20
    protected function setUp()
21
    {
22
        parent::setUp();
23
24
        $this->resolver = new DefinedExtensionsResolver();
25
        $this->root = vfsStream::setup();
26
    }
27
28
    public function testNoExtensions()
29
    {
30
        $composerJson = vfsStream::newFile('composer.json')->at($this->root)->setContent('{}')->url();
31
32
        $extensions = ($this->resolver)($composerJson);
33
34
        $this->assertCount(0, $extensions);
35
    }
36
37 View Code Duplication
    public function testCoreExtensions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $composerJson = vfsStream::newFile('composer.json')->at($this->root)
40
            ->setContent('{"require":{"php":"^7.0"}}')
41
            ->url();
42
43
        $extensions = ($this->resolver)($composerJson, ['ext-foo' => '*']);
44
45
        $this->assertCount(1, $extensions);
46
        $this->assertSame('*', reset($extensions));
47
    }
48
49 View Code Duplication
    public function testExtensionsAreReturned()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50
    {
51
        $composerJson = vfsStream::newFile('composer.json')->at($this->root)
52
            ->setContent('{"require":{"ext-zip":"*","ext-curl":"*"}}')
53
            ->url();
54
55
        $extensions = ($this->resolver)($composerJson);
56
57
        $this->assertCount(2, $extensions);
58
        $this->assertContains('zip', $extensions);
59
        $this->assertContains('curl', $extensions);
60
    }
61
}
62