public function testInvoke()
 {
     $request = $this->getMock(ServerRequest::CLASS, ['getServerParam']);
     $server = new Server($request);
     $profiler = $this->getMock(ProfilerListener::CLASS, ['getTimers']);
     $listeners = new Listeners();
     $listeners->set('SystemProfiler', $profiler);
     $services = new Services();
     $services->set('Server', $server);
     $services->set('Listeners', $listeners);
     $this->setServices($services);
     $rootModel = $this->getMock(ViewModel::CLASS, ['addChild']);
     $toolbarEvent = new ToolbarEvent($rootModel);
     $timers = ['foo' => ['start' => time() - 100, 'stop' => time()]];
     $profiler->expects($this->once())->method('getTimers')->will($this->returnValue($timers));
     $request->expects($this->once())->method('getServerParam')->with('REQUEST_TIME_FLOAT')->will($this->returnValue(time() - 360));
     $model = new ViewModel();
     $listener = new TimersListener();
     $listener->setModel($model);
     $rootModel->expects($this->once())->method('addChild')->with($this->identicalTo($model));
     $listener($toolbarEvent);
     $this->assertTrue(isset($model['timers']));
     $items = $model['timers'];
     $this->assertInternalType('array', $items);
     $this->assertSame(2, count($items));
     $this->assertArrayHasKey('foo', $items);
     $this->assertTrue($items['foo'] > 360);
     $this->assertArrayHasKey('Total', $items);
     $this->assertSame($items['Total'], $items['foo']);
 }
 public function testInvoke()
 {
     $var = 'bar';
     Debug::dump($var);
     $system = System::init([], true);
     $view = $this->getMock(View::CLASS, ['render']);
     $services = new Services();
     $services->set('System', $system);
     $services->set('View', $view);
     $this->setServices($services);
     $html = '<body></body>';
     $stream = Stream::make($html);
     $response = new Response(200, $stream, ['Content-Type' => ['text/html']]);
     $event = new SystemEvent();
     $event->setResult(SystemEvent::FINISH, $response);
     $model = new ViewModel();
     $listener = new InjectDumpListener();
     $listener->setModel($model);
     $view->expects($this->once())->method('render')->with($this->identicalTo($model))->will($this->returnValue('foo'));
     $listener($event);
     $this->assertTrue(isset($model['dumps']));
     $this->assertSame($model['dumps'], Debug::getDumpInstances());
     $injected = $event->getResult(SystemEvent::FINISH);
     $this->assertInstanceOf(Response::CLASS, $injected);
     $body = $injected->getBody();
     $this->assertSame('<body>foo</body>', (string) $body);
 }
 public function testGetSystem()
 {
     $system = System::init();
     $services = new Services();
     $services->set('System', $system);
     $this->setServices($services);
     $template = new SystemTraitTemplate();
     $this->assertSame($system, $template->getSystem());
 }
 public function testGetModules()
 {
     $modules = new Modules();
     $services = new Services();
     $services->set('Modules', $modules);
     Provider::setServices($services);
     $template = new ModulesTraitTemplate();
     $this->assertSame($modules, $template->getModules());
 }
 public function testGetConfig()
 {
     $config = new SystemConfig();
     $services = new Services();
     $services->set('Config', $config);
     Provider::setServices($services);
     $template = new ConfigTraitTemplate();
     $this->assertSame($config, $template->getConfig());
 }
 public function testGetPlugins()
 {
     $plugins = new ControllerPlugins();
     $services = new Services();
     $services->set('ControllerPlugins', $plugins);
     Provider::setServices($services);
     $controller = new PluginsTraitTemplate();
     $this->assertSame($plugins, $controller->getPlugins());
 }
Beispiel #7
0
 public function testGetListeners()
 {
     $listeners = new Listeners();
     $services = new Services();
     $services->set('Listeners', $listeners);
     Provider::setServices($services);
     $trigger = new Trigger('foo', 'bar');
     $this->assertSame($listeners, $trigger->getListeners());
 }
 public function testGetServer()
 {
     $server = new Server();
     $services = new Services();
     $services->set('Server', $server);
     Provider::setServices($services);
     $template = new ServerTraitTemplate();
     $this->assertSame($server, $template->getServer());
 }
 public function testGetControllers()
 {
     $controllers = new Controllers();
     $services = new Services();
     $services->set('Controllers', $controllers);
     Provider::setServices($services);
     $template = new ControllersTraitTemplate();
     $this->assertSame($controllers, $template->getControllers());
 }
 public function testGetRouter()
 {
     $services = new Services();
     $router = new Router();
     $services->set('Router', $router);
     $this->setServices($services);
     $template = new RouterTraitTemplate();
     $this->assertSame($router, $template->getRouter());
 }
 public function testGetResolver()
 {
     $resolver = new TemplateResolver();
     $services = new Services();
     $services->set('ErrorTemplateResolver', $resolver);
     $this->setServices($services);
     $renderer = new ErrorRenderer();
     $this->assertSame($resolver, $renderer->getResolver());
 }
Beispiel #12
0
 public function testGetEvents()
 {
     $events = new Events();
     $services = new Services();
     $services->set('Events', $events);
     $view = new View();
     $view->setServices($services);
     $this->assertSame($events, $view->getEvents());
 }
 public function testGetHelpers()
 {
     $helpers = new ViewHelpers();
     $services = new Services();
     $services->set('ViewHelpers', $helpers);
     $this->setServices($services);
     $renderer = new Renderer();
     $this->assertSame($helpers, $renderer->getHelpers());
 }
 public function testGetPlugins()
 {
     $plugins = new ControllerPlugins();
     $services = new Services();
     $services->set('ControllerPlugins', $plugins);
     Provider::setServices($services);
     $listener = new ConfigurePluginsListener();
     $this->assertSame($plugins, $listener->getPlugins());
 }
 public function testGetControllers()
 {
     $controllers = new Controllers();
     $services = new Services();
     $services->set('Controllers', $controllers);
     $this->setServices($services);
     $plugin = new Forward();
     $this->assertSame($controllers, $plugin->getControllers());
 }
 public function testGetRenderer()
 {
     $services = new Services();
     $renderer = new Renderer();
     $services->set('DefaultTemplateRenderer', $renderer);
     $this->setServices($services);
     $engine = new TemplateEngine();
     $this->assertSame($renderer, $engine->getRenderer());
 }
 public function testGetEvents()
 {
     $events = new Events();
     $services = new Services();
     $services->set('Events', $events);
     Provider::setServices($services);
     $template = new EventsTraitTemplate();
     $this->assertSame($events, $template->getEvents());
 }
 public function testGetView()
 {
     $view = new View();
     $services = new Services();
     $services->set('View', $view);
     $this->setServices($services);
     $plugin = new Layout();
     $this->assertSame($view, $plugin->getView());
 }
 public function testSetResolver()
 {
     $resolver = new Resolver();
     $services = new Services();
     $services->set('ViewResolver', $resolver);
     Provider::setServices($services);
     $listener = new ConfigureResolverListener();
     $this->assertSame($resolver, $listener->getResolver());
 }
 public function testGetDefaultErrorStrategy()
 {
     $strategy = new HtmlErrorStrategy();
     $services = new Services();
     $services->set('HtmlErrorStrategy', $strategy);
     $listener = new ErrorListener();
     $listener->setServices($services);
     $this->assertSame($strategy, $listener->getDefaultErrorStrategy());
 }
 public function testGetListeners()
 {
     $listeners = new Listeners();
     $services = new Services();
     $services->set('Listeners', $listeners);
     Provider::setServices($services);
     $template = new ListenersTraitTemplate();
     $this->assertSame($listeners, $template->getListeners());
 }
 public function testGetLoader()
 {
     $loader = new ClassLoader();
     $services = new Services();
     $services->set('ClassLoader', $loader);
     $this->setServices($services);
     $listener = new RegistrationListener();
     $this->assertSame($loader, $listener->getLoader());
 }
 public function testGetModels()
 {
     $models = new Models();
     $services = new Services();
     $services->set('Models', $models);
     $this->setServices($services);
     $template = new ModelsTraitTemplate();
     $this->assertSame($models, $template->getModels());
 }
 public function testGetHelpers()
 {
     $helpers = new ViewHelpers();
     $services = new Services();
     $services->set('ViewHelpers', $helpers);
     $this->setServices($services);
     $listener = new ConfigureHelpersListener();
     $this->assertSame($helpers, $listener->getHelpers());
 }
Beispiel #25
0
 public function testGetView()
 {
     $view = new View();
     $services = new Services();
     $services->set('View', $view);
     Provider::setServices($services);
     $template = new ViewTraitTemplate();
     $this->assertSame($view, $template->getView());
 }
 public function testGetRouter()
 {
     $router = new Router();
     $services = new Services();
     $services->set('Router', $router);
     $this->setServices($services);
     $plugin = new Url();
     $this->assertSame($router, $plugin->getRouter());
 }
 public function testGetRenderer()
 {
     $renderer = new ErrorRenderer();
     $services = new Services();
     $services->set('ErrorTemplateRenderer', $renderer);
     $this->setServices($services);
     $strategy = new HtmlErrorStrategy();
     $this->assertSame($renderer, $strategy->getRenderer());
 }
 public function testGetLoader()
 {
     $loader = new ModuleLoader();
     $services = new Services();
     $services->set('ModuleLoader', $loader);
     $this->setServices($services);
     $listener = new LoaderListener();
     $this->assertSame($loader, $listener->getLoader());
 }
 public function testGetCache()
 {
     $services = new Services();
     $cache = $this->getMock(AbstractCache::CLASS);
     $services->set('Cache', $cache);
     $listener = new CacheConfigListener();
     $listener->setServices($services);
     $cache->expects($this->once())->method('withNamespace')->with($this->identicalTo('system'))->will($this->returnValue($cache));
     $this->assertSame($cache, $listener->getCache());
 }
 public function testGetCache()
 {
     $services = new Services();
     $cache = new FileCache();
     $services->set('Cache', $cache);
     $listener = $this->getMock(ConfigureCacheListener::CLASS, ['setCache']);
     $listener->setServices($services);
     $listener->expects($this->once())->method('setCache')->with($this->identicalTo($cache));
     $listener->getCache();
 }