@@ -547,6 +547,46 @@ public function test_subscribe_invalid_endpoint(string $endpoint): void
547547 $ this ->controller ->subscribe ($ symfony_request );
548548 }
549549
550+ public function data_subscribe_missing_endpoint (): array
551+ {
552+ return [
553+ 'missing_endpoint ' => [[
554+ 'expiration_time ' => 0 ,
555+ 'keys ' => ['p256dh ' => 'test_p256dh ' , 'auth ' => 'test_auth ' ],
556+ ]],
557+ 'null_endpoint ' => [[
558+ 'endpoint ' => null ,
559+ 'expiration_time ' => 0 ,
560+ 'keys ' => ['p256dh ' => 'test_p256dh ' , 'auth ' => 'test_auth ' ],
561+ ]],
562+ 'array_endpoint ' => [[
563+ 'endpoint ' => ['https://fcm.googleapis.com/fcm/send/test_endpoint ' ],
564+ 'expiration_time ' => 0 ,
565+ 'keys ' => ['p256dh ' => 'test_p256dh ' , 'auth ' => 'test_auth ' ],
566+ ]],
567+ ];
568+ }
569+
570+ /**
571+ * @dataProvider data_subscribe_missing_endpoint
572+ */
573+ public function test_subscribe_missing_endpoint (array $ payload ): void
574+ {
575+ $ this ->form_helper ->method ('check_form_tokens ' )->willReturn (true );
576+ $ this ->request ->method ('is_ajax ' )->willReturn (true );
577+ $ this ->user ->data ['user_id ' ] = 2 ;
578+ $ this ->user ->data ['is_bot ' ] = false ;
579+ $ this ->user ->data ['user_type ' ] = USER_NORMAL ;
580+
581+ $ symfony_request = $ this ->createMock (\phpbb \symfony_request::class);
582+ $ symfony_request ->method ('get ' )->willReturn (json_encode ($ payload ));
583+
584+ $ this ->expectException (http_exception::class);
585+ $ this ->expectExceptionMessage ('WEBPUSH_INVALID_ENDPOINT ' );
586+
587+ $ this ->controller ->subscribe ($ symfony_request );
588+ }
589+
550590 public function data_is_valid_endpoint (): array
551591 {
552592 return [
0 commit comments