|
11 | 11 |
|
12 | 12 | use Framework\Debug\Collection; |
13 | 13 | use Framework\Debug\Debugger; |
| 14 | +use LogicException; |
14 | 15 | use PHPUnit\Framework\TestCase; |
15 | 16 |
|
16 | 17 | final class DebuggerTest extends TestCase |
@@ -216,6 +217,39 @@ public function testActivitiesDivisionByZero() : void |
216 | 217 | self::assertStringContainsString('1 activity', $debugbar); |
217 | 218 | } |
218 | 219 |
|
| 220 | + public function testActivitiesWithoutStartKey() : void |
| 221 | + { |
| 222 | + $collector = new CollectorMock(); |
| 223 | + $this->debugger->addCollector($collector, 'Foo'); |
| 224 | + $collector->activities = [ |
| 225 | + [ |
| 226 | + 'collector' => 'default', |
| 227 | + 'class' => 'Class name', |
| 228 | + 'description' => 'Collected data 1', |
| 229 | + ], |
| 230 | + ]; |
| 231 | + $this->expectException(LogicException::class); |
| 232 | + $this->expectExceptionMessage('An activity does not have the "start" key'); |
| 233 | + $this->debugger->getActivities(); |
| 234 | + } |
| 235 | + |
| 236 | + public function testActivitiesWithoutEndKey() : void |
| 237 | + { |
| 238 | + $collector = new CollectorMock(); |
| 239 | + $this->debugger->addCollector($collector, 'Foo'); |
| 240 | + $collector->activities = [ |
| 241 | + [ |
| 242 | + 'collector' => 'default', |
| 243 | + 'class' => 'Class name', |
| 244 | + 'description' => 'Collected data 1', |
| 245 | + 'start' => \microtime(), |
| 246 | + ], |
| 247 | + ]; |
| 248 | + $this->expectException(LogicException::class); |
| 249 | + $this->expectExceptionMessage('An activity does not have the "end" key'); |
| 250 | + $this->debugger->getActivities(); |
| 251 | + } |
| 252 | + |
219 | 253 | public function testOptions() : void |
220 | 254 | { |
221 | 255 | self::assertEmpty($this->debugger->getOptions()); |
@@ -269,7 +303,7 @@ public function testInvalidIconPathOption() : void |
269 | 303 | $this->debugger->setOption('icon_path', $iconPath); |
270 | 304 | try { |
271 | 305 | $this->debugger->renderDebugbar(); |
272 | | - } catch (\LogicException $e) { |
| 306 | + } catch (LogicException $e) { |
273 | 307 | self::assertSame( |
274 | 308 | 'Icon not found: ' . $iconPath, |
275 | 309 | $e->getMessage() |
|
0 commit comments