Profiler tests and some rework

Abandoned private constructor and cleaned up the code a bit.
This commit is contained in:
Joshua Sherman 2014-01-15 00:40:34 -05:00
parent 46b77fa1b1
commit f9f179b45d
2 changed files with 70 additions and 76 deletions

View file

@ -2,65 +2,80 @@
class ProfilerTest extends PHPUnit_Framework_TestCase
{
public function testEnabled()
{
// $this->assertTrue(Profiler::enabled());
}
public function testDisabled()
{
// $this->assertFalse(Profiler::enabled());
}
public function testEnabledType()
public function testReport()
{
$this->expectOutputRegex('//');
Profiler::report();
}
public function testDisabledType()
{
$config = Config::getInstance();
$config->data['pickles']['profiler'] = false;
$this->assertFalse(Profiler::enabled('timers'));
}
public function testLogArray()
public function testTimerDisabled()
{
$this->assertFalse(Profiler::timer('disabled'));
}
public function testLogObject()
public function testReportNothing()
{
$this->expectOutputRegex('/There is nothing to profile/');
Profiler::report();
}
public function testLogTimer()
public function testEnabled()
{
$config = Config::getInstance();
$config->data['pickles']['profiler'] = true;
$this->assertTrue(Profiler::enabled());
}
public function testLogString()
public function testEnabledType()
{
$config = Config::getInstance();
$config->data['pickles']['profiler'] = 'timers';
$this->assertTrue(Profiler::enabled('timers'));
}
public function testLogAndTimer()
{
Profiler::log('timer', 'timer-one');
Profiler::log(['foo' => 'bar']);
Profiler::log(new Object);
Profiler::log('string');
Profiler::log(3.14, 'method', true);
Profiler::log('timer', 'timer-one');
}
public function testLogQuery()
{
$explain = [
[
'key' => '',
'possible_keys' => '',
'type' => '',
'rows' => '',
'Extra' => '',
],
];
Profiler::logQuery('SELECT * FROM table;');
Profiler::logQuery('SELECT * FROM table WHERE column = ?;', ['foo']);
Profiler::logQuery('SELECT * FROM table;', false, $explain);
}
public function testTimerStart()
public function testTimer()
{
}
public function testTimerEnd()
{
}
public function testReport()
{
Profiler::timer('timer-two');
Profiler::timer('timer-two');
}
}