File: D:/HostingSpaces/SBogers95/rentman.io/vendor/sentry/sentry-laravel/test/Sentry/EventHandlerTest.php
<?php
namespace Sentry\Laravel\Tests;
use ReflectionClass;
use Sentry\Laravel\EventHandler;
use Orchestra\Testbench\TestCase;
class EventHandlerTest extends TestCase
{
/**
* @expectedException \RuntimeException
*/
public function test_missing_event_handler_throws_exception()
{
$handler = new EventHandler($this->app->events, []);
$handler->thisIsNotAHandlerAndShouldThrowAnException();
}
public function test_all_mapped_event_handlers_exist()
{
$this->tryAllEventHandlerMethods(
$this->getStaticPropertyValueFromClass(EventHandler::class, 'eventHandlerMap')
);
}
public function test_all_mapped_auth_event_handlers_exist()
{
$this->tryAllEventHandlerMethods(
$this->getStaticPropertyValueFromClass(EventHandler::class, 'authEventHandlerMap')
);
}
public function test_all_mapped_queue_event_handlers_exist()
{
$this->tryAllEventHandlerMethods(
$this->getStaticPropertyValueFromClass(EventHandler::class, 'queueEventHandlerMap')
);
}
private function tryAllEventHandlerMethods(array $methods): void
{
$handler = new EventHandler($this->app->events, []);
$methods = array_map(static function ($method) {
return "{$method}Handler";
}, array_unique(array_values($methods)));
foreach ($methods as $handlerMethod) {
$this->assertTrue(method_exists($handler, $handlerMethod));
}
}
private function getStaticPropertyValueFromClass($className, $attributeName)
{
$class = new ReflectionClass($className);
$attributes = $class->getStaticProperties();
return $attributes[$attributeName];
}
}