Example #1
0
/**
 * Setup shared instances and aliases
 */
$auryn->share($request);
$auryn->share($session);
$auryn->share($user);
$auryn->share($minifier);
$auryn->share($translator);
$auryn->share($decryptor);
$auryn->define('CodeCollab\\Encryption\\Defuse\\Encryptor', [':key' => file_get_contents(__DIR__ . '/encryption.key')]);
$auryn->define('CodeCollab\\Http\\Cookie\\Factory', [':domain' => $request->server('SERVER_NAME'), ':secure' => $request->isEncrypted()]);
$auryn->define('CodeCollab\\Theme\\Theme', [':themePath' => __DIR__ . '/themes', ':theme' => 'Default']);
$auryn->define('Demo\\Presentation\\Template\\Html', [':basePage' => '/page.phtml']);
$auryn->alias('CodeCollab\\CsrfToken\\Token', 'CodeCollab\\CsrfToken\\Handler');
$auryn->alias('CodeCollab\\Authentication\\Authentication', 'CodeCollab\\Authentication\\User');
$auryn->alias('CodeCollab\\CsrfToken\\Storage\\Storage', 'Demo\\Storage\\TokenSession');
$auryn->alias('CodeCollab\\Http\\Session\\Session', 'CodeCollab\\Http\\Session\\Native');
$auryn->alias('CodeCollab\\CsrfToken\\Generator\\Generator', 'CodeCollab\\CsrfToken\\Generator\\RandomBytes32');
$auryn->alias('CodeCollab\\I18n\\Translator', 'CodeCollab\\I18n\\FileTranslator');
$auryn->alias('CodeCollab\\Theme\\Loader', 'CodeCollab\\Theme\\Theme');
$auryn->alias('CodeCollab\\Template\\Html', 'Demo\\Presentation\\Template\\Html');
$auryn->alias('CodeCollab\\Encryption\\Encryptor', 'CodeCollab\\Encryption\\Defuse\\Encryptor');
$auryn->alias('CodeCollab\\Encryption\\Decryptor', 'CodeCollab\\Encryption\\Defuse\\Decryptor');
/**
 * Setup the front controller
 */
$frontController = new FrontController($router, $auryn->make('CodeCollab\\Http\\Response\\Response', ['server' => $request]), $session, $injector);
/**
 * Run the application
 */
$frontController->run($request);
 /**
  * @covers CodeCollab\Router\FrontController::__construct
  * @covers CodeCollab\Router\FrontController::run
  * @covers CodeCollab\Router\FrontController::runRoute
  */
 public function testRunThrowsUpOnNonExistentAction()
 {
     $dispatcher = $this->createMock(Dispatcher::class);
     $dispatcher->expects($this->once())->method('dispatch')->with($this->equalTo('GET'), $this->equalTo('/found'))->willReturn([Dispatcher::FOUND, [ValidController::class, 'noAction'], []]);
     $router = $this->createMock(Router::class);
     $router->expects($this->once())->method('getDispatcher')->willReturn($dispatcher);
     $response = $this->createMock(Response::class);
     $session = $this->createMock(Native::class);
     $injector = $this->createMock(Injector::class);
     $request = $this->createMock(Request::class);
     $request->expects($this->at(0))->method('server')->with($this->equalTo('REQUEST_METHOD'))->willReturn('GET');
     $request->expects($this->at(1))->method('server')->with($this->equalTo('REQUEST_URI_PATH'))->willReturn('/found');
     $frontController = new FrontController($router, $response, $session, $injector);
     $this->expectException(ActionNotFoundException::class);
     $this->expectExceptionMessage('Trying to call a non existent action (`CodeCollabTest\\Mock\\Router\\ValidController::noAction`)');
     $frontController->run($request);
 }
Example #3
0
 /**
  * @covers CodeCollab\Router\FrontController::__construct
  * @covers CodeCollab\Router\FrontController::run
  * @covers CodeCollab\Router\FrontController::runRoute
  */
 public function testRunThrowsUpOnNonExistentAction()
 {
     $dispatcher = $this->getMock('FastRoute\\Dispatcher');
     $dispatcher->expects($this->once())->method('dispatch')->with($this->equalTo('GET'), $this->equalTo('/found'))->willReturn([\FastRoute\Dispatcher::FOUND, ['CodeCollabTest\\Mock\\Router\\ValidController', 'noAction'], []]);
     $router = $this->getMockBuilder('CodeCollab\\Router\\Router')->disableOriginalConstructor()->getMock();
     $router->expects($this->once())->method('getDispatcher')->willReturn($dispatcher);
     $response = $this->getMockBuilder('CodeCollab\\Http\\Response\\Response')->disableOriginalConstructor()->getMock();
     $session = $this->getMockBuilder('CodeCollab\\Http\\Session\\Native')->disableOriginalConstructor()->getMock();
     $injector = $this->getMockBuilder('CodeCollab\\Router\\Injector')->disableOriginalConstructor()->getMock();
     $request = $this->getMockBuilder('CodeCollab\\Http\\Request\\Request')->disableOriginalConstructor()->getMock();
     $request->expects($this->at(0))->method('server')->with($this->equalTo('REQUEST_METHOD'))->willReturn('GET');
     $request->expects($this->at(1))->method('server')->with($this->equalTo('REQUEST_URI_PATH'))->willReturn('/found');
     $frontController = new FrontController($router, $response, $session, $injector);
     $this->setExpectedException('CodeCollab\\Router\\ActionNotFoundException', 'Trying to call a non existent action (`CodeCollabTest\\Mock\\Router\\ValidController::noAction`)');
     $frontController->run($request);
 }