@@ 50-67 (lines=18) @@ | ||
47 | } |
|
48 | ||
49 | /** @test */ |
|
50 | function route_notification_for_mail_custom() { |
|
51 | /* @var $host Host */ |
|
52 | $host = $this->notifiable->getEvent()->check->host()->first(); |
|
53 | $notifications = [ |
|
54 | 'TheCodingMachine\ServerMonitorPluginNotificationByHost\TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckSucceeded' => |
|
55 | [ |
|
56 | 'channels' => ['mail'] |
|
57 | ], |
|
58 | 'configuration' => ['mail' => [ 'to' => ['[email protected]'] ]] |
|
59 | ]; |
|
60 | ||
61 | $host->setCustomProperty('notifications', $notifications); |
|
62 | ||
63 | $host->save(); |
|
64 | ||
65 | $mail = $this->notifiable->routeNotificationForMail(); |
|
66 | $this->assertSame('[email protected]', $mail[0]); |
|
67 | } |
|
68 | ||
69 | /** @test */ |
|
70 | function route_notification_no_custom_data() { |
|
@@ 70-87 (lines=18) @@ | ||
67 | } |
|
68 | ||
69 | /** @test */ |
|
70 | function route_notification_no_custom_data() { |
|
71 | /* @var $host Host */ |
|
72 | $host = $this->notifiable->getEvent()->check->host()->first(); |
|
73 | $notifications = [ |
|
74 | 'TheCodingMachine\ServerMonitorPluginNotificationByHost\TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckFailed' => |
|
75 | [ |
|
76 | 'channels' => ['slack'] |
|
77 | ], |
|
78 | 'configuration' => ['slack' => [ 'webhook' => ['urlSlack'] ]] |
|
79 | ]; |
|
80 | ||
81 | $host->setCustomProperty('notifications', $notifications); |
|
82 | ||
83 | $host->save(); |
|
84 | ||
85 | $mail = $this->notifiable->routeNotificationForMail(); |
|
86 | $this->assertSame('[email protected]', $mail[0]); |
|
87 | } |
|
88 | ||
89 | /** @test */ |
|
90 | function route_notification_for_mail_custom_array() { |
|
@@ 118-135 (lines=18) @@ | ||
115 | } |
|
116 | ||
117 | /** @test */ |
|
118 | function route_notification_for_slack_custom() { |
|
119 | /* @var $host Host */ |
|
120 | $host = $this->notifiable->getEvent()->check->host()->first(); |
|
121 | $notifications = [ |
|
122 | 'TheCodingMachine\ServerMonitorPluginNotificationByHost\Test\TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckSucceeded' => |
|
123 | [ |
|
124 | 'channels' => ['slack'] |
|
125 | ], |
|
126 | 'configuration' => ['slack' => [ 'webhook_url' => 'urlSlack' ]] |
|
127 | ]; |
|
128 | ||
129 | $host->setCustomProperty('notifications', $notifications); |
|
130 | ||
131 | $host->save(); |
|
132 | ||
133 | $slack = $this->notifiable->routeNotificationForSlack(); |
|
134 | $this->assertSame('urlSlack', $slack); |
|
135 | } |
|
136 | } |
|
137 |