/** * @covers RecordsMan\Loader::registerClass */ public function testRegisterClass() { $loaderReflection = new \ReflectionClass($this->inst); $this->assertTrue($loaderReflection->hasProperty('_classes')); $_classes = $loaderReflection->getProperty('_classes'); $this->assertTrue($_classes->isPrivate()); $_classes->setAccessible(true); $this->assertTrue(is_array($_classes->getValue($this->inst))); $this->assertCount(0, $_classes->getValue($this->inst)); $this->inst->registerClass('\\Test\\Item'); $this->assertTrue(isset($_classes->getValue($this->inst)['\\Test\\Item']['properties'])); $this->assertEquals('\\Test\\Item', $this->inst->registerClass('\\Test\\Item')); $this->assertEquals('\\Test\\Item', $this->inst->registerClass('Test\\Item')); }
* Load application files * * @category LoveMachineLogin * @package Core * @author LoveMachine Inc. <*****@*****.**> * @license Copyright (c) 2009-2010, LoveMachine Inc. All Rights Reserved * @version SVN: $Id: loadapp.php 105 2010-10-10 21:45:37Z yani $ * @edited 26-MAY-2010 <Yani> * @link http://www.lovemachineinc.com */ if (!defined('APPLICATION_BASE')) { /** * Application base directory */ define('APPLICATION_BASE', dirname(__FILE__)); } if (!defined('APPLICATION_DIR')) { /** * Main application dir */ define('APPLICATION_DIR', dirname(__FILE__)); } // login controller Loader::registerClass('LoginController', APPLICATION_DIR . '/controller/LoginController.php'); // Love user Loader::registerClass('LoveUser', APPLICATION_DIR . '/model/LoveUser.php'); // user Loader::registerClass('User', APPLICATION_DIR . '/model/User.php'); Loader::registerClass('User_Exception', APPLICATION_DIR . '/model/User/User_Exception.php'); Loader::registerClass('User_DbException', APPLICATION_DIR . '/model/User/User_DbException.php');
* Loader */ require_once $libDir . '/Loader.php'; /** * Loader_Exception */ require_once $libDir . '/Loader/Loader_Exception.php'; // Controller Loader::registerClass('Controller', $libDir . '/Controller.php'); // Controller Action Loader::registerClass('Controller_Action', $libDir . '/Controller_Action.php'); // CURLHandler Loader::registerClass('CURLHandler', $libDir . '/CURLHandler.php'); // DataObject Loader::registerClass('DataObject', $libDir . '/DataObject.php'); // functions Loader::registerClass('Functions', $libDir . '/Functions.php'); // Request Loader::registerClass('Request', $libDir . '/Request.php'); // Response Loader::registerClass('Response', $libDir . '/Response.php'); // AppAuth Loader::registerClass('AppAuth', $libDir . '/AppAuth.php'); //Authentication_Handler Loader::registerClass('Authentication_Handler', $libDir . '/Authentication_Handler.php'); //Ldap_Authentication_Handler Loader::registerClass('Ldap_Authentication_Handler', $libDir . '/Ldap_Authentication_Handler.php'); //Db_Password_Authentication_Handler Loader::registerClass('Db_Password_Authentication_Handler', $libDir . '/Db_Password_Authentication_Handler.php'); Loader::splRegister(); unset($libDir);
/** * Try to load invalid class */ public function testLoadRegisteredClassWithWrongClassnameThrowsException() { $failureAffects = "Full login failure"; $data = $this->provideNonexistingClass(); $invalidClassname = $data[0][0]; Loader::registerClass($invalidClassname, $this->testClassFile); try { Loader::load($invalidClassname); $this->fail('Exception should have been thrown.'); } catch (Loader_Exception $e) { $this->assertContains('was not found in registered location', $e->getMessage(), $failureAffects); } }