Пример #1
0
 public function testAppReturnedByInit()
 {
     $app = App::init();
     $this->assertInstanceOf('ZeffMu\\App', $app);
 }
Пример #2
0
<?php

chdir(dirname(__DIR__));
require 'vendor/autoload.php';
$app = \ZeffMu\App::init();
$app->route('/', function () {
    return '<a href="/hello">HEllo!</a>';
})->route('/hello', function () {
    return 'Hi!';
})->route('/hello/:name', function ($params) use($app) {
    return 'Hello ' . $params['name'];
})->route('/hello/:name/:surname', function ($params) use($app) {
    return 'Hello, Mr. ' . $params['surname'] . ', or shall I call you ' . $params['name'] . '?';
})->run();
Пример #3
0
 /**
  * @group #24
  *
  * @requires PHP 5.4
  */
 public function testControllerPluginsAreCorrectlyInjectedInFactories()
 {
     $helper = $this->getMock('Zend\\Mvc\\Controller\\Plugin\\PluginInterface', array('setController', 'getController', '__invoke'));
     $request = new Request();
     $app = App::init();
     /* @var $plugins \Zend\ServiceManager\AbstractPluginManager */
     $plugins = $app->getServiceManager()->get('ControllerPluginManager');
     $request->setUri('http://localhost/something');
     $app->getMvcEvent()->setRequest($request);
     $plugins->setService('foo', $helper);
     $app->route('/something', function () {
         $this->foo('bar');
     });
     $helper->expects(self::once())->method('__invoke')->with('bar');
     // overriding send response listener
     $app->getEventManager()->attach(MvcEvent::EVENT_FINISH, function (EventInterface $e) {
         $e->stopPropagation();
     }, 1000);
     $app->run();
 }