Esempio n. 1
0
 /**
  * initialise
  *
  * @return  void
  */
 public function initialise()
 {
     // A workaround before Windwalker Loader fix bug
     class_alias('Windwalker\\Loader\\Loader\\VasemanPsr4Loader', 'Windwalker\\Loader\\Loader\\Psr4Loader');
     $loader = new ClassLoader();
     $loader->register();
     $config = Ioc::getConfig();
     if ($config->get('outer_project') || $config->get('mode') == 'test') {
         $loader->addPsr4('Vaseman\\', $config->get('project.path.data') . '/src');
     }
     parent::initialise();
     GlobalContainer::addExtension('vaseman', new VasemanTwigExtension());
 }
Esempio n. 2
0
 /**
  * Method to test addPsr4().
  *
  * @return void
  *
  * @covers Windwalker\Loader\ClassLoader::addPsr4
  */
 public function testAddPsr4()
 {
     /** @var MockPsr4Loader $psr4 */
     $psr4 = $this->instance->getPsr4Loader();
     // Test 1 prefix
     $this->instance->addPsr4('Psr4', __DIR__ . '/fixtures');
     $psr4->loadClass('Psr4\\Rose\\Love');
     $this->assertFileEquals(__DIR__ . '/fixtures/Rose/Love.php', $psr4->getLastRequired());
     $psr4 = $this->instance->unregister()->setPsr4Loader(new MockPsr4Loader())->register()->getPsr4Loader();
     // Test 2 prefix
     $this->instance->addPsr4('Psr4\\Rose', __DIR__ . '/fixtures/Rose');
     $psr4->loadClass('Psr4\\Rose\\Love');
     $this->assertFileEquals(__DIR__ . '/fixtures/Rose/Love.php', $psr4->getLastRequired());
     // Test as Psr0 prefix
     $this->instance->addPsr4('Psr0', __DIR__ . '/fixtures/Psr0');
     $psr4->loadClass('Psr0\\Flower\\Sakura');
     $this->assertFileEquals(__DIR__ . '/fixtures/Psr0/Flower/Sakura.php', $psr4->getLastRequired());
 }