1616use Nipwaayoni \Tests \SnsHandler \Events \SnsMessageBetaReceived ;
1717use Nipwaayoni \Tests \SnsHandler \MakesSnsTests ;
1818
19- class SnsHandlerTest extends \Nipwaayoni \Tests \SnsHandler \TestCase
19+ class SnsHandlerMappedEventsTest extends \Nipwaayoni \Tests \SnsHandler \TestCase
2020{
2121 use MakesSnsTests;
2222
@@ -38,31 +38,13 @@ protected function getEnvironmentSetUp($app)
3838 {
3939 $ app ['config ' ]->set ('sns-handler.confirmation-events ' , [
4040 SnsConfirmationRequestAlphaReceived::class => ['arn:aws:sns:us-west-2:123456789012:AlphaTopic ' ],
41- SnsConfirmationRequestReceived::class => ['* ' ],
4241 ]);
4342
4443 $ app ['config ' ]->set ('sns-handler.message-events ' , [
4544 SnsMessageAlphaReceived::class => ['arn:aws:sns:us-west-2:123456789012:AlphaTopic ' ],
46- SnsMessageReceived::class => ['* ' ],
4745 ]);
4846 }
4947
50- public function testDispatchesDefaultConfirmationEvent (): void
51- {
52- $ data = $ this ->makeSnsMessageData ([
53- 'Type ' => SnsMessage::SUBSCRIBE_TYPE ,
54- 'Message ' => json_encode (['id ' => 123 , 'color ' => 'red ' ], true ),
55- 'SubscribeURL ' => 'https://aws.amazon.com/sns/register/abc123 '
56- ]);
57-
58- $ response = $ this ->postJson ('/api/sns/message ' , $ data );
59-
60- $ this ->assertEquals (200 , $ response ->status ());
61- Event::assertDispatched (SnsConfirmationRequestReceived::class);
62- Event::assertNotDispatched (SnsConfirmationRequestAlphaReceived::class);
63- Event::assertNotDispatched (SnsConfirmationRequestBetaReceived::class);
64- }
65-
6648 public function testDispatchesMappedConfirmationEvent (): void
6749 {
6850 $ data = $ this ->makeSnsMessageData ([
@@ -79,34 +61,34 @@ public function testDispatchesMappedConfirmationEvent(): void
7961 Event::assertNotDispatched (SnsConfirmationRequestReceived::class);
8062 }
8163
82- public function testDispatchesDefaultMessageEvent (): void
64+ public function testDispatchesMappedMessageEvent (): void
8365 {
8466 $ data = $ this ->makeSnsMessageData ([
8567 'Type ' => SnsMessage::NOTIFICATION_TYPE ,
86- 'TopicArn ' => 'arn:aws:sns:us-west-2:123456789012:MyTopic ' ,
68+ 'TopicArn ' => 'arn:aws:sns:us-west-2:123456789012:AlphaTopic ' ,
8769 'Message ' => 'Test message ' ,
8870 ]);
8971
9072 $ response = $ this ->postJson ('/api/sns/message ' , $ data );
9173
9274 $ this ->assertEquals (200 , $ response ->status ());
93- Event::assertDispatched (SnsMessageReceived ::class);
94- Event::assertNotDispatched (SnsMessageAlphaReceived ::class);
75+ Event::assertDispatched (SnsMessageAlphaReceived ::class);
76+ Event::assertNotDispatched (SnsMessageReceived ::class);
9577 Event::assertNotDispatched (SnsMessageBetaReceived::class);
9678 }
9779
98- public function testDispatchesMappedMessageEvent (): void
80+ public function testReturnsNotFoundForUnmappedMessageEvent (): void
9981 {
10082 $ data = $ this ->makeSnsMessageData ([
10183 'Type ' => SnsMessage::NOTIFICATION_TYPE ,
102- 'TopicArn ' => 'arn:aws:sns:us-west-2:123456789012:AlphaTopic ' ,
84+ 'TopicArn ' => 'arn:aws:sns:us-west-2:123456789012:BetaTopic ' ,
10385 'Message ' => 'Test message ' ,
10486 ]);
10587
10688 $ response = $ this ->postJson ('/api/sns/message ' , $ data );
10789
108- $ this ->assertEquals (200 , $ response ->status ());
109- Event::assertDispatched (SnsMessageAlphaReceived::class);
90+ $ this ->assertEquals (404 , $ response ->status ());
91+ Event::assertNotDispatched (SnsMessageAlphaReceived::class);
11092 Event::assertNotDispatched (SnsMessageReceived::class);
11193 Event::assertNotDispatched (SnsMessageBetaReceived::class);
11294 }
0 commit comments