forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSupportClassLoaderTest.php
More file actions
executable file
·50 lines (40 loc) · 1.75 KB
/
SupportClassLoaderTest.php
File metadata and controls
executable file
·50 lines (40 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
use Mockery as m;
use Illuminate\Support\ClassLoader;
class SupportClassLoaderTest extends PHPUnit_Framework_TestCase {
public function testNormalizingClass()
{
$php53Class = 'Foo\Bar\Baz\Bat';
$prefixed53Class = '\Foo\Bar\Baz\Bat';
$php52Class = 'Foo_Bar_Baz_Bat';
$expected = 'Foo'.DIRECTORY_SEPARATOR.'Bar'.DIRECTORY_SEPARATOR.'Baz'.DIRECTORY_SEPARATOR.'Bat.php';
$this->assertEquals($expected, ClassLoader::normalizeClass($php53Class));
$this->assertEquals($expected, ClassLoader::normalizeClass($prefixed53Class));
$this->assertEquals($expected, ClassLoader::normalizeClass($php52Class));
}
public function testManipulatingDirectories()
{
ClassLoader::removeDirectories();
$this->assertEmpty(ClassLoader::getDirectories());
ClassLoader::addDirectories($directories = array('foo', 'bar'));
$this->assertEquals($directories, ClassLoader::getDirectories());
ClassLoader::addDirectories('baz');
$this->assertEquals(array_merge($directories, array('baz')), ClassLoader::getDirectories());
ClassLoader::removeDirectories('baz');
$this->assertEquals($directories, ClassLoader::getDirectories());
ClassLoader::addDirectories($directories = array('foo', 'bar', 'baz'));
ClassLoader::removeDirectories(array('bar', 'baz'));
$this->assertEquals(array('foo'), ClassLoader::getDirectories());
ClassLoader::removeDirectories($directories);
$this->assertEmpty(ClassLoader::getDirectories());
}
public function testClassLoadingWorks()
{
$php53Class = 'Foo\Bar\Php53';
$php52Class = 'Foo_Bar_Php52';
ClassLoader::addDirectories($directory = __DIR__.'/stubs/psr');
$this->assertTrue(ClassLoader::load($php53Class));
$this->assertTrue(ClassLoader::load($php52Class));
ClassLoader::removeDirectories($directory);
}
}