function testSharedInstance() { $this->loader->register('d', 'User'); $user1 = $this->loader->load('d'); $user2 = $this->loader->load('d'); $user3 = $this->loader->load('d', false); $this->assertTrue($user1 === $user2); $this->assertTrue($user1 !== $user3); }
function testRegisterUsingCallback() { $this->loader->register('f', function () { return Factory::create(); }); $obj = $this->loader->load('f'); $this->assertTrue(is_object($obj)); $this->assertEquals('Factory', get_class($obj)); }
<?php /** * Flight: An extensible micro-framework. * * @copyright Copyright (c) 2013, Mike Cao <*****@*****.**> * @license MIT, http://flightphp.com/license */ require_once __DIR__ . '/core/Loader.php'; \flight\core\Loader::autoload(true, dirname(__DIR__));