Completed
Push — master ( 358045...40fc10 )
by Jacob
02:24
created
tests/helpers/function-overrides.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -5,43 +5,43 @@
 block discarded – undo
5 5
 // namespace hack on microtime functionality
6 6
 function microtime()
7 7
 {
8
-    return 1450355136.5706;
8
+	return 1450355136.5706;
9 9
 }
10 10
 
11 11
 // namespace hack on included files functionality
12 12
 function get_included_files()
13 13
 {
14
-    return array(
15
-        'index.php',
16
-        'src/Class.php'
17
-    );
14
+	return array(
15
+		'index.php',
16
+		'src/Class.php'
17
+	);
18 18
 }
19 19
 
20 20
 // namespace hack on filesize
21 21
 function filesize($filename)
22 22
 {
23
-    return strlen($filename) * 100;
23
+	return strlen($filename) * 100;
24 24
 }
25 25
 
26 26
 // namespace hack on memory usage
27 27
 function memory_get_usage()
28 28
 {
29
-    return 12345678;
29
+	return 12345678;
30 30
 }
31 31
 
32 32
 // namespace hack on memory usage
33 33
 function memory_get_peak_usage()
34 34
 {
35
-    return 123456789;
35
+	return 123456789;
36 36
 }
37 37
 
38 38
 // namespace hack on ini settings
39 39
 function ini_get($setting)
40 40
 {
41
-    if ($setting == 'memory_limit') {
42
-        return '128M';
43
-    } elseif ($setting == 'max_execution_time') {
44
-        return '30';
45
-    }
46
-    return \ini_get($setting);
41
+	if ($setting == 'memory_limit') {
42
+		return '128M';
43
+	} elseif ($setting == 'max_execution_time') {
44
+		return '30';
45
+	}
46
+	return \ini_get($setting);
47 47
 }
Please login to merge, or discard this patch.
tests/unit/DisplayTest.php 1 patch
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -9,219 +9,219 @@
 block discarded – undo
9 9
 class DisplayTest extends PHPUnit_Framework_TestCase
10 10
 {
11 11
 
12
-    public function testConstruct()
13
-    {
14
-        $display = new Display();
15
-        $reflectedDisplay = new ReflectionClass(get_class($display));
16
-        $reflectedProperty = $reflectedDisplay->getProperty('defaults');
17
-        $reflectedProperty->setAccessible(true);
18
-        $defaults = $reflectedProperty->getValue($display);
19
-
20
-        $display = new Display();
21
-        $this->assertAttributeEquals($defaults, 'options', $display);
22
-
23
-        $options = array(
24
-            'script_path' => 'testing/testing.js',
25
-            'fake_key' => 'foo bar'
26
-        );
27
-        $expectedOptions = array_intersect_key($options, $defaults);
28
-        $expectedOptions = array_replace($defaults, $expectedOptions);
29
-        $display = new Display($options);
30
-        $this->assertAttributeEquals($expectedOptions, 'options', $display);
31
-    }
32
-
33
-    public function testSetStartTime()
34
-    {
35
-        $startTime = microtime(true);
36
-        $display = new Display();
37
-        $display->setStartTime($startTime);
38
-
39
-        $this->assertAttributeEquals($startTime, 'startTime', $display);
40
-    }
41
-
42
-    public function testSetConsole()
43
-    {
44
-        $console = new Console();
45
-        $display = new Display();
46
-        $display->setConsole($console);
47
-
48
-        $this->assertAttributeSame($console, 'console', $display);
49
-    }
50
-
51
-    public function testSetMemoryData()
52
-    {
53
-        $memoryData = array(
54
-            'used'    => memory_get_peak_usage(),
55
-            'allowed' => ini_get('memory_limit')
56
-        );
57
-        $display = new Display();
58
-        $display->setMemoryData($memoryData);
59
-
60
-        $this->assertAttributeEquals($memoryData, 'memoryData', $display);
61
-    }
62
-
63
-    public function testSetQueryData()
64
-    {
65
-        $queryData = array(
66
-            'sql'     => 'SELECT * FROM testing',
67
-            'explain' => array(
68
-                'key' => 'value'
69
-            ),
70
-            'time'    => 300
71
-        );
72
-        $display = new Display();
73
-        $display->setQueryData($queryData);
74
-
75
-        $this->assertAttributeEquals($queryData, 'queryData', $display);
76
-    }
77
-
78
-    public function testSetSpeedData()
79
-    {
80
-        $speedData = array(
81
-            'elapsed' => 1.234,
82
-            'allowed' => 30
83
-        );
84
-        $display = new Display();
85
-        $display->setSpeedData($speedData);
86
-
87
-        $this->assertAttributeEquals($speedData, 'speedData', $display);
88
-    }
89
-
90
-    public function testGetConsoleMeta()
91
-    {
92
-        $expectedMeta = array(
93
-            'log'    => 1,
94
-            'memory' => 0,
95
-            'error'  => 0,
96
-            'speed'  => 2
97
-        );
98
-        $console = new Console();
99
-        $console->log('testing words');
100
-        $console->logSpeed('now');
101
-        $console->logSpeed();
102
-        $display = new Display();
103
-        $display->setConsole($console);
104
-        $reflectedMethod = $this->getAccessibleMethod($display, 'getConsoleMeta');
105
-
106
-        $consoleMeta = $reflectedMethod->invoke($display);
107
-        $this->assertEquals($expectedMeta, $consoleMeta);
108
-    }
109
-
110
-    public function testGetConsoleMessages()
111
-    {
112
-        $console = new Console();
113
-        $testLog = 'testing more words';
114
-        $console->log($testLog);
115
-        $console->logMemory();
116
-        $testException = new Exception('test exception');
117
-        $console->logError($testException);
118
-        $console->logSpeed();
119
-        $display = new Display();
120
-        $display->setConsole($console);
121
-        $reflectedMethod = $this->getAccessibleMethod($display, 'getConsoleMessages');
122
-
123
-        $consoleMessages = $reflectedMethod->invoke($display);
124
-        foreach ($consoleMessages as $message) {
125
-            $this->assertArrayHasKey('message', $message);
126
-            $this->assertInternalType('string', $message['message']);
127
-            $this->assertArrayHasKey('type', $message);
128
-            $this->assertInternalType('string', $message['type']);
129
-            switch ($message['type']) {
130
-                case 'log':
131
-                    $expectedMessage = print_r($testLog, true);
132
-                    $this->assertEquals($expectedMessage, $message['message']);
133
-                    break;
134
-                case 'memory':
135
-                    $expectedMessage = 'PHP';
136
-                    $this->assertEquals($expectedMessage, $message['message']);
137
-                    $this->assertArrayHasKey('data', $message);
138
-                    $this->assertInternalType('string', $message['data']);
139
-                    $expectedData = memory_get_usage();
140
-                    $reflectedMethod = $this->getAccessibleMethod($display, 'getReadableMemory');
141
-                    $expectedData = $reflectedMethod->invokeArgs($display, array($expectedData));
142
-                    $this->assertEquals($expectedData, $message['data']);
143
-                    break;
144
-                case 'error':
145
-                    $expectedMessage = sprintf("Line %s: %s in %s",
146
-                        $testException->getLine(),
147
-                        $testException->getMessage(),
148
-                        $testException->getFile()
149
-                    );
150
-                    $this->assertEquals($expectedMessage, $message['message']);
151
-                    break;
152
-                case 'speed':
153
-                    $expectedMessage = 'Point in Time';
154
-                    $this->assertEquals($expectedMessage, $message['message']);
155
-                    $this->assertArrayHasKey('data', $message);
156
-                    $this->assertInternalType('string', $message['data']);
157
-                    $expectedData = microtime(true);
158
-                    $reflectedMethod = $this->getAccessibleMethod($display, 'getReadableTime');
159
-                    $expectedData = $reflectedMethod->invokeArgs($display, array($expectedData));
160
-                    $this->assertEquals($expectedData, $message['data']);
161
-                    break;
162
-            }
163
-        }
164
-    }
165
-
166
-    public function testGetSpeedMeta()
167
-    {
168
-        $elapsedTime = 1234.678;
169
-        $allowedTime = 30;
170
-        $display = new Display();
171
-        $display->setSpeedData(array(
172
-            'elapsed' => $elapsedTime,
173
-            'allowed' => $allowedTime
174
-        ));
175
-        $reflectedMethod = $this->getAccessibleMethod($display, 'getReadableTime');
176
-        $elapsedTime = $reflectedMethod->invokeArgs($display, array($elapsedTime));
177
-        $allowedTime = $reflectedMethod->invokeArgs($display, array($allowedTime, 0));
178
-        $expectedMeta = array(
179
-            'elapsed' => $elapsedTime,
180
-            'allowed' => $allowedTime
181
-        );
182
-
183
-        $reflectedMethod = $this->getAccessibleMethod($display, 'getSpeedMeta');
184
-        $speedMeta = $reflectedMethod->invoke($display);
185
-        $this->assertEquals($expectedMeta, $speedMeta);
186
-    }
187
-
188
-    public function testGetReadableTime()
189
-    {
190
-        $timeTest = array(
191
-            '.032432' => '32.432 ms',
192
-            '24.3781' => '24.378 s',
193
-            '145.123' => '2.419 m'
194
-        );
195
-        $display = new Display();
196
-        $reflectedMethod = $this->getAccessibleMethod($display, 'getReadableTime');
197
-
198
-        foreach ($timeTest as $rawTime => $expectedTime) {
199
-            $readableTime = $reflectedMethod->invokeArgs($display, array($rawTime));
200
-            $this->assertEquals($expectedTime, $readableTime);
201
-        }
202
-    }
203
-
204
-    public function testGetReadableMemory()
205
-    {
206
-        $memoryTest = array(
207
-            '314'     => '314 b',
208
-            '7403'    => '7.23 k',
209
-            '2589983' => '2.47 M'
210
-        );
211
-        $display = new Display();
212
-        $reflectedMethod = $this->getAccessibleMethod($display, 'getReadableMemory');
213
-
214
-        foreach ($memoryTest as $rawMemory => $expectedMemory) {
215
-            $readableMemory = $reflectedMethod->invokeArgs($display, array($rawMemory));
216
-            $this->assertEquals($expectedMemory, $readableMemory);
217
-        }
218
-    }
219
-
220
-    protected function getAccessibleMethod(Display $display, $methodName)
221
-    {
222
-        $reflectedConsole = new ReflectionClass(get_class($display));
223
-        $reflectedMethod = $reflectedConsole->getMethod($methodName);
224
-        $reflectedMethod->setAccessible(true);
225
-        return $reflectedMethod;
226
-    }
12
+	public function testConstruct()
13
+	{
14
+		$display = new Display();
15
+		$reflectedDisplay = new ReflectionClass(get_class($display));
16
+		$reflectedProperty = $reflectedDisplay->getProperty('defaults');
17
+		$reflectedProperty->setAccessible(true);
18
+		$defaults = $reflectedProperty->getValue($display);
19
+
20
+		$display = new Display();
21
+		$this->assertAttributeEquals($defaults, 'options', $display);
22
+
23
+		$options = array(
24
+			'script_path' => 'testing/testing.js',
25
+			'fake_key' => 'foo bar'
26
+		);
27
+		$expectedOptions = array_intersect_key($options, $defaults);
28
+		$expectedOptions = array_replace($defaults, $expectedOptions);
29
+		$display = new Display($options);
30
+		$this->assertAttributeEquals($expectedOptions, 'options', $display);
31
+	}
32
+
33
+	public function testSetStartTime()
34
+	{
35
+		$startTime = microtime(true);
36
+		$display = new Display();
37
+		$display->setStartTime($startTime);
38
+
39
+		$this->assertAttributeEquals($startTime, 'startTime', $display);
40
+	}
41
+
42
+	public function testSetConsole()
43
+	{
44
+		$console = new Console();
45
+		$display = new Display();
46
+		$display->setConsole($console);
47
+
48
+		$this->assertAttributeSame($console, 'console', $display);
49
+	}
50
+
51
+	public function testSetMemoryData()
52
+	{
53
+		$memoryData = array(
54
+			'used'    => memory_get_peak_usage(),
55
+			'allowed' => ini_get('memory_limit')
56
+		);
57
+		$display = new Display();
58
+		$display->setMemoryData($memoryData);
59
+
60
+		$this->assertAttributeEquals($memoryData, 'memoryData', $display);
61
+	}
62
+
63
+	public function testSetQueryData()
64
+	{
65
+		$queryData = array(
66
+			'sql'     => 'SELECT * FROM testing',
67
+			'explain' => array(
68
+				'key' => 'value'
69
+			),
70
+			'time'    => 300
71
+		);
72
+		$display = new Display();
73
+		$display->setQueryData($queryData);
74
+
75
+		$this->assertAttributeEquals($queryData, 'queryData', $display);
76
+	}
77
+
78
+	public function testSetSpeedData()
79
+	{
80
+		$speedData = array(
81
+			'elapsed' => 1.234,
82
+			'allowed' => 30
83
+		);
84
+		$display = new Display();
85
+		$display->setSpeedData($speedData);
86
+
87
+		$this->assertAttributeEquals($speedData, 'speedData', $display);
88
+	}
89
+
90
+	public function testGetConsoleMeta()
91
+	{
92
+		$expectedMeta = array(
93
+			'log'    => 1,
94
+			'memory' => 0,
95
+			'error'  => 0,
96
+			'speed'  => 2
97
+		);
98
+		$console = new Console();
99
+		$console->log('testing words');
100
+		$console->logSpeed('now');
101
+		$console->logSpeed();
102
+		$display = new Display();
103
+		$display->setConsole($console);
104
+		$reflectedMethod = $this->getAccessibleMethod($display, 'getConsoleMeta');
105
+
106
+		$consoleMeta = $reflectedMethod->invoke($display);
107
+		$this->assertEquals($expectedMeta, $consoleMeta);
108
+	}
109
+
110
+	public function testGetConsoleMessages()
111
+	{
112
+		$console = new Console();
113
+		$testLog = 'testing more words';
114
+		$console->log($testLog);
115
+		$console->logMemory();
116
+		$testException = new Exception('test exception');
117
+		$console->logError($testException);
118
+		$console->logSpeed();
119
+		$display = new Display();
120
+		$display->setConsole($console);
121
+		$reflectedMethod = $this->getAccessibleMethod($display, 'getConsoleMessages');
122
+
123
+		$consoleMessages = $reflectedMethod->invoke($display);
124
+		foreach ($consoleMessages as $message) {
125
+			$this->assertArrayHasKey('message', $message);
126
+			$this->assertInternalType('string', $message['message']);
127
+			$this->assertArrayHasKey('type', $message);
128
+			$this->assertInternalType('string', $message['type']);
129
+			switch ($message['type']) {
130
+				case 'log':
131
+					$expectedMessage = print_r($testLog, true);
132
+					$this->assertEquals($expectedMessage, $message['message']);
133
+					break;
134
+				case 'memory':
135
+					$expectedMessage = 'PHP';
136
+					$this->assertEquals($expectedMessage, $message['message']);
137
+					$this->assertArrayHasKey('data', $message);
138
+					$this->assertInternalType('string', $message['data']);
139
+					$expectedData = memory_get_usage();
140
+					$reflectedMethod = $this->getAccessibleMethod($display, 'getReadableMemory');
141
+					$expectedData = $reflectedMethod->invokeArgs($display, array($expectedData));
142
+					$this->assertEquals($expectedData, $message['data']);
143
+					break;
144
+				case 'error':
145
+					$expectedMessage = sprintf("Line %s: %s in %s",
146
+						$testException->getLine(),
147
+						$testException->getMessage(),
148
+						$testException->getFile()
149
+					);
150
+					$this->assertEquals($expectedMessage, $message['message']);
151
+					break;
152
+				case 'speed':
153
+					$expectedMessage = 'Point in Time';
154
+					$this->assertEquals($expectedMessage, $message['message']);
155
+					$this->assertArrayHasKey('data', $message);
156
+					$this->assertInternalType('string', $message['data']);
157
+					$expectedData = microtime(true);
158
+					$reflectedMethod = $this->getAccessibleMethod($display, 'getReadableTime');
159
+					$expectedData = $reflectedMethod->invokeArgs($display, array($expectedData));
160
+					$this->assertEquals($expectedData, $message['data']);
161
+					break;
162
+			}
163
+		}
164
+	}
165
+
166
+	public function testGetSpeedMeta()
167
+	{
168
+		$elapsedTime = 1234.678;
169
+		$allowedTime = 30;
170
+		$display = new Display();
171
+		$display->setSpeedData(array(
172
+			'elapsed' => $elapsedTime,
173
+			'allowed' => $allowedTime
174
+		));
175
+		$reflectedMethod = $this->getAccessibleMethod($display, 'getReadableTime');
176
+		$elapsedTime = $reflectedMethod->invokeArgs($display, array($elapsedTime));
177
+		$allowedTime = $reflectedMethod->invokeArgs($display, array($allowedTime, 0));
178
+		$expectedMeta = array(
179
+			'elapsed' => $elapsedTime,
180
+			'allowed' => $allowedTime
181
+		);
182
+
183
+		$reflectedMethod = $this->getAccessibleMethod($display, 'getSpeedMeta');
184
+		$speedMeta = $reflectedMethod->invoke($display);
185
+		$this->assertEquals($expectedMeta, $speedMeta);
186
+	}
187
+
188
+	public function testGetReadableTime()
189
+	{
190
+		$timeTest = array(
191
+			'.032432' => '32.432 ms',
192
+			'24.3781' => '24.378 s',
193
+			'145.123' => '2.419 m'
194
+		);
195
+		$display = new Display();
196
+		$reflectedMethod = $this->getAccessibleMethod($display, 'getReadableTime');
197
+
198
+		foreach ($timeTest as $rawTime => $expectedTime) {
199
+			$readableTime = $reflectedMethod->invokeArgs($display, array($rawTime));
200
+			$this->assertEquals($expectedTime, $readableTime);
201
+		}
202
+	}
203
+
204
+	public function testGetReadableMemory()
205
+	{
206
+		$memoryTest = array(
207
+			'314'     => '314 b',
208
+			'7403'    => '7.23 k',
209
+			'2589983' => '2.47 M'
210
+		);
211
+		$display = new Display();
212
+		$reflectedMethod = $this->getAccessibleMethod($display, 'getReadableMemory');
213
+
214
+		foreach ($memoryTest as $rawMemory => $expectedMemory) {
215
+			$readableMemory = $reflectedMethod->invokeArgs($display, array($rawMemory));
216
+			$this->assertEquals($expectedMemory, $readableMemory);
217
+		}
218
+	}
219
+
220
+	protected function getAccessibleMethod(Display $display, $methodName)
221
+	{
222
+		$reflectedConsole = new ReflectionClass(get_class($display));
223
+		$reflectedMethod = $reflectedConsole->getMethod($methodName);
224
+		$reflectedMethod->setAccessible(true);
225
+		return $reflectedMethod;
226
+	}
227 227
 }
Please login to merge, or discard this patch.