addClassLoader() public method

Injects an additional class loader.
public addClassLoader ( AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface $classLoader, AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface $configuration ) : void
$classLoader AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface A class loader to put on the class loader stack
$configuration AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface The class loader's configuration
return void
Exemplo n.º 1
0
 /**
  * Test if the class loaders has been registered successfully.
  *
  * @return void
  */
 public function testRegisterClassLoaders()
 {
     // initialize the mock logger
     $mockLogger = $this->getMock('Psr\\Log\\LoggerInterface', array('log', 'error', 'warning', 'notice', 'emergency', 'debug', 'info', 'alert', 'critical'));
     // create a mock instance
     $classToMock = 'AppserverIo\\Appserver\\Application\\Interfaces\\ContextInterface';
     $mockInitialContext = $this->getMock($classToMock, get_class_methods($classToMock));
     $mockInitialContext->expects($this->any())->method('getSystemLogger')->will($this->returnValue($mockLogger));
     // inject the mock initial context instance
     $this->application->injectInitialContext($mockInitialContext);
     // create a mock loader configuration
     $classToMock = 'AppserverIo\\Appserver\\Core\\Api\\Node\\ClassLoaderNodeInterface';
     $mockLoaderConfiguration = $this->getMock($classToMock, get_class_methods($classToMock));
     $mockLoaderConfiguration->expects($this->any())->method('getName')->will($this->returnValue('MockLoader'));
     // register the mock class loader instance
     $this->application->addClassLoader($mockClassLoader = new MockClassLoader(), $mockLoaderConfiguration);
     $this->application->registerClassLoaders();
     // check that the mock class loader has been registered
     $this->assertTrue($mockClassLoader->isRegistered());
 }