Example #1
0
 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param \Pimple $mainContainer An Container instance
  */
 public function register(\Pimple $mainContainer)
 {
     $container = new \Pimple();
     $container['profiler'] = $mainContainer->share(function ($container) use($mainContainer) {
         $profiler = new Profiler(new FileStorage($mainContainer['config']->get('profiler_path')));
         $profiler->addCollector($container['collector.cache']);
         $profiler->addCollector($container['collector.database']);
         return $profiler;
     });
     $container['session_storage'] = $mainContainer->share(function () use($mainContainer) {
         return new SessionStorage($mainContainer['session']);
     });
     $container['profiler_manager'] = $mainContainer->share(function ($container) {
         return new ProfilerManager($container['profiler']);
     });
     $container['collector.cache'] = $mainContainer->share(function () {
         return new CacheDataCollector();
     });
     $container['collector.listener'] = $mainContainer->share(function () use($mainContainer) {
         return new ListenerDataCollector($mainContainer['core']['dispatcher']);
     });
     $container['collector.database'] = $mainContainer->share(function () {
         return new DatabaseDataCollector();
     });
     $container['collector.xhprof'] = $mainContainer->share(function () {
         return new XhprofDataCollector();
     });
     $container['listener'] = $mainContainer->share(function ($container) {
         return new ProfilerListener($container['profiler']);
     });
     $container['template_finder'] = $mainContainer->share(function () {
         return new Finder();
     });
     $mainContainer['profiler'] = $container;
 }
Example #2
0
 public function testStart()
 {
     $collectorStub = $this->getMock('Itkg\\Profiler\\DataCollector\\CacheDataCollector');
     $storageStub = $this->getMock('Itkg\\Profiler\\Storage\\FileStorage', array(), array('data'));
     $profiler = new Profiler($storageStub);
     $profiler->addCollector($collectorStub);
     $collectorStub->expects($this->once())->method('start');
     $storageStub->expects($this->once())->method('load');
     $profiler->start();
 }