Commit 3bd86fb8 authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

Fix code styles and tests

parent 4e0f1ee0
......@@ -5,19 +5,19 @@ namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;
use Source\UseCases\Doors\GetDoor\GetDoorUseCase;
use Source\UseCases\Doors\GetDoors\GetDoorsUseCase;
use Source\UseCases\Doors\CreateDoor\CreateDoorUseCase;
use Source\UseCases\Doors\DeleteDoor\DeleteDoorUseCase;
use Source\UseCases\Doors\UpdateDoor\UpdateDoorUseCase;
use Source\UseCases\Doors\GetDoors\GetDoorsUseCase;
use Source\UseCases\DoorGroup\GetDoorGroups\GetDoorGroupsUseCase;
use Source\UseCases\DoorGroup\AddDoorToGroup\AddDoorToGroupUseCase;
use Source\UseCases\Doors\GenerateDoorToken\GenerateDoorTokenUseCase;
use Source\UseCases\Doors\GetDoor\APIPresenter as GetDoorAPIPresenter;
use Source\UseCases\Doors\GetDoors\APIPresenter as GetAllDoorsAPIPresenter;
use Source\UseCases\Doors\CreateDoor\APIPresenter as CreateDoorAPIPresenter;
use Source\UseCases\Doors\DeleteDoor\APIPresenter as DeleteDoorAPIPresenter;
use Source\UseCases\Doors\UpdateDoor\APIPresenter as UpdateDoorAPIPresenter;
use Source\UseCases\DoorGroup\RemoveDoorFromGroup\RemoveDoorFromGroupUseCase;
use Source\UseCases\Doors\GetDoors\APIPresenter as GetAllDoorsAPIPresenter;
use Source\UseCases\DoorGroup\GetDoorGroups\APIPresenter as GetDoorGroupsAPIPresenter;
use Source\UseCases\DoorGroup\AddDoorToGroup\APIPresenter as AddDoorToGroupAPIPresenter;
use Source\UseCases\DoorGroup\RemoveDoorFromGroup\APIPresenter as RemoveDoorFromGroupAPIPresenter;
......
......@@ -31,8 +31,8 @@ use Source\UseCases\Users\CreateUser\CreateUserUseCaseServiceProvider;
use Source\UseCases\Users\DeleteUser\DeleteUserUseCaseServiceProvider;
use Source\UseCases\Users\UpdateUser\UpdateUserUseCaseServiceProvider;
use Source\Gateways\DoorSchedule\DoorScheduleRepositoryServiceProvider;
use Source\UseCases\Users\GetAllUsers\GetAllUsersUseCaseServiceProvider;
use Source\UseCases\Entries\GetEntries\GetEntriesUseCaseServiceProvider;
use Source\UseCases\Users\GetAllUsers\GetAllUsersUseCaseServiceProvider;
use Source\Gateways\RecurrenceSet\RecurrenceSetRepositoryServiceProvider;
use Source\UseCases\Door\UpdateBinary\UpdateBinaryUseCaseServiceProvider;
use Source\UseCases\Groups\CreateGroup\CreateGroupUseCaseServiceProvider;
......
......@@ -107,7 +107,7 @@ class DatabaseDoorsRepository implements DoorsRepository
public function query(?string $query = null): array
{
$doors = [];
if (!$query) {
if (!$query) {
$doors = \App\Door::all()->values()->all();
} else {
$doors = \App\Door::query()
......
......@@ -61,9 +61,9 @@ class DatabaseEntriesRepository implements EntriesRepository
if ($begin && $end) {
$query->whereBetween('created_at', [$begin, $end]);
} else if ($begin) {
} elseif ($begin) {
$query->where('created_at', '>', $begin);
} else if ($end) {
} elseif ($end) {
$query->where('created_at', '<', $end);
}
......
......@@ -2,12 +2,9 @@
namespace Source\UseCases\Entries\GetEntries;
use Carbon\Carbon;
use Source\Sanitize\CastsTo;
use Source\UseCases\Entries\Presenter;
use Source\Gateways\Users\UsersRepository;
use Source\UseCases\Entries\ResponseModel;
use Source\Exceptions\EntityNotFoundException;
use Source\Gateways\Entries\EntriesRepository;
class GetEntries implements GetEntriesUseCase
......
......@@ -4,7 +4,6 @@
namespace Source\UseCases\Entries\GetEntries;
use Illuminate\Support\ServiceProvider;
use Source\Gateways\Users\UsersRepository;
use Source\Gateways\Entries\EntriesRepository;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Support\DeferrableProvider;
......
......@@ -81,9 +81,9 @@ class EntriesDatabaseTest extends DatabaseTestCase
$this->repository->add(new Entry(0, $u1->getId(), $d1->getId(), true));
$this->repository->add(new Entry(0, $u2->getId(), $d1->getId(), true));
$this->repository->add(new Entry(0, $u2->getId(), $d2->getId(), false));
$this->assertCount(2, $this->repository->getForDoorBetween($d1->getId(), $begin, $end));
$this->assertCount(2, $this->repository->getForUserBetween($u2->getId(), $begin, $end));
$this->assertCount(1, $this->repository->getForUserAndDoorBetween($u2->getId(), $d1->getId(), $begin, $end));
$this->assertCount(2, $this->repository->get($begin, $end, null, $d1->getId()));
$this->assertCount(2, $this->repository->get($begin, $end, $u2->getId(), null));
$this->assertCount(1, $this->repository->get($begin, $end, $u2->getId(), $d1->getId()));
}
/**
......@@ -103,6 +103,6 @@ class EntriesDatabaseTest extends DatabaseTestCase
$this->repository->add(new Entry(0, $u1->getId(), $d1->getId(), true));
$this->repository->add(new Entry(0, $u2->getId(), $d1->getId(), true));
$this->repository->add(new Entry(0, $u2->getId(), $d2->getId(), false));
$this->assertCount(3, $this->repository->getBetween(Carbon::now()->subDays(1), Carbon::now()->addDay()));
$this->assertCount(3, $this->repository->get(Carbon::now()->subDays(1), Carbon::now()->addDay()));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment