Example #1
0
 public function testResolve()
 {
     $this->profiler->start('foo', 'barbar');
     $this->profiler->stop('foo');
     $this->profiler->monitor('Foobar', function () {
         // yeah
     });
     $this->assertInstanceOf(\Generator::class, $this->datasource->getProcess($this->process->getId()));
 }
Example #2
0
 public function testResolveMonolog()
 {
     $monolog = new Monolog();
     $log = new Logger('name');
     $log->pushHandler($monolog);
     $monolog->setDispatcher($this->process->getDispatcher());
     $this->profiler->setLogger($monolog);
     $log->addError('Bar');
     $this->profiler->alert('FooBar');
     $this->assertInstanceOf(\Generator::class, $this->datasource->getProcess($this->process->getId()));
 }
Example #3
0
 public function initiate()
 {
     parent::initiate();
     $processId = $this->request->headers->get(self::HEADER_PROCESS, null);
     $this->process = Process::build($processId);
     $this->process->setContext($this);
 }
Example #4
0
 public function initiate()
 {
     parent::initiate();
     $this->process = Process::build();
     $this->process->setContext($this);
     $this->sendDebugIds();
 }
Example #5
0
 public function testBuildWithParentId()
 {
     $process = Process::build('foo');
     $this->assertInstanceOf(Process::class, $process);
     $this->assertNotNull($process->getId());
     $this->assertEquals('foo', $process->getParentId());
     $this->assertInstanceOf(EventDispatcher::class, $process->getDispatcher());
 }
Example #6
0
 public function testSaveSummary()
 {
     $process = Process::build();
     $this->datasource->saveSummary($process, ['foo' => 'bar']);
     $profiles = $this->datasource->all();
     $this->assertEquals(1, count($profiles));
     $profile = current($profiles);
     $this->assertObjectHasAttribute('foo', $profile);
     $this->assertEquals('bar', $profile->foo);
 }
Example #7
0
 public function testPersist()
 {
     $this->collector->resolve();
     $this->collector->persist();
     $this->assertInstanceOf(\Generator::class, $this->datasource->getProcess($this->process->getId()));
 }
Example #8
0
 public function testRegisterCollectors()
 {
     $this->profiler->registerCollectors([new PhpVersion(Process::build(), new NullDataSource()), new Context(Process::build(), new NullDataSource())]);
     $this->profiler->initiate();
     $this->profiler->terminate();
 }
Example #9
0
 /**
  * @param Process $process
  * @param array $item
  * @return mixed
  * @throws IOException
  */
 public function saveSummary(Process $process, array $item)
 {
     $fileName = $this->getProcessFolder($process->getId()) . DIRECTORY_SEPARATOR . self::SUMMARY_FILENAME;
     if ($this->filesystem->exists($fileName)) {
         $content = json_decode(file_get_contents($fileName));
         if (is_bool($content)) {
             $content = [];
         }
         $item = array_merge((array) $content, $item);
     }
     return file_put_contents($fileName, json_encode($item)) !== false;
 }
Example #10
0
 /**
  * NullContext constructor.
  */
 public function __construct()
 {
     $this->process = Process::build();
 }
Example #11
0
 protected function initiateMemoryProcess(Process $process)
 {
     if (!array_key_exists($process->getId(), $this->memory)) {
         $this->memory[$process->getId()] = [];
     }
 }
Example #12
0
 public function testSaveSummary()
 {
     $process = Process::build();
     $this->datasource->saveSummary($process, ['foo' => 'bar']);
     $this->assertEquals(0, $this->datasource->count());
 }