Skip to content

Commit d7d1796

Browse files
author
Ahmed Raafat
committed
Update the format of __string format for the StopwatchEvent
1 parent 7eccd04 commit d7d1796

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Symfony/Component/Stopwatch/StopwatchEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,6 @@ public function getName(): string
256256
*/
257257
public function __toString()
258258
{
259-
return sprintf('%s: %.2F MiB - %d ms', $this->getName(), $this->getMemory() / 1024 / 1024, $this->getDuration());
259+
return sprintf('%s/%s: %.2F MiB - %d ms', $this->getCategory(), $this->getName(), $this->getMemory() / 1024 / 1024, $this->getDuration());
260260
}
261261
}

src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,24 +193,24 @@ public function testStartTimeWhenStartedLater()
193193
public function testHumanRepresentation()
194194
{
195195
$event = new StopwatchEvent(microtime(true) * 1000);
196-
$this->assertEquals('default: 0.00 MiB - 0 ms', (string) $event);
196+
$this->assertEquals('default/default: 0.00 MiB - 0 ms', (string) $event);
197197
$event->start();
198198
$event->stop();
199199
$this->assertEquals(1, preg_match('/default: [0-9\.]+ MiB - [0-9]+ ms/', (string) $event));
200200

201201
$event = new StopwatchEvent(microtime(true) * 1000, 'foo');
202-
$this->assertEquals('default: 0.00 MiB - 0 ms', (string) $event);
202+
$this->assertEquals('foo/default: 0.00 MiB - 0 ms', (string) $event);
203203

204204
$event = new StopwatchEvent(microtime(true) * 1000, 'foo', false, 'name');
205-
$this->assertEquals('name: 0.00 MiB - 0 ms', (string) $event);
205+
$this->assertEquals('foo/name: 0.00 MiB - 0 ms', (string) $event);
206206
}
207207

208208
public function testGetName()
209209
{
210210
$event = new StopwatchEvent(microtime(true) * 1000);
211211
$this->assertEquals('default', $event->getName());
212212

213-
$event = new StopwatchEvent(microtime(true) * 1000, 'cat', false, 'test');
214-
$this->assertEquals('test', $event->getName());
213+
$event = new StopwatchEvent(microtime(true) * 1000, 'cat', false, 'name');
214+
$this->assertEquals('name', $event->getName());
215215
}
216216
}

0 commit comments

Comments
 (0)