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

LocateDefinedSymbolsFromExtensionsTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 60
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testThrowsExceptionForUnknownExtension() 0 5 1
A testReturnsFilledArray() 0 6 1
A testSymbolsContainConstants() 0 5 1
A testSymbolsContainFunctions() 0 5 1
A testSymbolsContainClasses() 0 5 1
A testCanHandleMultipleExtensions() 0 11 1
1
<?php
2
3
namespace ComposerRequireCheckerTest\DefinedSymbolsLocator;
4
5
6
use ComposerRequireChecker\DefinedSymbolsLocator\LocateDefinedSymbolsFromExtensions;
7
8
class LocateDefinedSymbolsFromExtensionsTest extends \PHPUnit_Framework_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->setExpectedException('ComposerRequireChecker\Exception\UnknownExtensionException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
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->assertTrue(is_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 testCanHandleMultipleExtensions()
56
    {
57
        $coreSymbols = $this->locator->__invoke(['Core']);
58
        $standardSymbols = $this->locator->__invoke(['standard']);
59
60
        $this->assertGreaterThan(1, count($coreSymbols));
61
        $this->assertGreaterThan(1, count($standardSymbols));
62
63
        $combinedSymbols = $this->locator->__invoke(['Core', 'standard']);
64
        $this->assertSame(array_merge($coreSymbols, $standardSymbols), $combinedSymbols);
65
    }
66
67
}
68