|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Tests\PHPSA; |
|
4
|
|
|
|
|
5
|
|
|
use PHPSA\AliasManager; |
|
6
|
|
|
|
|
7
|
|
|
class AliasManagerTest extends TestCase |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @covers \PHPSA\AliasManager::__construct |
|
11
|
|
|
*/ |
|
12
|
|
|
public function testConstructorWithNamespace() |
|
13
|
|
|
{ |
|
14
|
|
|
$manager = new AliasManager('\Some\Deep\Namespace'); |
|
15
|
|
|
|
|
16
|
|
|
$this->assertInstanceOf('\PHPSA\AliasManager', $manager); |
|
17
|
|
|
$this->assertEquals('\Some\Deep\Namespace', $manager->getNamespace()); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @covers \PHPSA\AliasManager::__construct |
|
22
|
|
|
*/ |
|
23
|
|
|
public function testConstructorWithoutNamespace() |
|
24
|
|
|
{ |
|
25
|
|
|
$manager = new AliasManager(); |
|
26
|
|
|
|
|
27
|
|
|
$this->assertInstanceOf('\PHPSA\AliasManager', $manager); |
|
28
|
|
|
$this->assertNull($manager->getNamespace()); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @covers \PHPSA\AliasManager::getNamespace |
|
33
|
|
|
* @covers \PHPSA\AliasManager::setNamespace |
|
34
|
|
|
* @depends testConstructorWithNamespace |
|
35
|
|
|
*/ |
|
36
|
|
|
public function testNamespaceGetterSetter() |
|
37
|
|
|
{ |
|
38
|
|
|
$manager = new AliasManager('\Some\Initial\Namespace'); |
|
39
|
|
|
|
|
40
|
|
|
$this->assertNull($manager->setNamespace('\New\GoneWithTheOld')); |
|
41
|
|
|
$this->assertEquals('\New\GoneWithTheOld', $manager->getNamespace()); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @covers \PHPSA\AliasManager::add |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testAddNamespace() |
|
48
|
|
|
{ |
|
49
|
|
|
$manager = new AliasManager(); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertNull($manager->add('WebThings')); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @covers \PHPSA\AliasManager::isClassImported |
|
56
|
|
|
* @depends testAddNamespace |
|
57
|
|
|
*/ |
|
58
|
|
|
public function testIsClassImported() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->markTestSkipped('See https://github.com/ovr/phpsa/issues/173 for bug'); |
|
61
|
|
|
|
|
62
|
|
|
$manager = new AliasManager(); |
|
63
|
|
|
|
|
64
|
|
|
$this->assertNull($manager->add('WebThings')); |
|
65
|
|
|
|
|
66
|
|
|
$this->assertTrue($manager->isClassImported('WebThings')); |
|
67
|
|
|
$this->assertFalse($manager->isClassImported('AnalogStuff')); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|