예제 #1
0
 /**
  *
  */
 protected function setUp()
 {
     $item = new Item();
     $item->attach($this);
     $item->attach(new BacktraceObserver());
     $this->manager = new Manager($item);
 }
예제 #2
0
 public function testBasic()
 {
     $this->expectOutputRegex('/\\[\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}] test\\.DEBUG: 1 \\{"PHProfiling\\\\\\\\Example\\\\\\\\TaggingObserver":\\{"tag":"EX"\\},"PHProfiling\\\\\\\\Example\\\\\\\\MemoryPeekUseObserver":\\{"usage":\\d+\\}\\} \\[\\]/');
     $logger = new Logger('test');
     $logger->pushHandler(new StreamHandler('php://output'));
     $prototype = new Item();
     $prototype->attach(new MonologOutput($logger, Logger::DEBUG));
     $prototype->attach(new TaggingObserver('EX'));
     $prototype->attach(new MemoryPeekUseObserver());
     $manager = new Manager($prototype);
     $manager->namedStart('1');
     $memoryEater = range(0, 500);
     $this->assertTrue($manager->stop()->isHandled());
     unset($memoryEater);
 }
예제 #3
0
 public function testSimple()
 {
     $this->expectOutputString("onFinish\nonFinish");
     $item = new Item();
     $item->attach($this);
     $manager = new Manager(new Item('N'));
     $this->assertSame('N', $manager->getPrototype()->getTitle());
     $this->assertSame($manager, $manager->setPrototype($item));
     $this->assertSame($item, $manager->getPrototype());
     $this->assertInstanceOf(\SplQueue::class, $manager->getIterator());
     $this->assertNull($manager->top());
     foreach ($manager as $item) {
         $this->fail('Should be empty iteration now: ' . gettype($item));
     }
     $newItem = $manager->create('1');
     $this->assertInstanceOf(Item::class, $newItem);
     $this->assertSame('1', $newItem->getTitle());
     $this->assertNotSame($item, $newItem);
     $this->assertSame($newItem, $manager->start());
     $this->assertInstanceOf(StateRunning::class, $newItem->getState());
     $this->assertInstanceOf(StatePaused::class, $manager->pause()->getState());
     $this->assertSame($newItem, $manager->top());
     $this->assertInstanceOf(StateRunning::class, $manager->resume()->getState());
     $newItem->stop();
     $this->assertNull($manager->discard());
     echo "\n";
     $this->assertNotSame($newItem, $newItem2 = $manager->namedStart('2'));
     $this->assertCount(1, $manager);
     $this->assertSame('2', $newItem2->getTitle());
     $this->assertSame($newItem2, $manager->stop());
     $this->assertCount(2, $manager);
     $item->detach($this);
     $this->assertSame('3', $manager->start()->setTitle('3')->setHandled(true)->stop()->getTitle());
     $this->assertCount(2, $manager);
 }
예제 #4
0
 protected function setUp()
 {
     $prototype = new Item();
     $prototype->attach(new TimingObserver());
     $this->manager = new Manager($prototype);
 }