1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-17 21:38:14 +01:00
php-debugbar/tests/DebugBar/Tests/DataCollector/TimeDataCollectorTest.php
Barry vd. Heuvel 0447abd246 Extend TimeData widget/collector
Add params + collector name. Make params expend on click.
2014-10-30 16:40:31 +01:00

49 lines
1.5 KiB
PHP

<?php
namespace DebugBar\Tests\DataCollector;
use DebugBar\Tests\DebugBarTestCase;
use DebugBar\DataCollector\TimeDataCollector;
class TimeDataCollectorTest extends DebugBarTestCase
{
public function setUp()
{
$this->s = microtime(true);
$this->c = new TimeDataCollector($this->s);
}
public function testAddMeasure()
{
$this->c->addMeasure('foo', $this->s, $this->s + 10, array('a' => 'b'), 'timer');
$m = $this->c->getMeasures();
$this->assertCount(1, $m);
$this->assertEquals('foo', $m[0]['label']);
$this->assertEquals(10, $m[0]['duration']);
$this->assertEquals(array('a' => 'b'), $m[0]['params']);
$this->assertEquals('timer', $m[0]['collector']);
}
public function testStartStopMeasure()
{
$this->c->startMeasure('foo', 'bar', 'baz');
$this->c->stopMeasure('foo', array('bar' => 'baz'));
$m = $this->c->getMeasures();
$this->assertCount(1, $m);
$this->assertEquals('bar', $m[0]['label']);
$this->assertEquals('baz', $m[0]['collector']);
$this->assertEquals(array('bar' => 'baz'), $m[0]['params']);
$this->assertTrue($m[0]['start'] < $m[0]['end']);
}
public function testCollect()
{
$this->c->addMeasure('foo', 0, 10);
$this->c->addMeasure('bar', 10, 20);
$data = $this->c->collect();
$this->assertTrue($data['end'] > $this->s);
$this->assertTrue($data['duration'] > 0);
$this->assertCount(2, $data['measures']);
}
}