<?php

require dirname(__DIR__) . '/vendor/autoload.php';
use Jicjjang\June\Router;
use Jicjjang\June\Stubs\AdminController;
use Psr\Http\Message\RequestInterface;
$bench = new Ubench();
$bench->start();
/****************************************************************/
$getMock = Mockery::mock(RequestInterface::class);
$getMock->shouldReceive('getMethod')->andReturn('GET');
$getMock->shouldReceive('getUri->getPath')->andReturn('/abc/ded');
for ($i = 0; $i < 1000; $i++) {
    $app = new Router();
    $app->setController('admin', new AdminController());
    $app->get('/abc', function () {
    }, function () {
    });
    $app->get('/abc/{id}/{name}', ["admin", "middleware"], function () {
    });
    $app->get('/abd/{id}/{what}', function () {
    }, ["admin", "middleware"]);
    $app->get('/abc/def', ["admin", "middleware"], ['admin', 'action']);
    $app->get('/abc/ghi', ["admin", "middleware"], ['admin', 'action'], function () {
    });
    $app->get('/def/{id}/2', function () {
    }, function () {
    });
    $app->get('/def/{id}/{name}', ["admin", "middleware"], function () {
    });
    $app->get('/defg/{id}/{what}', function () {
Exemplo n.º 2
0
 public function testExecuteWithController()
 {
     $app = new Router();
     $app->setController('admin', new AdminController());
     $getMock = Mockery::mock(ServerRequestInterface::class);
     $getMock->shouldReceive('getMethod')->andReturn('GET');
     $getMock->shouldReceive('getUri->getPath')->andReturn('/');
     $getMock->shouldReceive('setArguments')->with([]);
     //        $app->get('/', "middleware@admin", ['admin', 'action']);
     $app->get('/', ["admin", "middleware"], ['admin', 'action']);
     //        $this->assertEquals('Hello World!!!', $app->dispatch($getMock));
     $this->assertEquals('Hello World!!!', $app->dispatch($getMock));
 }