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