11<?php
22
3+ namespace Kevariable \SlackLogging \Tests ;
4+
5+ use Exception ;
36use Illuminate \Support \Facades \Log ;
47use Kevariable \SlackLogging \Facades \SlackLogging ;
8+ use PHPUnit \Framework \Attributes \Test ;
59
6- use function Pest \Laravel \get ;
10+ class LoggingTest extends TestCase
11+ {
12+ protected function setUp (): void
13+ {
14+ parent ::setUp ();
715
8- beforeEach (function () {
9- SlackLogging::fake ();
16+ SlackLogging::fake ();
1017
11- config ()->set ('logging.channels.slack.driver ' , 'slack-logging ' );
12- config ()->set ('logging.channels.stack.channels ' , ['single ' , 'slack ' ]);
13- config ()->set ('slack-logging.environments ' , ['testing ' ]);
14- });
18+ config ()->set ('logging.channels.slack.driver ' , 'slack-logging ' );
19+ config ()->set ('logging.channels.stack.channels ' , ['single ' , 'slack ' ]);
20+ config ()->set ('slack-logging.environments ' , ['testing ' ]);
21+ }
1522
16- it (description: 'will not send log information to slack ' )
17- ->defer (function (): void {
18- app ()['router ' ]->get ('/log-information-via-route/{type} ' , function (string $ type ) {
23+ #[Test]
24+ public function it_will_not_send_log_information_to_slack ()
25+ {
26+ $ this ->app ['router ' ]->get ('/log-information-via-route/{type} ' , function (string $ type ) {
1927 Log::{$ type }('log ' );
2028 });
2129
2836 $ this ->get ('/log-information-via-route/alert ' );
2937 $ this ->get ('/log-information-via-route/emergency ' );
3038
31- SlackLogging::assertRequestsSent (expectedCount: 0 );
32- });
39+ SlackLogging::assertRequestsSent (0 );
40+ }
3341
34- it (description: 'will send log information to slack ' )
35- ->defer (function (): void {
36- app ()['router ' ]->get ('/throwables-via-route ' , function () {
42+ #[Test]
43+ public function it_will_send_log_information_to_slack ()
44+ {
45+ $ this ->app ['router ' ]->get ('/throwables-via-route ' , function () {
3746 throw new Exception ('Sent to Slack Logging. ' );
3847 });
3948
40- get ('/throwables-via-route ' );
49+ $ this -> get ('/throwables-via-route ' );
4150
42- SlackLogging::assertRequestsSent (expectedCount: 1 );
43- });
51+ SlackLogging::assertRequestsSent (1 );
52+ }
53+ }
0 commit comments