Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Jan 31, 2024
1 parent 822ddbf commit 325cc32
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/Api/Serializers/PollSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FoF\Polls\Api\Serializers;

use Flarum\Api\Serializer\AbstractSerializer;
use Flarum\Api\Serializer\PostSerializer;
use FoF\Polls\Poll;

class PollSerializer extends AbstractSerializer
Expand Down
65 changes: 38 additions & 27 deletions tests/integration/api/CreatePollTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of fof/polls.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FoF\Polls\Tests\integration\api;

use Flarum\Testing\integration\RetrievesAuthorizedUsers;
Expand All @@ -19,7 +28,7 @@ public function setUp(): void
$this->prepareDatabase([
'users' => [
$this->normalUser(),
['id' => 3, 'username' => 'polluser', 'email' => '[email protected]', 'password' => 'too-obscure', 'is_email_confirmed' => true]
['id' => 3, 'username' => 'polluser', 'email' => '[email protected]', 'password' => 'too-obscure', 'is_email_confirmed' => true],
],
'discussions' => [
['id' => 1, 'title' => 'Discussion 1', 'comment_count' => 1, 'participant_count' => 1, 'created_at' => '2021-01-01 00:00:00'],
Expand All @@ -40,7 +49,7 @@ private function authorizedUserProvider(): array
{
return [
[1],
[3]
[3],
];
}

Expand All @@ -53,6 +62,7 @@ private function unauthorizedUserProvider(): array

/**
* @dataProvider authorizedUserProvider
*
* @test
*/
public function authorized_user_can_create_poll_in_post(int $userId)
Expand All @@ -63,19 +73,19 @@ public function authorized_user_can_create_poll_in_post(int $userId)
'/api/posts',
[
'authenticatedAs' => $userId,
'json' => [
'json' => [
'data' => [
'attributes' => [
'content' => 'Here is my poll',
'poll' => [
'question' => 'What is your favourite colour?',
'publicPoll' => false,
'hideVotes' => false,
'allowChangeVote' => true,
'poll' => [
'question' => 'What is your favourite colour?',
'publicPoll' => false,
'hideVotes' => false,
'allowChangeVote' => true,
'allowMultipleVotes' => false,
'maxVotes' => 0,
'endDate' => false,
'options' => [
'maxVotes' => 0,
'endDate' => false,
'options' => [
[
'answer' => 'Red',
],
Expand All @@ -92,11 +102,11 @@ public function authorized_user_can_create_poll_in_post(int $userId)
'discussion' => [
'data' => [
'type' => 'discussions',
'id' => 1,
'id' => 1,
],
],
]
]
],
],
],
]
)
Expand All @@ -121,7 +131,7 @@ public function authorized_user_can_create_poll_in_post(int $userId)
$response = $this->send(
$this->request(
'GET',
'/api/fof/polls/' . $pollId,
'/api/fof/polls/'.$pollId,
[
'authenticatedAs' => $userId,
]
Expand All @@ -137,6 +147,7 @@ public function authorized_user_can_create_poll_in_post(int $userId)

/**
* @dataProvider unauthorizedUserProvider
*
* @test
*/
public function unauthorized_user_cannot_create_poll_in_post(int $userId)
Expand All @@ -147,19 +158,19 @@ public function unauthorized_user_cannot_create_poll_in_post(int $userId)
'/api/posts',
[
'authenticatedAs' => $userId,
'json' => [
'json' => [
'data' => [
'attributes' => [
'content' => 'Here is my poll',
'poll' => [
'question' => 'What is your favourite colour?',
'publicPoll' => false,
'hideVotes' => false,
'allowChangeVote' => true,
'poll' => [
'question' => 'What is your favourite colour?',
'publicPoll' => false,
'hideVotes' => false,
'allowChangeVote' => true,
'allowMultipleVotes' => false,
'maxVotes' => 0,
'endDate' => false,
'options' => [
'maxVotes' => 0,
'endDate' => false,
'options' => [
[
'answer' => 'Red',
],
Expand All @@ -176,11 +187,11 @@ public function unauthorized_user_cannot_create_poll_in_post(int $userId)
'discussion' => [
'data' => [
'type' => 'discussions',
'id' => 1,
'id' => 1,
],
],
]
]
],
],
],
]
)
Expand Down

0 comments on commit 325cc32

Please sign in to comment.