added basic autoloader tests.
This commit is contained in:
parent
9de8e0050c
commit
319964fce2
|
@ -190,7 +190,7 @@ protected static function remember($id)
|
||||||
|
|
||||||
// This method assumes the "remember me" cookie should have the same
|
// This method assumes the "remember me" cookie should have the same
|
||||||
// configuration as the session cookie. Since this cookie, like the
|
// configuration as the session cookie. Since this cookie, like the
|
||||||
// session cookie, should be kept very secure, it's probably safe
|
// session cookie, should be kept very secure, it's probably safe.
|
||||||
// to assume the cookie settings are the same.
|
// to assume the cookie settings are the same.
|
||||||
$config = Config::get('session');
|
$config = Config::get('session');
|
||||||
|
|
||||||
|
|
|
@ -27,4 +27,9 @@
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Bootstrap the Laravel core.
|
// Bootstrap the Laravel core.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
require SYS_PATH.'core.php';
|
require SYS_PATH.'core.php';
|
||||||
|
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// Start the default bundle.
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
Bundle::start(DEFAULT_BUNDLE);
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class AutoloaderTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the Autoloader::map method.
|
||||||
|
*
|
||||||
|
* @group laravel
|
||||||
|
*/
|
||||||
|
public function testMapsCanBeRegistered()
|
||||||
|
{
|
||||||
|
Autoloader::map(array(
|
||||||
|
'Foo' => APP_PATH.'models/foo.php',
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertEquals(APP_PATH.'models/foo.php', Autoloader::$mappings['Foo']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the Autoloader::alias method.
|
||||||
|
*
|
||||||
|
* @group laravel
|
||||||
|
*/
|
||||||
|
public function testAliasesCanBeRegistered()
|
||||||
|
{
|
||||||
|
Autoloader::alias('Foo\\Bar', 'Foo');
|
||||||
|
|
||||||
|
$this->assertEquals('Foo\\Bar', Autoloader::$aliases['Foo']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the Autoloader::psr method.
|
||||||
|
*
|
||||||
|
* @group laravel
|
||||||
|
*/
|
||||||
|
public function testPsrDirectoriesCanBeRegistered()
|
||||||
|
{
|
||||||
|
Autoloader::psr(array(
|
||||||
|
APP_PATH.'foo'.DS.'bar',
|
||||||
|
APP_PATH.'foo'.DS.'baz'.DS.DS,
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertTrue(in_array(APP_PATH.'foo'.DS.'bar'.DS, Autoloader::$psr));
|
||||||
|
$this->assertTrue(in_array(APP_PATH.'foo'.DS.'baz'.DS, Autoloader::$psr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the Autoloader::namespaces method.
|
||||||
|
*
|
||||||
|
* @group laravel
|
||||||
|
*/
|
||||||
|
public function testNamespacesCanBeRegistered()
|
||||||
|
{
|
||||||
|
Autoloader::namespaces(array(
|
||||||
|
'Autoloader_1' => BUNDLE_PATH.'autoload'.DS.'models',
|
||||||
|
'Autoloader_2' => BUNDLE_PATH.'autoload'.DS.'libraries'.DS.DS,
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertEquals(BUNDLE_PATH.'autoload'.DS.'models'.DS, Autoloader::$namespaces['Autoloader_1']);
|
||||||
|
$this->assertEquals(BUNDLE_PATH.'autoload'.DS.'libraries'.DS, Autoloader::$namespaces['Autoloader_2']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the loading of PSR-0 models and libraries.
|
||||||
|
*
|
||||||
|
* @group laravel
|
||||||
|
*/
|
||||||
|
public function testPsrLibrariesAndModelsCanBeLoaded()
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf('User', new User);
|
||||||
|
$this->assertInstanceOf('Repositories\\User', new Repositories\User);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php namespace Repositories;
|
||||||
|
|
||||||
|
class User {}
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class User {}
|
Loading…
Reference in New Issue