Moved tests and updated to use namespaces

This commit is contained in:
Josh Sherman 2014-09-28 07:31:02 -04:00
parent 302f400dcb
commit 0cfc2c7979
26 changed files with 686 additions and 683 deletions

81
tests/ProfilerTest.php Normal file
View file

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