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 Oct 21, 2023
1 parent 55f56f6 commit 7940e3a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
9 changes: 9 additions & 0 deletions tests/integration/api/ForumTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

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

namespace FoF\Reactions\tests\integration\api;

use Flarum\Testing\integration\TestCase;
Expand Down
37 changes: 24 additions & 13 deletions tests/integration/api/ReactTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

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

namespace FoF\Reactions\tests\integration\api;

use Carbon\Carbon;
Expand All @@ -10,7 +19,7 @@
class ReactTest extends TestCase
{
use RetrievesAuthorizedUsers;

public function setUp(): void
{
parent::setUp();
Expand All @@ -37,15 +46,16 @@ public function setUp(): void

/**
* @dataProvider allowedUsersToReact
*
* @test
*/
public function can_react_to_a_post_if_allowed(int $postId, ?int $authenticatedAs, int $reactionId, string $message, bool $canReactOwnPost = null, bool $guestReactionsEnabled = null)
{
if (! is_null($canReactOwnPost)) {
if (!is_null($canReactOwnPost)) {
$this->setting('fof-reactions.react_own_post', $canReactOwnPost);
}

if (! is_null($guestReactionsEnabled)) {
if (!is_null($guestReactionsEnabled)) {
$this->setting('fof-reactions.anonymousReactions', $guestReactionsEnabled);
}

Expand All @@ -59,15 +69,16 @@ public function can_react_to_a_post_if_allowed(int $postId, ?int $authenticatedA

/**
* @dataProvider unallowedUsersToReact
*
* @test
*/
public function cannot_react_to_a_post_if_not_allowed(int $postId, ?int $authenticatedAs, int $reactionId, string $message, bool $canReactOwnPost = null, bool $guestReactionsEnabled = null)
{
if (! is_null($canReactOwnPost)) {
if (!is_null($canReactOwnPost)) {
$this->setting('fof-reactions.react_own_post', $canReactOwnPost);
}

if (! is_null($guestReactionsEnabled)) {
if (!is_null($guestReactionsEnabled)) {
$this->setting('fof-reactions.anonymousReactions', $guestReactionsEnabled);
}

Expand Down Expand Up @@ -105,7 +116,7 @@ public function unallowedUsersToReact(): array

protected function sendReactRequest(int $postId, int $reactionId, ?int $authenticatedAs = null): ResponseInterface
{
if (! isset($authenticatedAs)) {
if (!isset($authenticatedAs)) {
$initial = $this->send(
$this->request('GET', '/')
);
Expand All @@ -115,17 +126,17 @@ protected function sendReactRequest(int $postId, int $reactionId, ?int $authenti

$request = $this->request('PATCH', "/api/posts/$postId", [
'authenticatedAs' => $authenticatedAs,
'cookiesFrom' => $initial ?? null,
'json' => [
'cookiesFrom' => $initial ?? null,
'json' => [
'data' => [
'attributes' => [
'reaction' => $reactionId
]
]
]
'reaction' => $reactionId,
],
],
],
]);

if (! isset($authenticatedAs)) {
if (!isset($authenticatedAs)) {
$request = $request->withHeader('X-CSRF-Token', $token);
}

Expand Down
8 changes: 5 additions & 3 deletions tests/integration/setup.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

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

use Flarum\Testing\integration\Setup\SetupScript;
Expand Down

0 comments on commit 7940e3a

Please sign in to comment.