Completed
Push — stable8.2 ( 3ce7e4...72226d )
by
unknown
27s
created

AutoLoader::testLoadCoreNamespaceCore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright (c) 2013 Thomas Müller <[email protected]>
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later.
6
 * See the COPYING-README file.
7
 */
8
9
namespace Test;
10
11
class AutoLoader extends TestCase {
12
	/**
13
	 * @var \OC\Autoloader $loader
14
	 */
15
	private $loader;
16
17
	protected function setUp() {
18
		parent::setUp();
19
		$this->loader = new \OC\AutoLoader([]);
20
	}
21
22
	public function testLeadingSlashOnClassName() {
23
		$this->assertEquals([
24
			\OC::$SERVERROOT . '/lib/private/files/storage/local.php',
25
		], $this->loader->findClass('\OC\Files\Storage\Local'));
26
	}
27
28
	public function testNoLeadingSlashOnClassName() {
29
		$this->assertEquals([
30
			\OC::$SERVERROOT . '/lib/private/files/storage/local.php', 
31
		], $this->loader->findClass('OC\Files\Storage\Local'));
32
	}
33
34
	public function testLegacyPath() {
35
		$this->assertEquals([
36
			\OC::$SERVERROOT . '/lib/private/legacy/files.php', 
37
			\OC::$SERVERROOT . '/lib/private/files.php',
38
		], $this->loader->findClass('OC_Files'));
39
	}
40
41
	public function testLoadTestNamespace() {
42
		$this->assertEquals([
43
			\OC::$SERVERROOT . '/tests/lib/foo/bar.php'
44
		], $this->loader->findClass('Test\Foo\Bar'));
45
	}
46
47
	public function testLoadTest() {
48
		$this->assertEquals([
49
			\OC::$SERVERROOT . '/tests/lib/foo/bar.php'
50
		], $this->loader->findClass('Test_Foo_Bar'));
51
	}
52
53
	public function testLoadCoreNamespace() {
54
		$this->assertEquals([
55
			\OC::$SERVERROOT . '/lib/private/foo/bar.php', 
56
		], $this->loader->findClass('OC\Foo\Bar'));
57
	}
58
59
	public function testLoadCore() {
60
		$this->assertEquals([
61
			\OC::$SERVERROOT . '/lib/private/legacy/foo/bar.php', 
62
			\OC::$SERVERROOT . '/lib/private/foo/bar.php',
63
		], $this->loader->findClass('OC_Foo_Bar'));
64
	}
65
66
	public function testLoadPublicNamespace() {
67
		$this->assertEquals([
68
			\OC::$SERVERROOT . '/lib/public/foo/bar.php',
69
		], $this->loader->findClass('OCP\Foo\Bar'));
70
	}
71
72
	public function testLoadAppNamespace() {
73
		$result = $this->loader->findClass('OCA\Files\Foobar');
74
		$this->assertEquals(2, count($result));
75
		$this->assertStringEndsWith('apps/files/foobar.php', $result[0]);
76
		$this->assertStringEndsWith('apps/files/lib/foobar.php', $result[1]);
77
	}
78
79
	public function testLoadCoreNamespaceCore() {
80
		$this->assertEquals([
81
			\OC::$SERVERROOT . '/core/foo/bar.php', 
82
		], $this->loader->findClass('OC\Core\Foo\Bar'));
83
	}
84
85
	public function testLoadCoreNamespaceSettings() {
86
		$this->assertEquals([
87
			\OC::$SERVERROOT . '/settings/foo/bar.php', 
88
		], $this->loader->findClass('OC\Settings\Foo\Bar'));
89
	}
90
91
	public function testLoadCoreNamespaceRepair() {
92
		$this->assertEquals([
93
			\OC::$SERVERROOT . '/lib/repair/foo/bar.php', 
94
		], $this->loader->findClass('OC\Repair\Foo\Bar'));
95
	}
96
}
97