2
2
3
3
namespace Sentry \Features ;
4
4
5
+ use DateTimeZone ;
5
6
use Illuminate \Console \Scheduling \Schedule ;
6
7
use RuntimeException ;
7
8
use Sentry \Laravel \Tests \TestCase ;
@@ -27,6 +28,34 @@ public function testScheduleMacro(): void
27
28
$ this ->assertEquals ('test-monitor ' , $ finishCheckInEvent ->getCheckIn ()->getMonitorSlug ());
28
29
}
29
30
31
+ /**
32
+ * When a timezone was defined on a command this would fail with:
33
+ * Sentry\MonitorConfig::__construct(): Argument #4 ($timezone) must be of type ?string, DateTimeZone given
34
+ * This test ensures that the timezone is properly converted to a string as expected.
35
+ */
36
+ public function testScheduleMacroWithTimeZone (): void
37
+ {
38
+ $ expectedTimezone = 'UTC ' ;
39
+
40
+ /** @var Event $scheduledEvent */
41
+ $ scheduledEvent = $ this ->getScheduler ()
42
+ ->call (function () {})
43
+ ->timezone (new DateTimeZone ($ expectedTimezone ))
44
+ ->sentryMonitor ('test-timezone-monitor ' );
45
+
46
+ $ scheduledEvent ->run ($ this ->app );
47
+
48
+ // We expect a total of 2 events to be sent to Sentry:
49
+ // 1. The start check-in event
50
+ // 2. The finish check-in event
51
+ $ this ->assertEquals (2 , $ this ->getEventsCount ());
52
+
53
+ $ finishCheckInEvent = $ this ->getLastEvent ();
54
+
55
+ $ this ->assertNotNull ($ finishCheckInEvent ->getCheckIn ());
56
+ $ this ->assertEquals ($ expectedTimezone , $ finishCheckInEvent ->getCheckIn ()->getMonitorConfig ()->getTimezone ());
57
+ }
58
+
30
59
public function testScheduleMacroAutomaticSlug (): void
31
60
{
32
61
/** @var Event $scheduledEvent */
0 commit comments