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())); }
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())); }
public function initiate() { parent::initiate(); $processId = $this->request->headers->get(self::HEADER_PROCESS, null); $this->process = Process::build($processId); $this->process->setContext($this); }
public function initiate() { parent::initiate(); $this->process = Process::build(); $this->process->setContext($this); $this->sendDebugIds(); }
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()); }
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); }
public function testPersist() { $this->collector->resolve(); $this->collector->persist(); $this->assertInstanceOf(\Generator::class, $this->datasource->getProcess($this->process->getId())); }
public function testRegisterCollectors() { $this->profiler->registerCollectors([new PhpVersion(Process::build(), new NullDataSource()), new Context(Process::build(), new NullDataSource())]); $this->profiler->initiate(); $this->profiler->terminate(); }
/** * @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; }
/** * NullContext constructor. */ public function __construct() { $this->process = Process::build(); }
protected function initiateMemoryProcess(Process $process) { if (!array_key_exists($process->getId(), $this->memory)) { $this->memory[$process->getId()] = []; } }
public function testSaveSummary() { $process = Process::build(); $this->datasource->saveSummary($process, ['foo' => 'bar']); $this->assertEquals(0, $this->datasource->count()); }