0e3f2055d2
Composer's autoloader is rather better than the OwnCloud autoloader's handling of non-OC classes. Plus we can rely on upstream Composer to maintain it and not worry about it ourselves. With this change, we drop the bits of OwnCloud's autoloader that handled non-OC classes, and register the classes that were being handled by that code with Composer's autoloader instead. As these dependencies are converted to actually being managed by Composer, the explicit registrations can be dropped as they won't be needed any more. Since OwnCloud's autoloader isn't going to handle non-OC classes any more, we no longer need to test to make sure it does it right. drop unneeded registerPrefix() and registerClass() from autoloader Now we're not handling anything but OC's own classes, these are unnecessary. error out if composer autoloader is not found (thanks bantu) We're never going to be able to work without the autoloader, if it's not there we should just throw our hands up and surrender.
59 lines
1.9 KiB
PHP
59 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Copyright (c) 2013 Thomas Müller <thomas.mueller@tmit.eu>
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
* later.
|
|
* See the COPYING-README file.
|
|
*/
|
|
|
|
namespace Test;
|
|
|
|
class AutoLoader extends \PHPUnit_Framework_TestCase {
|
|
/**
|
|
* @var \OC\Autoloader $loader
|
|
*/
|
|
private $loader;
|
|
|
|
public function setUp() {
|
|
$this->loader = new \OC\AutoLoader();
|
|
}
|
|
|
|
public function testLeadingSlashOnClassName() {
|
|
$this->assertEquals(array('private/files/storage/local.php', 'files/storage/local.php'), $this->loader->findClass('\OC\Files\Storage\Local'));
|
|
}
|
|
|
|
public function testNoLeadingSlashOnClassName() {
|
|
$this->assertEquals(array('private/files/storage/local.php', 'files/storage/local.php'), $this->loader->findClass('OC\Files\Storage\Local'));
|
|
}
|
|
|
|
public function testLegacyPath() {
|
|
$this->assertEquals(array('private/legacy/files.php', 'private/files.php'), $this->loader->findClass('OC_Files'));
|
|
}
|
|
|
|
public function testLoadTestNamespace() {
|
|
$this->assertEquals(array('tests/lib/foo/bar.php'), $this->loader->findClass('Test\Foo\Bar'));
|
|
}
|
|
|
|
public function testLoadTest() {
|
|
$this->assertEquals(array('tests/lib/foo/bar.php'), $this->loader->findClass('Test_Foo_Bar'));
|
|
}
|
|
|
|
public function testLoadCoreNamespace() {
|
|
$this->assertEquals(array('private/foo/bar.php', 'foo/bar.php'), $this->loader->findClass('OC\Foo\Bar'));
|
|
}
|
|
|
|
public function testLoadCore() {
|
|
$this->assertEquals(array('private/legacy/foo/bar.php', 'private/foo/bar.php'), $this->loader->findClass('OC_Foo_Bar'));
|
|
}
|
|
|
|
public function testLoadPublicNamespace() {
|
|
$this->assertEquals(array('public/foo/bar.php'), $this->loader->findClass('OCP\Foo\Bar'));
|
|
}
|
|
|
|
public function testLoadAppNamespace() {
|
|
$result = $this->loader->findClass('OCA\Files\Foobar');
|
|
$this->assertEquals(2, count($result));
|
|
$this->assertStringEndsWith('apps/files/foobar.php', $result[0]);
|
|
$this->assertStringEndsWith('apps/files/lib/foobar.php', $result[1]);
|
|
}
|
|
}
|