Skip to content
This repository was archived by the owner on Apr 13, 2022. It is now read-only.

Commit 38c964d

Browse files
Added more ueful error feedback in the event trait
1 parent cd7f6cf commit 38c964d

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/EventTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,23 @@ public function testEventHasRegisteredHandlers()
6666
$class = get_class($this->getObjectAndParams()['object']);
6767
$mappings = $property->getValue(new $provider($this->app));
6868

69-
$this->assertTrue(isset($mappings[$class]));
69+
$this->assertTrue(isset($mappings[$class]), "Expected '{$class}' to exists as a key in the event mappings.");
7070

7171
$handlers = count($mappings[$class]);
7272

7373
if ($this->objectHasHandlers()) {
74-
$this->assertGreaterThan(0, $handlers);
74+
$this->assertGreaterThan(0, $handlers, "Expected '{$class}' to have at least 1 handler.");
7575
} else {
76-
$this->assertSame(0, $handlers);
76+
$this->assertSame(0, $handlers, "Expected '{$class}' to have at exactly 0 handlers.");
7777
}
7878

7979
foreach ($mappings[$class] as $handler) {
8080
$this->assertInstanceOf($handler, $this->app->make($handler));
8181
$params = (new ReflectionClass($handler))->getMethod('handle')->getParameters();
82-
$this->assertCount(1, $params);
83-
$this->assertFalse($params[0]->getType()->allowsNull());
82+
$this->assertCount(1, $params, "Expected '{$handler}::handle' to require exactly 1 argument.");
83+
$this->assertFalse($params[0]->getType()->allowsNull(), "Expected '{$handler}::handle' to require non-null arguments.");
8484
$type = (string) $params[0]->getType();
85-
$this->assertTrue($class === $type || (new ReflectionClass($class))->isSubclassOf($type));
85+
$this->assertTrue($class === $type || (new ReflectionClass($class))->isSubclassOf($type), "Expected '{$class}' to equal or subtype '{$type}' in '{$handler}::handle'.");
8686
}
8787
}
8888
}

0 commit comments

Comments
 (0)