Skip to content

Commit e11f014

Browse files
committed
Update Profiler test
1 parent 352fdcd commit e11f014

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/Profiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ abstract class Profiler {
1515
/**
1616
* @return Collection
1717
*/
18-
public function getCollection() {
18+
public static function getCollection() {
1919
$className = static::class;
2020

2121
if (!isset(static::$collections[$className])) {

tests/ProfilerTest.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ public function __construct($name = null, array $data = [], $dataName = '') {
2929
*/
3030
public function testInit() {
3131
$expected = null;
32-
$result = Timer::$collection;
32+
$result = Timer::getCollection();
3333
$this->assertEquals($expected, $result);
3434

3535
Timer::init();
3636

3737
$expected = '\Xicrow\PhpDebug\Collection';
38-
$result = Timer::$collection;
38+
$result = Timer::getCollection();
3939
$this->assertInstanceOf($expected, $result);
4040

4141
$expected = [];
42-
$result = Timer::$collection->getAll();
42+
$result = Timer::getCollection()->getAll();
4343
$this->assertEquals($expected, $result);
4444
}
4545

@@ -48,18 +48,18 @@ public function testInit() {
4848
* @covers \Xicrow\PhpDebug\Profiler::add
4949
*/
5050
public function testAdd() {
51-
Timer::$collection->clear();
51+
Timer::getCollection()->clear();
5252

5353
$expected = 0;
54-
$result = Timer::$collection->count();
54+
$result = Timer::getCollection()->count();
5555
$this->assertEquals($expected, $result);
5656

5757
$expected = true;
5858
$result = Timer::add();
5959
$this->assertEquals($expected, $result);
6060

6161
$expected = 1;
62-
$result = Timer::$collection->count();
62+
$result = Timer::getCollection()->count();
6363
$this->assertEquals($expected, $result);
6464
}
6565

@@ -69,18 +69,18 @@ public function testAdd() {
6969
* @covers \Xicrow\PhpDebug\Profiler::start
7070
*/
7171
public function testStart() {
72-
Timer::$collection->clear();
72+
Timer::getCollection()->clear();
7373

7474
$expected = 0;
75-
$result = Timer::$collection->count();
75+
$result = Timer::getCollection()->count();
7676
$this->assertEquals($expected, $result);
7777

7878
$expected = true;
7979
$result = Timer::start();
8080
$this->assertEquals($expected, $result);
8181

8282
$expected = 1;
83-
$result = Timer::$collection->count();
83+
$result = Timer::getCollection()->count();
8484
$this->assertEquals($expected, $result);
8585
}
8686

@@ -91,18 +91,18 @@ public function testStart() {
9191
* @covers \Xicrow\PhpDebug\Profiler::stop
9292
*/
9393
public function testStop() {
94-
Timer::$collection->clear();
94+
Timer::getCollection()->clear();
9595

9696
$expected = 0;
97-
$result = Timer::$collection->count();
97+
$result = Timer::getCollection()->count();
9898
$this->assertEquals($expected, $result);
9999

100100
$expected = false;
101101
$result = Timer::stop();
102102
$this->assertEquals($expected, $result);
103103

104104
$expected = 0;
105-
$result = Timer::$collection->count();
105+
$result = Timer::getCollection()->count();
106106
$this->assertEquals($expected, $result);
107107

108108
$expected = true;
@@ -114,7 +114,7 @@ public function testStop() {
114114
$this->assertEquals($expected, $result);
115115

116116
$expected = 1;
117-
$result = Timer::$collection->count();
117+
$result = Timer::getCollection()->count();
118118
$this->assertEquals($expected, $result);
119119
}
120120

@@ -124,7 +124,7 @@ public function testStop() {
124124
* @covers \Xicrow\PhpDebug\Profiler::custom
125125
*/
126126
public function testCustom() {
127-
Timer::$collection->clear();
127+
Timer::getCollection()->clear();
128128

129129
$expected = true;
130130
$result = Timer::custom();
@@ -151,7 +151,7 @@ public function testCustom() {
151151
* @covers \Xicrow\PhpDebug\Profiler::callback
152152
*/
153153
public function testCallback() {
154-
Timer::$collection->clear();
154+
Timer::getCollection()->clear();
155155

156156
$expected = time();
157157
$result = Timer::callback(null, 'time');
@@ -210,7 +210,7 @@ public function testCallback() {
210210
* @covers \Xicrow\PhpDebug\Profiler::getStatsOneline
211211
*/
212212
public function testGetStats() {
213-
Timer::$collection->clear();
213+
Timer::getCollection()->clear();
214214

215215
$expected = 'Unknow item in with key: foo';
216216
$result = Timer::getStats('foo');
@@ -238,22 +238,22 @@ public function testGetStats() {
238238
* @covers \Xicrow\PhpDebug\Profiler::getStatsOneline
239239
*/
240240
public function testGetStatsOneline() {
241-
Timer::$collection->clear();
241+
Timer::getCollection()->clear();
242242

243243
$timerName = 'Foo';
244244
Timer::custom($timerName, 0.1, 0.2);
245245

246-
$result = Timer::getStatsOneline(Timer::$collection->get($timerName));
246+
$result = Timer::getStatsOneline(Timer::getCollection()->get($timerName));
247247
$this->assertContains($timerName, $result);
248248
$this->assertContains('100.0000 MS', $result);
249249

250-
$result = Timer::getStatsOneline(Timer::$collection->get($timerName), ['show_start_stop' => true]);
250+
$result = Timer::getStatsOneline(Timer::getCollection()->get($timerName), ['show_start_stop' => true]);
251251
$this->assertContains(date('Y-m-d H:i'), $result);
252252

253253
$timerName = 'Really, really, really, really, really, really, really, really, really, really, really, really, really long timer name';
254254
Timer::custom($timerName, 0.1, 0.2);
255255

256-
$result = Timer::getStatsOneline(Timer::$collection->get($timerName));
256+
$result = Timer::getStatsOneline(Timer::getCollection()->get($timerName));
257257
$this->assertContains(substr($timerName, -20), $result);
258258
$this->assertContains('100.0000 MS', $result);
259259
}
@@ -265,22 +265,22 @@ public function testGetStatsOneline() {
265265
* @covers \Xicrow\PhpDebug\Profiler::getStatsMultiline
266266
*/
267267
public function testGetStatsMultiline() {
268-
Timer::$collection->clear();
268+
Timer::getCollection()->clear();
269269

270270
$timerName = 'Foo';
271271
Timer::custom($timerName, 0.1, 0.2);
272272

273-
$result = Timer::getStatsMultiline(Timer::$collection->get($timerName));
273+
$result = Timer::getStatsMultiline(Timer::getCollection()->get($timerName));
274274
$this->assertContains($timerName, $result);
275275
$this->assertContains('100.0000 MS', $result);
276276

277-
$result = Timer::getStatsMultiline(Timer::$collection->get($timerName), ['show_start_stop' => true]);
277+
$result = Timer::getStatsMultiline(Timer::getCollection()->get($timerName), ['show_start_stop' => true]);
278278
$this->assertContains(date('Y-m-d H:i'), $result);
279279

280280
$timerName = 'Really, really, really, really, really, really, really, really, really, really, really, really, really long timer name';
281281
Timer::custom($timerName, 0.1, 0.2);
282282

283-
$result = Timer::getStatsMultiline(Timer::$collection->get($timerName));
283+
$result = Timer::getStatsMultiline(Timer::getCollection()->get($timerName));
284284
$this->assertContains($timerName, $result);
285285
$this->assertContains('100.0000 MS', $result);
286286
}
@@ -293,7 +293,7 @@ public function testGetStatsMultiline() {
293293
* @covers \Xicrow\PhpDebug\Profiler::getLastItemName
294294
*/
295295
public function testGetLastItemName() {
296-
Timer::$collection->clear();
296+
Timer::getCollection()->clear();
297297

298298
$expected = false;
299299
$result = Timer::getLastItemName();

0 commit comments

Comments
 (0)