Passed
Push — master ( ba5f73...696202 )
by Marco
37s
created

LocateDefinedSymbolsFromExtensionsTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 23
dl 0
loc 64
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testSymbolsContainClasses() 0 4 1
A testThrowsExceptionForUnknownExtension() 0 4 1
A testSymbolsContainFunctions() 0 4 1
A setUp() 0 3 1
A testSymbolsContainConstants() 0 4 1
A testReturnsFilledArray() 0 5 1
A testCanHandleMultipleExtensions() 0 10 1
A testPackageNameInterpolation() 0 5 1
1
<?php
2
3
namespace ComposerRequireCheckerTest\DefinedSymbolsLocator;
4
5
use ComposerRequireChecker\DefinedSymbolsLocator\LocateDefinedSymbolsFromExtensions;
6
use PHPUnit\Framework\TestCase;
7
8
class LocateDefinedSymbolsFromExtensionsTest extends TestCase
9
{
10
11
    /**
12
     * @var LocateDefinedSymbolsFromExtensions
13
     */
14
    private $locator;
15
16
    /**
17
     * {@inheritDoc}
18
     */
19
    protected function setUp()
20
    {
21
        $this->locator = new LocateDefinedSymbolsFromExtensions();
22
    }
23
24
    public function testThrowsExceptionForUnknownExtension()
25
    {
26
        $this->expectException('ComposerRequireChecker\Exception\UnknownExtensionException');
27
        $this->locator->__invoke(['unknown_extension_name']);
28
    }
29
30
    public function testReturnsFilledArray()
31
    {
32
        $symbols = $this->locator->__invoke(['Core']);
33
        $this->assertGreaterThan(1, count($symbols));
34
        $this->assertInternalType('array', $symbols);
35
    }
36
37
    public function testSymbolsContainConstants()
38
    {
39
        $symbols = $this->locator->__invoke(['Core']);
40
        $this->assertTrue(in_array('PHP_VERSION', $symbols));
41
    }
42
43
    public function testSymbolsContainFunctions()
44
    {
45
        $symbols = $this->locator->__invoke(['Core']);
46
        $this->assertTrue(in_array('strlen', $symbols));
47
    }
48
49
    public function testSymbolsContainClasses()
50
    {
51
        $symbols = $this->locator->__invoke(['Core']);
52
        $this->assertTrue(in_array('stdClass', $symbols));
53
    }
54
55
    public function testPackageNameInterpolation()
56
    {
57
        $symbols = $this->locator->__invoke(['zend-opcache']);
58
        $symbols2 = $this->locator->__invoke(['Zend Opcache']);
59
        $this->assertEquals($symbols, $symbols2);
60
    }
61
62
    public function testCanHandleMultipleExtensions()
63
    {
64
        $coreSymbols = $this->locator->__invoke(['Core']);
65
        $standardSymbols = $this->locator->__invoke(['standard']);
66
67
        $this->assertGreaterThan(1, count($coreSymbols));
68
        $this->assertGreaterThan(1, count($standardSymbols));
69
70
        $combinedSymbols = $this->locator->__invoke(['Core', 'standard']);
71
        $this->assertSame(array_merge($coreSymbols, $standardSymbols), $combinedSymbols);
72
    }
73
}
74