コード例 #1
0
 public function testNotFoundHandling()
 {
     try {
         $response = $this->application->handle(Request::create('/invalid-url'));
         throw new \RuntimeException('Application in debug mode should throws NotFoundHttpException');
     } catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e) {
         $this->assertTrue(true);
     }
 }
コード例 #2
0
ファイル: index.php プロジェクト: voxsim/minima
<?php

require_once __DIR__ . '/bootstrap.php';
use Minima\Provider\DatabaseProvider;
use Minima\Provider\LoggerProvider;
use Minima\Http\Request;
use Minima\FrontendController\FrontendController;
use Symfony\Component\EventDispatcher\EventDispatcher;
// Configuration
$configuration = array('root' => __DIR__);
// Stateful Components
$dispatcher = new EventDispatcher();
$database = DatabaseProvider::getConnection();
$frontendController = FrontendController::build($configuration);
// Add your routes here
// Build Application
$application = ApplicationFactory::build($configuration, $dispatcher, $frontendController);
// Handle the request
$request = Request::createFromGlobals();
$response = $application->handle($request);
$response->send();
コード例 #3
0
 public function testRedirectToLoginIfNotLogged()
 {
     $request = Request::create('/account');
     $response = $this->application->handle($request);
     $this->assertEquals(302, $response->getStatusCode());
     $this->assertTrue($this->containsString($response->getContent(), 'Redirecting to /login'));
 }
コード例 #4
0
ファイル: Authentication.php プロジェクト: voxsim/minima
 public function check(Request $request)
 {
     return $request->getSession()->get('user') != null;
 }
コード例 #5
0
 public function testNotFoundHandling()
 {
     $response = $this->application->handle(Request::create('/invalid-url'));
     $this->assertEquals('Something went wrong! (No route found for "GET /invalid-url")', $response->getContent());
 }