/** * @covers Fabfuel\Prophiler\Iterator\ComponentFilteredIterator::__construct * @covers Fabfuel\Prophiler\Iterator\ComponentFilteredIterator::accept * @uses Fabfuel\Prophiler\Profiler */ public function testAccept() { $benchmark = $this->getMockBuilder('Fabfuel\\Prophiler\\Benchmark\\Benchmark')->disableOriginalConstructor()->getMock(); $benchmark->expects($this->exactly(2))->method('getComponent')->willReturn('Foobar'); $this->profiler->addBenchmark($benchmark); $iterator = new ComponentFilteredIterator($this->profiler, 'Foobar'); $iterator->rewind(); $this->assertTrue($iterator->accept()); }
public function testAggregate() { $benchmark = $this->getMock('\\Fabfuel\\Prophiler\\Benchmark\\BenchmarkInterface'); $aggregator = $this->getMock('\\Fabfuel\\Prophiler\\AggregatorInterface'); $aggregator->expects($this->once())->method('aggregate')->with($benchmark); $this->profiler->addAggregator($aggregator); $this->profiler->aggregate($benchmark); }
/** * @covers Fabfuel\Prophiler\Iterator\ComponentFilteredIterator::count * @uses Fabfuel\Prophiler\Iterator\ComponentFilteredIterator * @uses Fabfuel\Prophiler\Profiler */ public function testCount() { $benchmark = $this->getMock('Fabfuel\\Prophiler\\Benchmark\\BenchmarkInterface'); $benchmark->expects($this->any())->method('getComponent')->willReturn('Foobar'); $iterator = new ComponentFilteredIterator($this->profiler, 'Foobar'); $this->assertSame(0, count($iterator)); $this->profiler->addBenchmark($benchmark); $this->assertSame(1, count($iterator)); }
/** * @covers Fabfuel\Prophiler\Profiler::current * @covers Fabfuel\Prophiler\Profiler::next * @covers Fabfuel\Prophiler\Profiler::valid * @covers Fabfuel\Prophiler\Profiler::rewind * @covers Fabfuel\Prophiler\Profiler::key * @uses Fabfuel\Prophiler\Profiler * @uses Fabfuel\Prophiler\Benchmark\Benchmark * @uses Fabfuel\Prophiler\Benchmark\BenchmarkFactory */ public function testIteration() { $benchmark1 = $this->profiler->start('Foobar'); $this->profiler->stop($benchmark1); $benchmark2 = $this->profiler->start('Loremk Ipsum'); $this->profiler->stop($benchmark2); $this->profiler->rewind(); $this->assertSame(spl_object_hash($benchmark1), $this->profiler->key()); $this->assertTrue($this->profiler->valid()); $this->assertSame($benchmark1, $this->profiler->current()); $this->profiler->next(); $this->assertSame(spl_object_hash($benchmark2), $this->profiler->key()); $this->assertTrue($this->profiler->valid()); $this->assertSame($benchmark2, $this->profiler->current()); $this->profiler->next(); $this->assertFalse($this->profiler->valid()); }