@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Particletree\Pqp; |
4 | 4 | |
5 | -use PHPUnit_Framework_Testcase; |
|
6 | - |
|
7 | 5 | // namespace hack on microtime functionality |
8 | 6 | function microtime($get_as_float = false) { |
9 | 7 | if ($get_as_float) { |
@@ -6,81 +6,81 @@ |
||
6 | 6 | |
7 | 7 | // namespace hack on microtime functionality |
8 | 8 | function microtime($get_as_float = false) { |
9 | - if ($get_as_float) { |
|
10 | - return 1450355136.5706; |
|
11 | - } |
|
12 | - return '1450355136 5706'; |
|
9 | + if ($get_as_float) { |
|
10 | + return 1450355136.5706; |
|
11 | + } |
|
12 | + return '1450355136 5706'; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | // namespace hack on included files functionality |
16 | 16 | function get_included_files() { |
17 | - return array( |
|
18 | - 'index.php', |
|
19 | - 'src/Class.php' |
|
20 | - ); |
|
17 | + return array( |
|
18 | + 'index.php', |
|
19 | + 'src/Class.php' |
|
20 | + ); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | // namespace hack on filesize |
24 | 24 | function filesize($filename) { |
25 | - return 100; |
|
25 | + return 100; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | class PhpQuickProfilerTest extends PHPUnit_Framework_TestCase |
29 | 29 | { |
30 | 30 | |
31 | - public function testConstruct() |
|
32 | - { |
|
33 | - $startTime = microtime(true); |
|
34 | - |
|
35 | - $profiler = new PhpQuickProfiler(); |
|
36 | - $this->assertAttributeEquals($startTime, 'startTime', $profiler); |
|
37 | - |
|
38 | - $profiler = new PhpQuickProfiler($startTime); |
|
39 | - $this->assertAttributeEquals($startTime, 'startTime', $profiler); |
|
40 | - } |
|
41 | - |
|
42 | - public function testSetConsole() |
|
43 | - { |
|
44 | - $console = new Console(); |
|
45 | - $profiler = new PhpQuickProfiler(); |
|
46 | - $profiler->setConsole($console); |
|
47 | - |
|
48 | - $this->assertAttributeSame($console, 'console', $profiler); |
|
49 | - } |
|
50 | - |
|
51 | - public function testSetDisplay() |
|
52 | - { |
|
53 | - $display = new Display(); |
|
54 | - $profiler = new PhpQuickProfiler(); |
|
55 | - $profiler->setDisplay($display); |
|
56 | - |
|
57 | - $this->assertAttributeSame($display, 'display', $profiler); |
|
58 | - } |
|
59 | - |
|
60 | - public function testGatherFileData() |
|
61 | - { |
|
62 | - $files = get_included_files(); |
|
63 | - $fileSize = filesize(''); |
|
64 | - $profiler = new PhpQuickProfiler(); |
|
65 | - $gatheredFileData = $profiler->gatherFileData(); |
|
66 | - |
|
67 | - foreach ($gatheredFileData as $fileData) { |
|
68 | - $this->assertArrayHasKey('name', $fileData); |
|
69 | - $this->assertContains($fileData['name'], $files); |
|
70 | - $this->assertArrayHasKey('size', $fileData); |
|
71 | - $this->assertEquals($fileData['size'], $fileSize); |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - public function testSetProfiledQueries() |
|
76 | - { |
|
77 | - $profiledQueries = array( |
|
78 | - 'sql' => 'SELECT * FROM example', |
|
79 | - 'time' => 25 |
|
80 | - ); |
|
81 | - $profiler = new PhpQuickProfiler(); |
|
82 | - $profiler->setProfiledQueries($profiledQueries); |
|
83 | - |
|
84 | - $this->assertAttributeEquals($profiledQueries, 'profiledQueries', $profiler); |
|
85 | - } |
|
31 | + public function testConstruct() |
|
32 | + { |
|
33 | + $startTime = microtime(true); |
|
34 | + |
|
35 | + $profiler = new PhpQuickProfiler(); |
|
36 | + $this->assertAttributeEquals($startTime, 'startTime', $profiler); |
|
37 | + |
|
38 | + $profiler = new PhpQuickProfiler($startTime); |
|
39 | + $this->assertAttributeEquals($startTime, 'startTime', $profiler); |
|
40 | + } |
|
41 | + |
|
42 | + public function testSetConsole() |
|
43 | + { |
|
44 | + $console = new Console(); |
|
45 | + $profiler = new PhpQuickProfiler(); |
|
46 | + $profiler->setConsole($console); |
|
47 | + |
|
48 | + $this->assertAttributeSame($console, 'console', $profiler); |
|
49 | + } |
|
50 | + |
|
51 | + public function testSetDisplay() |
|
52 | + { |
|
53 | + $display = new Display(); |
|
54 | + $profiler = new PhpQuickProfiler(); |
|
55 | + $profiler->setDisplay($display); |
|
56 | + |
|
57 | + $this->assertAttributeSame($display, 'display', $profiler); |
|
58 | + } |
|
59 | + |
|
60 | + public function testGatherFileData() |
|
61 | + { |
|
62 | + $files = get_included_files(); |
|
63 | + $fileSize = filesize(''); |
|
64 | + $profiler = new PhpQuickProfiler(); |
|
65 | + $gatheredFileData = $profiler->gatherFileData(); |
|
66 | + |
|
67 | + foreach ($gatheredFileData as $fileData) { |
|
68 | + $this->assertArrayHasKey('name', $fileData); |
|
69 | + $this->assertContains($fileData['name'], $files); |
|
70 | + $this->assertArrayHasKey('size', $fileData); |
|
71 | + $this->assertEquals($fileData['size'], $fileSize); |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + public function testSetProfiledQueries() |
|
76 | + { |
|
77 | + $profiledQueries = array( |
|
78 | + 'sql' => 'SELECT * FROM example', |
|
79 | + 'time' => 25 |
|
80 | + ); |
|
81 | + $profiler = new PhpQuickProfiler(); |
|
82 | + $profiler->setProfiledQueries($profiledQueries); |
|
83 | + |
|
84 | + $this->assertAttributeEquals($profiledQueries, 'profiledQueries', $profiler); |
|
85 | + } |
|
86 | 86 | } |