diff --git a/tests/integration/api/CreatePollTest.php b/tests/integration/api/CreatePollTest.php index a0f7aa27..edcd1e6a 100644 --- a/tests/integration/api/CreatePollTest.php +++ b/tests/integration/api/CreatePollTest.php @@ -435,4 +435,45 @@ public function authorized_user_can_create_global_poll_on_api(int $userId) $this->assertTrue($json['data']['attributes']['isGlobal']); } + + /** + * @dataProvider unauthorizedUserProvider + * + * @test + */ + public function unauthorized_user_cannot_create_global_poll_on_api(int $userId) + { + $response = $this->send( + $this->request( + 'POST', + '/api/fof/polls', + [ + 'authenticatedAs' => $userId, + 'json' => [ + 'data' => [ + 'attributes' => [ + 'question' => 'Add a global poll', + 'publicPoll' => false, + 'hideVotes' => false, + 'allowChangeVote' => true, + 'allowMultipleVotes' => false, + 'maxVotes' => 0, + 'endDate' => false, + 'options' => [ + [ + 'answer' => 'Yes', + ], + [ + 'answer' => 'No', + ], + ], + ], + ], + ], + ] + ) + ); + + $this->assertEquals(403, $response->getStatusCode()); + } }