diff --git a/src/PersonalRecentVisitsWidget.php b/src/PersonalRecentVisitsWidget.php index 8e09292..2724dca 100644 --- a/src/PersonalRecentVisitsWidget.php +++ b/src/PersonalRecentVisitsWidget.php @@ -4,9 +4,7 @@ use Illuminate\Contracts\Auth\Access\Authorizable; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Collection; use Kontenta\Kontour\Contracts\PersonalRecentVisitsWidget as PersonalRecentVisitsWidgetContract; -use Kontenta\Kontour\Contracts\AdminLink; class PersonalRecentVisitsWidget implements PersonalRecentVisitsWidgetContract { @@ -19,9 +17,9 @@ public function __construct(RecentVisitsRepository $repository) public function toHtml() { - return ''; + return ''; } public function isAuthorized(Authorizable $user = null): bool @@ -31,7 +29,7 @@ public function isAuthorized(Authorizable $user = null): bool private function getVisits() { - return $this->repository->getShowVisits()->merge($this->repository->getEditVisits())->filter(function($visit) { + return $this->repository->getShowVisits()->merge($this->repository->getEditVisits())->filter(function ($visit) { return $visit->getUser()->is(Auth::guard(config('kontour.guard'))->user()); })->unique(function ($visit) { return $visit->getLink()->getUrl(); diff --git a/src/TeamRecentVisitsWidget.php b/src/TeamRecentVisitsWidget.php index e471cb1..89258a4 100644 --- a/src/TeamRecentVisitsWidget.php +++ b/src/TeamRecentVisitsWidget.php @@ -4,9 +4,7 @@ use Illuminate\Contracts\Auth\Access\Authorizable; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Collection; use Kontenta\Kontour\Contracts\TeamRecentVisitsWidget as TeamRecentVisitsWidgetContract; -use Kontenta\Kontour\Contracts\AdminLink; class TeamRecentVisitsWidget implements TeamRecentVisitsWidgetContract { @@ -19,9 +17,9 @@ public function __construct(RecentVisitsRepository $repository) public function toHtml() { - return ''; + return ''; } public function isAuthorized(Authorizable $user = null): bool @@ -31,7 +29,7 @@ public function isAuthorized(Authorizable $user = null): bool private function getVisits() { - return $this->repository->getEditVisits()->filter(function($visit) { + return $this->repository->getEditVisits()->filter(function ($visit) { return !$visit->getUser()->is(Auth::guard(config('kontour.guard'))->user()); })->unique(function ($visit) { return $visit->getLink()->getUrl(); diff --git a/tests/Feature/UserlandControllerTest.php b/tests/Feature/UserlandControllerTest.php index b756474..0ad4951 100644 --- a/tests/Feature/UserlandControllerTest.php +++ b/tests/Feature/UserlandControllerTest.php @@ -3,11 +3,11 @@ namespace Kontenta\KontourSupport\Tests\Feature; use Illuminate\Support\Facades\Event; -use Kontenta\KontourSupport\Tests\UserlandAdminToolTest; -use Kontenta\KontourSupport\Tests\Feature\Fakes\User; -use Kontenta\Kontour\Events\AdminToolVisited; use Kontenta\KontourSupport\AdminLink; +use Kontenta\KontourSupport\Tests\Feature\Fakes\User; +use Kontenta\KontourSupport\Tests\UserlandAdminToolTest; use Kontenta\Kontour\EditAdminVisit; +use Kontenta\Kontour\Events\AdminToolVisited; use Kontenta\Kontour\ShowAdminVisit; class UserlandControllerTest extends UserlandAdminToolTest @@ -33,13 +33,13 @@ public function test_index_route() $response->assertSee('assertSee('UserlandAdminWidget'); $response->assertDontSee('UnauthorizedWidget'); - $response->assertSee('Userland Tool'); + $response->assertSee('Userland Tool'); $response->assertSee('>main<'); - Event::assertDispatched(AdminToolVisited::class, function($e) { + Event::assertDispatched(AdminToolVisited::class, function ($e) { $now = new \DateTimeImmutable(); return $e->visit->getLink()->getUrl() == route('userland.index') and - $this->user->is($e->visit->getUser()) and - $now->getTimestamp() - $e->visit->getDateTime()->getTimestamp() >= 0; + $this->user->is($e->visit->getUser()) and + $now->getTimestamp() - $e->visit->getDateTime()->getTimestamp() >= 0; }); } @@ -63,16 +63,16 @@ public function test_recent_visits_widgets() $response->assertOk(); // Check personal links - $numberOfMatches = substr_count($response->content(), '
  • Recent Userland Tool'); + $numberOfMatches = substr_count($response->content(), '
  • Recent Userland Tool'); $this->assertEquals(1, $numberOfMatches); - $numberOfMatches = substr_count($response->content(), '
  • Recent Userland Tool'); + $numberOfMatches = substr_count($response->content(), '
  • Recent Userland Tool'); $this->assertEquals(1, $numberOfMatches); // Check team links - $numberOfMatches = substr_count($response->content(), '
  • Other Recent Userland Tool'); + $numberOfMatches = substr_count($response->content(), '
  • Other Recent Userland Tool'); $this->assertEquals(1, $numberOfMatches); - $response->assertDontSee('Other Recent Userland Tool'); + $response->assertDontSee('Other Recent Userland Tool'); } }