示例#1
0
 /**
  * @test
  */
 public function getConfig_valid()
 {
     // prepare
     $classUnderTest = new \Yamveecee\Config\Loader();
     $expectedResult = $this->getMock('\\Yamveecee\\Config\\ConfigInterface');
     $parserMock = $this->getMock('\\Yamveecee\\Config\\ParserInterface');
     $parserMock->expects($this->once())->method('parse')->will($this->returnValue(new \stdClass()));
     $classUnderTest->addParser('validExtension', $parserMock);
     $fileDto = new \Yamveecee\Resources\Dto('nowhere', 'nofile', 'validExtension');
     $finderMock = $this->getMock('\\Yamveecee\\Resources\\Finder');
     $finderMock->expects($this->once())->method('find')->will($this->returnValue($fileDto));
     $classUnderTest->setResourcesFinder($finderMock);
     $configFactoryMock = $this->getMock('\\Yamveecee\\Config\\FactoryInterface');
     $configFactoryMock->expects($this->once())->method('makeInstance')->will($this->returnValue($expectedResult));
     $classUnderTest->setConfigFactory($configFactoryMock);
     // test
     $result = $classUnderTest->getConfig('dummy');
     // verify
     $this->assertEquals($expectedResult, $result);
 }
示例#2
0
<?php

require_once FRAMEWORKPATH . 'Yamveecee' . DIRECTORY_SEPARATOR . 'Classloader.php';
$classLoader = new \Yamveecee\Classloader();
$classLoader->register();
$classFinder = new \Yamveecee\Resources\Finder();
$classFinder->addPath(dirname(__FILE__));
$classFinder->addPath(APPPATH . 'lib');
$classLoader->setResourceFinder($classFinder);
$configFinder = new \Yamveecee\Resources\Finder();
$configFinder->addPath(APPPATH . 'config');
$configLoader = new \Yamveecee\Config\Loader();
$configLoader->setResourcesFinder($configFinder);
// $configLoader->addParser('.array.php', new \Yamveecee\Config\Parser\PhpArray());
$configLoader->addParser('.json', new \Yamveecee\Config\Parser\Json());
// $configLoader->addParser('.xml', new \Yamveecee\Config\Parser\Xml());
// $configLoader->addParser('.yml', new \Yamveecee\Config\Parser\Yaml());
$configLoader->init();
$serviceLocator = \Yamveecee\Service\Locator::getInstance($configLoader->getConfig('serviceLocator'));
$serviceLocator->addConfigurationLoaderService($configLoader);
$classFinderService = new \Yamveecee\Service\ClassFinder();
$classFinderService->setResourceFinder($classFinder);
$serviceLocator->addService('classFinder', $classFinderService);
$dispatcher = $serviceLocator->getDispatcher();
$response = $dispatcher->route($serviceLocator->getRequestFactory()->getRequest());
$response->render();