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 29, 2023
1 parent d001417 commit dbfc46a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/Console/NotifySchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class NotifySchedule
* @var SettingsRepositoryInterface
*/
public $settings;

public function __construct(SettingsRepositoryInterface $settings)
{
$this->settings = $settings;
}

public function __invoke(Event $event)
{
$event->hourly()
Expand Down
1 change: 0 additions & 1 deletion src/Listeners/RecalculateBestAnswerCounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Flarum\Discussion\Event\Deleting as DiscussionDeleting;
use Flarum\Post\Event\Deleting as PostDeleting;
use Flarum\Post\Post;
use Flarum\User\User;
use FoF\BestAnswer\Events\BestAnswerSet;
use FoF\BestAnswer\Events\BestAnswerUnset;
use Illuminate\Contracts\Events\Dispatcher;
Expand Down
33 changes: 21 additions & 12 deletions tests/integration/api/BestAnswerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

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

namespace FoF\BestAnswer\tests\integration\api;

use Carbon\Carbon;
Expand All @@ -12,7 +21,7 @@
class BestAnswerTest extends TestCase
{
use RetrievesAuthorizedUsers;

public function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -59,7 +68,7 @@ public function default_answer_count_for_new_user_is_zero()
'GET',
'/api/users/2',
[
'authenticatedAs' => '1'
'authenticatedAs' => '1',
],
)
);
Expand All @@ -81,7 +90,7 @@ public function user_with_extising_best_answer_has_correct_count()
'GET',
'/api/users/1',
[
'authenticatedAs' => '2'
'authenticatedAs' => '2',
],
)
);
Expand All @@ -107,12 +116,12 @@ public function setting_best_answer_increases_author_best_answer_count()
'data' => [
'attributes' => [
'bestAnswerPostId' => 2,
'bestAnswerUserId' => 1
'bestAnswerUserId' => 1,
],
]
],

],
'authenticatedAs' => '1'
'authenticatedAs' => '1',
],
)
);
Expand Down Expand Up @@ -143,10 +152,10 @@ public function unsetting_best_answer_decreases_author_best_answer_count()
'attributes' => [
'bestAnswerPostId' => 0,
],
]
],

],
'authenticatedAs' => '1'
'authenticatedAs' => '1',
],
)
);
Expand All @@ -173,7 +182,7 @@ public function deleting_the_best_answer_post_in_a_discussion_reduces_author_bes
'/api/posts/6',
[
'authenticatedAs' => '1',
'json' => [],
'json' => [],
],
)
);
Expand Down Expand Up @@ -204,7 +213,7 @@ public function deleting_a_discussion_with_a_best_answer_reduces_author_best_ans
'/api/discussions/3',
[
'authenticatedAs' => '1',
'json' => [],
'json' => [],
],
)
);
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/best-answer.
*
* 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
25 changes: 17 additions & 8 deletions tests/unit/SaveBestAnswerToDatabaseTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

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

namespace FoF\BestAnswer\tests\unit;

use Flarum\Discussion\Discussion;
Expand Down Expand Up @@ -35,12 +44,12 @@ public function testHandle_WhenKeyIsMissing_ReturnsWithoutAction()
$event = m::mock(Saving::class);
$event->data = [];

$this->sut = m::mock(SaveBestAnswerToDatabase::class . '[removeBestAnswer,setBestAnswer]', [
$this->sut = m::mock(SaveBestAnswerToDatabase::class.'[removeBestAnswer,setBestAnswer]', [
m::mock(NotificationSyncer::class),
m::mock(Dispatcher::class),
m::mock(TranslatorInterface::class),
m::mock(BestAnswerRepository::class),
m::mock(SettingsRepositoryInterface::class)
m::mock(SettingsRepositoryInterface::class),
])->shouldAllowMockingProtectedMethods();

$this->sut->shouldNotReceive('removeBestAnswer');
Expand All @@ -59,12 +68,12 @@ public function testHandle_DiscussionDoesNotExistOrMatches_ReturnsWithoutAction(
$event->discussion->exists = false;
$event->discussion->best_answer_post_id = 1;

$this->sut = m::mock(SaveBestAnswerToDatabase::class . '[removeBestAnswer,setBestAnswer]', [
$this->sut = m::mock(SaveBestAnswerToDatabase::class.'[removeBestAnswer,setBestAnswer]', [
m::mock(NotificationSyncer::class),
m::mock(Dispatcher::class),
m::mock(TranslatorInterface::class),
m::mock(BestAnswerRepository::class),
m::mock(SettingsRepositoryInterface::class)
m::mock(SettingsRepositoryInterface::class),
])->shouldAllowMockingProtectedMethods();

$this->sut->shouldNotReceive('removeBestAnswer');
Expand All @@ -86,12 +95,12 @@ public function testHandle_IdIsZero_CallsRemoveBestAnswer()
$notifications = m::mock(NotificationSyncer::class);
$notifications->shouldReceive('delete')->with(m::type(SelectBestAnswerBlueprint::class))->once();

$this->sut = m::mock(SaveBestAnswerToDatabase::class . '[removeBestAnswer]', [
$this->sut = m::mock(SaveBestAnswerToDatabase::class.'[removeBestAnswer]', [
$notifications,
m::mock(Dispatcher::class),
m::mock(TranslatorInterface::class),
m::mock(BestAnswerRepository::class),
m::mock(SettingsRepositoryInterface::class)
m::mock(SettingsRepositoryInterface::class),
])->shouldAllowMockingProtectedMethods();

$this->sut->shouldReceive('removeBestAnswer')->once();
Expand All @@ -112,12 +121,12 @@ public function testHandle_IdIsNotZero_CallsSetBestAnswer()
$notifications = m::mock(NotificationSyncer::class);
$notifications->shouldReceive('delete')->with(m::type(SelectBestAnswerBlueprint::class))->once();

$this->sut = m::mock(SaveBestAnswerToDatabase::class . '[setBestAnswer]', [
$this->sut = m::mock(SaveBestAnswerToDatabase::class.'[setBestAnswer]', [
$notifications,
m::mock(Dispatcher::class),
m::mock(TranslatorInterface::class),
m::mock(BestAnswerRepository::class),
m::mock(SettingsRepositoryInterface::class)
m::mock(SettingsRepositoryInterface::class),
])->shouldAllowMockingProtectedMethods();

$this->sut->shouldReceive('setBestAnswer')->once();
Expand Down

0 comments on commit dbfc46a

Please sign in to comment.