diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 29ff273f4..c91baa02e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -79,6 +79,11 @@ jobs: run: | cp tests/.env.ci-${{ matrix.connection }} .env touch config/version + echo '{"/js/app.js": "/js/app.js", "/css/app.css": "/css/app.css"}' > public/mix-manifest.json + mkdir -p public/js + echo '' > public/js/app.js + mkdir -p public/css + echo '' > public/css/app.css - name: Create SQLite database if: matrix.connection == 'sqlite' run: | diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 2b180b1f6..6dc1398ab 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -81,36 +81,36 @@ jobs: # run: vendor/bin/psalm --output-format=github - # phpstan: - # runs-on: ubuntu-latest - # strategy: - # matrix: - # php-version: [7.4] + phpstan: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [7.4] - # steps: - # - name: Checkout sources - # uses: actions/checkout@v2 + steps: + - name: Checkout sources + uses: actions/checkout@v2 - # - name: Setup PHP ${{ matrix.php-version }} - # uses: shivammathur/setup-php@v2 - # with: - # php-version: ${{ matrix.php-version }} - # coverage: none + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none - # - name: Get Composer Cache Directory - # id: composer-cache - # run: echo "::set-output name=dir::$(composer config cache-files-dir)" - # - name: Cache composer files - # uses: actions/cache@v2 - # with: - # path: ${{ steps.composer-cache.outputs.dir }} - # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - # restore-keys: | - # ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - # ${{ runner.os }}-composer- + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer files + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + ${{ runner.os }}-composer- - # - name: Install dependencies - # run: composer install --no-progress --no-interaction --no-suggest --prefer-dist --optimize-autoloader + - name: Install dependencies + run: composer install --no-progress --no-interaction --no-suggest --prefer-dist --optimize-autoloader - # - name: Run phpstan - # run: vendor/bin/phpstan analyse + - name: Run phpstan + run: vendor/bin/phpstan analyse diff --git a/app/Console/Commands/Helpers/Command.php b/app/Console/Commands/Helpers/Command.php index c221191b0..aff516e79 100644 --- a/app/Console/Commands/Helpers/Command.php +++ b/app/Console/Commands/Helpers/Command.php @@ -5,6 +5,10 @@ use RuntimeException; use Tests\Helpers\CommandCallerFake; +/** + * @method static void exec(\Illuminate\Console\Command $command, string $message, string $commandline) + * @method static void artisan(\Illuminate\Console\Command $command, string $message, string $commandline, array $arguments) + */ class Command { /** @@ -22,9 +26,9 @@ public static function fake() : CommandCallerContract /** * The Command Executor. * - * @var CommandCallerContract + * @var CommandCallerContract|null */ - private static $CommandCaller; + private static $commandCaller; /** * Get the current backend command. @@ -33,11 +37,11 @@ public static function fake() : CommandCallerContract */ private static function getBackend() : CommandCallerContract { - if (is_null(static::$CommandCaller)) { - static::$CommandCaller = app(CommandCaller::class); // @codeCoverageIgnore + if (! static::$commandCaller) { + static::$commandCaller = app(CommandCaller::class); // @codeCoverageIgnore } - return static::$CommandCaller; + return static::$commandCaller; } /** @@ -47,7 +51,7 @@ private static function getBackend() : CommandCallerContract */ public static function setBackend(CommandCallerContract $executor) : void { - static::$CommandCaller = $executor; + static::$commandCaller = $executor; } /** @@ -63,10 +67,6 @@ public static function __callStatic($method, $args) { $instance = static::getBackend(); - if (! $instance) { - throw new RuntimeException('No backend.'); // @codeCoverageIgnore - } - return $instance->$method(...$args); } } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 46889cb5e..170c07d29 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -46,13 +46,4 @@ public function render($request, Throwable $e) return parent::render($request, $e); } - - protected function whoopsHandler() - { - try { - return app(\Whoops\Handler\HandlerInterface::class); - } catch (\Illuminate\Contracts\Container\BindingResolutionException $e) { - return parent::whoopsHandler(); - } - } } diff --git a/app/Helpers/BirthdayHelper.php b/app/Helpers/BirthdayHelper.php index 6f2265052..c3ecd104f 100644 --- a/app/Helpers/BirthdayHelper.php +++ b/app/Helpers/BirthdayHelper.php @@ -28,7 +28,7 @@ public static function isBirthdayInXDays(Carbon $startDate, Carbon $birthdate, i /** * Check if the birthdate will happen in the given range. * - * @param Carbon $startDate + * @param Carbon $birthdate * @param Carbon $minDate * @param Carbon $maxDate * @return bool diff --git a/app/Http/Controllers/Company/Adminland/AdminExpenseController.php b/app/Http/Controllers/Company/Adminland/AdminExpenseController.php index f21dde49e..94886cb86 100644 --- a/app/Http/Controllers/Company/Adminland/AdminExpenseController.php +++ b/app/Http/Controllers/Company/Adminland/AdminExpenseController.php @@ -71,7 +71,7 @@ public function store(Request $request, int $companyId): JsonResponse * * @param Request $request * @param int $companyId - * @param mixed $expenseCategoryId + * @param int $expenseCategoryId * @return JsonResponse */ public function update(Request $request, int $companyId, int $expenseCategoryId): JsonResponse diff --git a/app/Http/Controllers/Company/Company/QuestionController.php b/app/Http/Controllers/Company/Company/QuestionController.php index 385be65b1..37c12b554 100644 --- a/app/Http/Controllers/Company/Company/QuestionController.php +++ b/app/Http/Controllers/Company/Company/QuestionController.php @@ -116,7 +116,7 @@ public function team(Request $request, int $companyId, int $questionId, int $tea ->orderBy('answers.created_at', 'desc') ->paginate(10); - $answersCollection = CompanyQuestionViewHelper::allAnswers($question, $answers, $employee); + $answersCollection = CompanyQuestionViewHelper::question($question, $answers, $employee); return Inertia::render('Company/Question/Show', [ 'teams' => $teams, diff --git a/app/Http/Controllers/Company/Dashboard/DashboardExpensesController.php b/app/Http/Controllers/Company/Dashboard/DashboardExpensesController.php index 1a4094b62..1ea561a78 100644 --- a/app/Http/Controllers/Company/Dashboard/DashboardExpensesController.php +++ b/app/Http/Controllers/Company/Dashboard/DashboardExpensesController.php @@ -37,7 +37,7 @@ public function index(): Response $employeeInformation = [ 'id' => $employee->id, 'dashboard_view' => 'expenses', - 'is_manager' => $employee->directReports->count() > 0 ? true : false, + 'is_manager' => $employee->directReports->count() > 0, 'can_manage_expenses' => $employee->can_manage_expenses, ]; diff --git a/app/Http/Controllers/Company/Dashboard/DashboardMeController.php b/app/Http/Controllers/Company/Dashboard/DashboardMeController.php index 16e004cbf..e943d04ca 100644 --- a/app/Http/Controllers/Company/Dashboard/DashboardMeController.php +++ b/app/Http/Controllers/Company/Dashboard/DashboardMeController.php @@ -39,7 +39,7 @@ public function index(): Response 'has_logged_morale_today' => $employee->hasAlreadyLoggedMoraleToday(), 'dashboard_view' => 'me', 'can_manage_expenses' => $employee->can_manage_expenses, - 'is_manager' => $employee->directReports->count() > 0 ? true : false, + 'is_manager' => $employee->directReports->count() > 0, 'has_worked_from_home_today' => WorkFromHomeHelper::hasWorkedFromHomeOnDate($employee, Carbon::now()), 'question' => DashboardMeViewHelper::question($employee), ]; diff --git a/app/Http/Controllers/Company/Dashboard/DashboardTeamController.php b/app/Http/Controllers/Company/Dashboard/DashboardTeamController.php index 0d55dfdfb..173e692db 100644 --- a/app/Http/Controllers/Company/Dashboard/DashboardTeamController.php +++ b/app/Http/Controllers/Company/Dashboard/DashboardTeamController.php @@ -50,7 +50,7 @@ public function index(Request $request, int $companyId, int $teamId = null, $req 'has_logged_morale_today' => $employee->hasAlreadyLoggedMoraleToday(), 'dashboard_view' => 'team', 'can_manage_expenses' => $employee->can_manage_expenses, - 'is_manager' => $employee->directReports->count() > 0 ? true : false, + 'is_manager' => $employee->directReports->count() > 0, ]; UpdateDashboardPreference::dispatch([ diff --git a/app/Http/Controllers/Company/Employee/EmployeeLogsController.php b/app/Http/Controllers/Company/Employee/EmployeeLogsController.php index 23c16057c..098c218ed 100644 --- a/app/Http/Controllers/Company/Employee/EmployeeLogsController.php +++ b/app/Http/Controllers/Company/Employee/EmployeeLogsController.php @@ -4,12 +4,15 @@ use Inertia\Inertia; use Illuminate\Http\Request; +use Illuminate\Http\Response; use App\Helpers\InstanceHelper; use App\Helpers\PaginatorHelper; use App\Models\Company\Employee; +use Illuminate\Routing\Redirector; use App\Helpers\NotificationHelper; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Auth; +use Illuminate\Http\RedirectResponse; use App\Http\ViewHelpers\Employee\EmployeeLogViewHelper; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -21,7 +24,7 @@ class EmployeeLogsController extends Controller * @param Request $request * @param int $companyId * @param int $employeeId - * @return Response + * @return Redirector|RedirectResponse|Response */ public function index(Request $request, int $companyId, int $employeeId) { diff --git a/app/Http/Controllers/Company/Project/ProjectController.php b/app/Http/Controllers/Company/Project/ProjectController.php index 80711542a..bb31882e7 100644 --- a/app/Http/Controllers/Company/Project/ProjectController.php +++ b/app/Http/Controllers/Company/Project/ProjectController.php @@ -561,7 +561,6 @@ public function destroyLink(Request $request, int $companyId, int $projectId, in * @param Request $request * @param int $companyId * @param int $projectId - * @param int $linkId */ public function createStatus(Request $request, int $companyId, int $projectId) { diff --git a/app/Http/Controllers/Company/Team/TeamMembersController.php b/app/Http/Controllers/Company/Team/TeamMembersController.php index cc85e953c..4c46504c2 100644 --- a/app/Http/Controllers/Company/Team/TeamMembersController.php +++ b/app/Http/Controllers/Company/Team/TeamMembersController.php @@ -35,6 +35,8 @@ public function index(Request $request, int $companyId, int $teamId): JsonRespon } $search = $request->input('searchTerm'); + + /** @var \Illuminate\Pagination\LengthAwarePaginator */ $potentialEmployees = Employee::search( $search, $companyId, diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index ff9e8d25e..6e41cd8da 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -14,8 +14,6 @@ class Authenticate extends Middleware */ protected function redirectTo($request) { - if (! $request->expectsJson()) { - return route('login'); - } + return $request->expectsJson() ? route('login') : null; } } diff --git a/app/Http/ViewHelpers/Adminland/AdminEmployeeViewHelper.php b/app/Http/ViewHelpers/Adminland/AdminEmployeeViewHelper.php index d98f1a8b9..93557bfbc 100644 --- a/app/Http/ViewHelpers/Adminland/AdminEmployeeViewHelper.php +++ b/app/Http/ViewHelpers/Adminland/AdminEmployeeViewHelper.php @@ -79,7 +79,7 @@ private static function getCollectionOfEmployees(Collection $employees, Company 'permission_level' => $employee->permission_level, 'avatar' => $employee->avatar, 'invitation_link' => $employee->invitation_link, - 'invited' => ! $employee->invitation_used_at && $employee->invitation_link ? true : false, + 'invited' => (bool) (! $employee->invitation_used_at && $employee->invitation_link), 'lock_status' => $employee->locked, 'url_view' => route('employees.show', [ 'company' => $company, diff --git a/app/Http/ViewHelpers/Company/CompanyQuestionViewHelper.php b/app/Http/ViewHelpers/Company/CompanyQuestionViewHelper.php index 6d2e90c0d..174a0dff4 100644 --- a/app/Http/ViewHelpers/Company/CompanyQuestionViewHelper.php +++ b/app/Http/ViewHelpers/Company/CompanyQuestionViewHelper.php @@ -3,7 +3,6 @@ namespace App\Http\ViewHelpers\Company; use App\Helpers\DateHelper; -use App\Models\Company\Team; use App\Models\Company\Answer; use App\Helpers\QuestionHelper; use App\Models\Company\Company; @@ -77,8 +76,8 @@ public static function question(Question $question, $answers, Employee $employee 'id' => $answer->answer_id, 'body' => $answer->body, 'employee' => [ - 'name' => $answer->employee->name, - 'avatar' => $answer->employee->avatar, + 'name' => $answer->employee ? $answer->employee->name : $answer->name, + 'avatar' => $answer->employee ? $answer->employee->avatar : $answer->avatar, ], ]); } @@ -88,7 +87,7 @@ public static function question(Question $question, $answers, Employee $employee 'title' => $question->title, 'number_of_answers' => $answers->count(), 'answers' => $answerCollection, - 'employee_has_answered' => $detailOfAnswer ? true : false, + 'employee_has_answered' => (bool) $detailOfAnswer, 'answer_by_employee' => $detailOfAnswer, 'date' => $date, 'url' => route('company.questions.show', [ @@ -120,52 +119,6 @@ public static function teams(Collection $teams): Collection return $teamsCollection; } - /** - * Detail of a question, along with all the answers only written by - * employees in a team. - * - * @param Question $question - * @param mixed $answers - * @param Employee $employee - * - * @return array|null - */ - public static function allAnswers(Question $question, $answers, Employee $employee): ?array - { - $answerByEmployee = QuestionHelper::getAnswer($question, $employee); - - $date = self::getInformationAboutActivationDate($question); - - // preparing the array of answers - $answerCollection = collect([]); - foreach ($answers as $answer) { - $answerCollection->push([ - 'id' => $answer->answer_id, - 'body' => $answer->body, - 'employee' => [ - 'name' => $answer->name, - 'avatar' => $answer->avatar, - ], - ]); - } - - $array = [ - 'id' => $question->id, - 'title' => $question->title, - 'number_of_answers' => $answers->count(), - 'answers' => $answerCollection, - 'employee_has_answered' => $answerByEmployee ? true : false, - 'answer_by_employee' => $answerByEmployee, - 'date' => $date, - 'url' => route('company.questions.show', [ - 'company' => $employee->company, - 'question' => $question, - ]), - ]; - - return $array; - } - /** * @param Question $question * @return string|null diff --git a/app/Http/ViewHelpers/Dashboard/DashboardManagerViewHelper.php b/app/Http/ViewHelpers/Dashboard/DashboardManagerViewHelper.php index 5e006c105..1c39eff73 100644 --- a/app/Http/ViewHelpers/Dashboard/DashboardManagerViewHelper.php +++ b/app/Http/ViewHelpers/Dashboard/DashboardManagerViewHelper.php @@ -109,7 +109,7 @@ public static function expense(Expense $expense): array * @param Collection $directReports * @return SupportCollection|null */ - public static function oneOnOnes(Employee $manager, Collection $directReports): SupportCollection + public static function oneOnOnes(Employee $manager, Collection $directReports): ?SupportCollection { // get the list of employees this manager manages $oneOnOnesCollection = collect([]); diff --git a/app/Http/ViewHelpers/Dashboard/DashboardMeViewHelper.php b/app/Http/ViewHelpers/Dashboard/DashboardMeViewHelper.php index 0bab9d459..9e35c9c0c 100644 --- a/app/Http/ViewHelpers/Dashboard/DashboardMeViewHelper.php +++ b/app/Http/ViewHelpers/Dashboard/DashboardMeViewHelper.php @@ -54,7 +54,7 @@ public static function question(Employee $employee): ?array 'title' => $question->title, 'number_of_answers' => $allAnswers->count(), 'answers' => $answersCollection, - 'employee_has_answered' => $answerByEmployee ? true : false, + 'employee_has_answered' => (bool) $answerByEmployee, 'answer_by_employee' => $answerByEmployee ? [ 'body' => $answerByEmployee->body, ] : null, diff --git a/app/Http/ViewHelpers/Employee/EmployeeOneOnOneViewHelper.php b/app/Http/ViewHelpers/Employee/EmployeeOneOnOneViewHelper.php index 68671d883..c121232bf 100644 --- a/app/Http/ViewHelpers/Employee/EmployeeOneOnOneViewHelper.php +++ b/app/Http/ViewHelpers/Employee/EmployeeOneOnOneViewHelper.php @@ -43,7 +43,7 @@ public static function stats(Collection $entries): array /** * Array containing all the one on ones done. * - * @param Collection $expenses + * @param Collection $oneOnOnes * @param Employee $employee * @return SupportCollection */ diff --git a/app/Http/ViewHelpers/Employee/EmployeePerformanceViewHelper.php b/app/Http/ViewHelpers/Employee/EmployeePerformanceViewHelper.php index 8dffdae5e..ff1987128 100644 --- a/app/Http/ViewHelpers/Employee/EmployeePerformanceViewHelper.php +++ b/app/Http/ViewHelpers/Employee/EmployeePerformanceViewHelper.php @@ -43,28 +43,26 @@ public static function latestRateYourManagerSurveys(Employee $employee): ?array foreach ($surveysToDisplay as $survey) { $totalNumberOfPotentialResponders = $survey->answers->count(); - $numberOfAnswers = 0; // counting results about answers, if available $results = []; - if ($survey->answers) { - $bad = $survey->answers->filter(function ($answer) { - return $answer->rating == RateYourManagerAnswer::BAD; - }); - $average = $survey->answers->filter(function ($answer) { - return $answer->rating == RateYourManagerAnswer::AVERAGE; - }); - $good = $survey->answers->filter(function ($answer) { - return $answer->rating == RateYourManagerAnswer::GOOD; - }); - $results = [ - 'bad' => $bad->count(), - 'average' => $average->count(), - 'good' => $good->count(), - ]; - $numberOfAnswers = $bad->count() + $average->count() + $good->count(); - } + $bad = $survey->answers->filter(function ($answer) { + return $answer->rating == RateYourManagerAnswer::BAD; + }); + $average = $survey->answers->filter(function ($answer) { + return $answer->rating == RateYourManagerAnswer::AVERAGE; + }); + $good = $survey->answers->filter(function ($answer) { + return $answer->rating == RateYourManagerAnswer::GOOD; + }); + $results = [ + 'bad' => $bad->count(), + 'average' => $average->count(), + 'good' => $good->count(), + ]; + + $numberOfAnswers = $bad->count() + $average->count() + $good->count(); $surveysCollection->push([ 'id' => $survey->id, diff --git a/app/Http/ViewHelpers/Employee/EmployeeSurveysViewHelper.php b/app/Http/ViewHelpers/Employee/EmployeeSurveysViewHelper.php index 7d3540058..eb5d47be7 100644 --- a/app/Http/ViewHelpers/Employee/EmployeeSurveysViewHelper.php +++ b/app/Http/ViewHelpers/Employee/EmployeeSurveysViewHelper.php @@ -43,28 +43,24 @@ public static function rateYourManagerSurveys(Employee $employee): ?array foreach ($allSurveys as $survey) { $totalNumberOfPotentialResponders = $survey->answers->count(); - $numberOfAnswers = 0; - - // counting results about answers, if available - $results = []; - if ($survey->answers) { - $bad = $survey->answers->filter(function ($answer) { - return $answer->rating == RateYourManagerAnswer::BAD; - }); - $average = $survey->answers->filter(function ($answer) { - return $answer->rating == RateYourManagerAnswer::AVERAGE; - }); - $good = $survey->answers->filter(function ($answer) { - return $answer->rating == RateYourManagerAnswer::GOOD; - }); - $results = [ - 'bad' => $bad->count(), - 'average' => $average->count(), - 'good' => $good->count(), - ]; - - $numberOfAnswers = $bad->count() + $average->count() + $good->count(); - } + + // counting results about answers + $bad = $survey->answers->filter(function ($answer) { + return $answer->rating == RateYourManagerAnswer::BAD; + }); + $average = $survey->answers->filter(function ($answer) { + return $answer->rating == RateYourManagerAnswer::AVERAGE; + }); + $good = $survey->answers->filter(function ($answer) { + return $answer->rating == RateYourManagerAnswer::GOOD; + }); + $results = [ + 'bad' => $bad->count(), + 'average' => $average->count(), + 'good' => $good->count(), + ]; + + $numberOfAnswers = $bad->count() + $average->count() + $good->count(); $surveysCollection->push([ 'id' => $survey->id, @@ -113,24 +109,21 @@ public static function informationAboutSurvey(int $surveyId): ?array ->with('answers.employee') ->findOrFail($surveyId); - // counting results about answers, if available - $results = []; - if ($survey->answers) { - $bad = $survey->answers->filter(function ($answer) { - return $answer->rating == RateYourManagerAnswer::BAD; - }); - $average = $survey->answers->filter(function ($answer) { - return $answer->rating == RateYourManagerAnswer::AVERAGE; - }); - $good = $survey->answers->filter(function ($answer) { - return $answer->rating == RateYourManagerAnswer::GOOD; - }); - $results = [ - 'bad' => $bad->count(), - 'average' => $average->count(), - 'good' => $good->count(), - ]; - } + // counting results about answers + $bad = $survey->answers->filter(function ($answer) { + return $answer->rating == RateYourManagerAnswer::BAD; + }); + $average = $survey->answers->filter(function ($answer) { + return $answer->rating == RateYourManagerAnswer::AVERAGE; + }); + $good = $survey->answers->filter(function ($answer) { + return $answer->rating == RateYourManagerAnswer::GOOD; + }); + $results = [ + 'bad' => $bad->count(), + 'average' => $average->count(), + 'good' => $good->count(), + ]; // employees $directReportsCollection = collect([]); diff --git a/app/Http/ViewHelpers/Project/ProjectViewHelper.php b/app/Http/ViewHelpers/Project/ProjectViewHelper.php index 0029739f9..206d6242b 100644 --- a/app/Http/ViewHelpers/Project/ProjectViewHelper.php +++ b/app/Http/ViewHelpers/Project/ProjectViewHelper.php @@ -13,7 +13,7 @@ class ProjectViewHelper /** * Array containing the information all the projects in the company. * - * @param Company + * @param Company $company * @return array */ public static function index(Company $company): array @@ -44,8 +44,8 @@ public static function index(Company $company): array * Array containing the information about the project displayed on the * summary page. * - * @param Project - * @param Company + * @param Project $project + * @param Company $company * @return array */ public static function summary(Project $project, Company $company): array @@ -119,8 +119,7 @@ public static function summary(Project $project, Company $company): array /** * Array containing the information needed to update the project details. * - * @param Project - * @param Company + * @param Project $project * @return array */ public static function edit(Project $project): array diff --git a/app/Http/ViewHelpers/Team/TeamMembersViewHelper.php b/app/Http/ViewHelpers/Team/TeamMembersViewHelper.php index cf64162fb..489c000d6 100644 --- a/app/Http/ViewHelpers/Team/TeamMembersViewHelper.php +++ b/app/Http/ViewHelpers/Team/TeamMembersViewHelper.php @@ -4,6 +4,7 @@ use App\Models\Company\Employee; use Illuminate\Support\Collection; +use Illuminate\Support\Enumerable; class TeamMembersViewHelper { @@ -11,11 +12,11 @@ class TeamMembersViewHelper * Array containing all the basic information about employees that the user * has made a search about. * - * @param Collection $employees + * @param \Traversable $employees * * @return Collection */ - public static function searchedEmployees(Collection $employees): Collection + public static function searchedEmployees(\Traversable $employees): Collection { $employeesCollection = collect([]); foreach ($employees as $employee) { diff --git a/app/Jobs/CheckIfPendingExpenseShouldBeMovedToAccountingWhenManagerChanges.php b/app/Jobs/CheckIfPendingExpenseShouldBeMovedToAccountingWhenManagerChanges.php index 80b187957..e482293a1 100644 --- a/app/Jobs/CheckIfPendingExpenseShouldBeMovedToAccountingWhenManagerChanges.php +++ b/app/Jobs/CheckIfPendingExpenseShouldBeMovedToAccountingWhenManagerChanges.php @@ -58,10 +58,6 @@ public function handle() foreach ($expenses as $expense) { $employee = $expense->employee; - if (! $employee->managers) { - continue; - } - if ($employee->managers->count() == 0) { $expense->status = Expense::AWAITING_ACCOUTING_APPROVAL; $expense->save(); diff --git a/app/Models/Company/CompanyCalendar.php b/app/Models/Company/CompanyCalendar.php index aed87a8ed..7c58484ed 100644 --- a/app/Models/Company/CompanyCalendar.php +++ b/app/Models/Company/CompanyCalendar.php @@ -38,7 +38,7 @@ class CompanyCalendar extends Model /** * Get the company record associated with the company news. * - * @return belongsTo + * @return BelongsTo */ public function policy() { diff --git a/app/Models/Company/CompanyNews.php b/app/Models/Company/CompanyNews.php index b4e1c1b28..d5f1ab426 100644 --- a/app/Models/Company/CompanyNews.php +++ b/app/Models/Company/CompanyNews.php @@ -41,7 +41,7 @@ class CompanyNews extends Model /** * Get the company record associated with the company news. * - * @return belongsTo + * @return BelongsTo */ public function company() { @@ -50,6 +50,8 @@ public function company() /** * Get the employee record associated with the company news. + * + * @return BelongsTo */ public function author() { diff --git a/app/Models/Company/CompanyPTOPolicy.php b/app/Models/Company/CompanyPTOPolicy.php index 8a281bc7c..f225b2067 100644 --- a/app/Models/Company/CompanyPTOPolicy.php +++ b/app/Models/Company/CompanyPTOPolicy.php @@ -32,7 +32,7 @@ class CompanyPTOPolicy extends Model /** * Get the company record associated with the company news. * - * @return belongsTo + * @return BelongsTo */ public function company() { diff --git a/app/Models/Company/DirectReport.php b/app/Models/Company/DirectReport.php index bb8983e02..06504c427 100644 --- a/app/Models/Company/DirectReport.php +++ b/app/Models/Company/DirectReport.php @@ -3,6 +3,7 @@ namespace App\Models\Company; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasOne; class DirectReport extends Model { diff --git a/app/Models/Company/Employee.php b/app/Models/Company/Employee.php index 5a09defa9..8ae8977ba 100644 --- a/app/Models/Company/Employee.php +++ b/app/Models/Company/Employee.php @@ -129,7 +129,7 @@ public function user() /** * Get the Company record associated with the company. * - * @return belongsTo + * @return BelongsTo */ public function company() { @@ -139,7 +139,7 @@ public function company() /** * Get the teams record associated with the employee. * - * @return belongsToMany + * @return BelongsToMany */ public function teams() { @@ -149,7 +149,7 @@ public function teams() /** * Get all the employees this employee reports to (ie the managers). * - * @return hasMany + * @return HasMany */ public function managers() { @@ -159,7 +159,7 @@ public function managers() /** * Get all the employees this employee manages. * - * @return hasMany + * @return HasMany */ public function directReports() { @@ -179,7 +179,7 @@ public function employeeLogs() /** * Get the position record associated with the employee. * - * @return belongsTo + * @return BelongsTo */ public function position() { @@ -209,7 +209,7 @@ public function worklogs() /** * Get the employee status associated with the employee. * - * @return belongsTo + * @return BelongsTo */ public function status() { @@ -273,7 +273,7 @@ public function plannedHolidays() /** * Get the pronoun record associated with the employee. * - * @return belongsTo + * @return BelongsTo */ public function pronoun() { @@ -323,7 +323,7 @@ public function hardware() /** * Get the ship records associated with the employee. * - * @return belongsToMany + * @return BelongsToMany */ public function ships() { @@ -333,7 +333,7 @@ public function ships() /** * Get the skill records associated with the employee. * - * @return belongsToMany + * @return BelongsToMany */ public function skills() { @@ -343,7 +343,7 @@ public function skills() /** * Get the expense records associated with the employee. * - * @return hasMany + * @return HasMany */ public function expenses() { @@ -354,7 +354,7 @@ public function expenses() * Get the expense records approved by this employee as a manager * associated with the employee. * - * @return hasMany + * @return HasMany */ public function approvedExpenses() { @@ -365,7 +365,7 @@ public function approvedExpenses() * Get the expense records approved by this employee as someone in the * accounting department associated with the employee. * - * @return hasMany + * @return HasMany */ public function approvedAccountingExpenses() { @@ -375,7 +375,7 @@ public function approvedAccountingExpenses() /** * Get the current active surveys about how his manager is doing. * - * @return hasMany + * @return HasMany */ public function rateYourManagerSurveys() { @@ -385,7 +385,7 @@ public function rateYourManagerSurveys() /** * Get the current active surveys about how his manager is doing. * - * @return hasMany + * @return HasMany */ public function rateYourManagerAnswers() { @@ -395,7 +395,7 @@ public function rateYourManagerAnswers() /** * Get the one on one entries associated with the employee. * - * @return hasMany + * @return HasMany */ public function oneOnOneEntriesAsEmployee() { @@ -405,7 +405,7 @@ public function oneOnOneEntriesAsEmployee() /** * Get the one on one entries associated with the employee being a manager. * - * @return hasMany + * @return HasMany */ public function oneOnOneEntriesAsManager() { @@ -415,7 +415,7 @@ public function oneOnOneEntriesAsManager() /** * Get the Guess Employee Games records associated with the employee. * - * @return hasMany + * @return HasMany */ public function gamesAsPlayer() { @@ -425,7 +425,7 @@ public function gamesAsPlayer() /** * Get the Guess Employee Games records associated with the employee. * - * @return hasMany + * @return HasMany */ public function gamesAsPersonToFind() { @@ -435,7 +435,7 @@ public function gamesAsPersonToFind() /** * Get the project records associated with the employee. * - * @return belongsToMany + * @return BelongsToMany */ public function projects() { @@ -445,7 +445,7 @@ public function projects() /** * Get the project records as lead associated with the employee. * - * @return hasMany + * @return HasMany */ public function projectsAsLead() { diff --git a/app/Models/Company/ExpenseCategory.php b/app/Models/Company/ExpenseCategory.php index 7f3087b34..65e798dfa 100644 --- a/app/Models/Company/ExpenseCategory.php +++ b/app/Models/Company/ExpenseCategory.php @@ -50,7 +50,7 @@ public function company() /** * Get the expense records associated with the expense category. * - * @return hasMany + * @return HasMany */ public function expenses() { diff --git a/app/Models/Company/Hardware.php b/app/Models/Company/Hardware.php index bdf5266c8..34d88cf14 100644 --- a/app/Models/Company/Hardware.php +++ b/app/Models/Company/Hardware.php @@ -73,7 +73,7 @@ public function company() /** * Get the employee records associated with the hardware. * - * @return belongsTo + * @return BelongsTo */ public function employee() { diff --git a/app/Models/Company/OneOnOneEntry.php b/app/Models/Company/OneOnOneEntry.php index 5bfe5b1f1..9f8cef4e9 100644 --- a/app/Models/Company/OneOnOneEntry.php +++ b/app/Models/Company/OneOnOneEntry.php @@ -4,6 +4,7 @@ use Illuminate\Database\Eloquent\Model; use Spatie\Activitylog\Traits\LogsActivity; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; class OneOnOneEntry extends Model @@ -78,7 +79,7 @@ public function employee() /** * Get the one on one talking point associated with the entry. * - * @return hasMany + * @return HasMany */ public function talkingPoints() { @@ -88,7 +89,7 @@ public function talkingPoints() /** * Get the one on one action items associated with the entry. * - * @return hasMany + * @return HasMany */ public function actionItems() { @@ -98,7 +99,7 @@ public function actionItems() /** * Get the one on one action items associated with the entry. * - * @return hasMany + * @return HasMany */ public function notes() { diff --git a/app/Models/Company/Place.php b/app/Models/Company/Place.php index 158faabb0..2fe4588c6 100644 --- a/app/Models/Company/Place.php +++ b/app/Models/Company/Place.php @@ -4,6 +4,8 @@ use App\Helpers\MapHelper; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\MorphTo; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class Place extends Model { @@ -36,6 +38,8 @@ class Place extends Model /** * Get the owning placable model. + * + * @return MorphTo */ public function placable() { @@ -44,6 +48,8 @@ public function placable() /** * Get the country record associated with the place. + * + * @return BelongsTo */ public function country() { diff --git a/app/Models/Company/Position.php b/app/Models/Company/Position.php index 2af44d3a9..3ccd1b5c8 100644 --- a/app/Models/Company/Position.php +++ b/app/Models/Company/Position.php @@ -64,7 +64,7 @@ public function company() /** * Get the employee records associated with the position. * - * @return hasMany + * @return HasMany */ public function employees() { diff --git a/app/Models/Company/Project.php b/app/Models/Company/Project.php index b48ff7261..f63677ed4 100644 --- a/app/Models/Company/Project.php +++ b/app/Models/Company/Project.php @@ -3,7 +3,9 @@ namespace App\Models\Company; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Project extends Model { @@ -79,7 +81,7 @@ public function lead() /** * Get the employee records associated with the project. * - * @return belongsToMany + * @return BelongsToMany */ public function employees() { @@ -89,7 +91,7 @@ public function employees() /** * Get the team records associated with the project. * - * @return belongsToMany + * @return BelongsToMany */ public function teams() { @@ -99,7 +101,7 @@ public function teams() /** * Get the employee records associated with the project. * - * @return hasMany + * @return HasMany */ public function links() { @@ -109,7 +111,7 @@ public function links() /** * Get the project status associated with the project. * - * @return hasMany + * @return HasMany */ public function statuses() { diff --git a/app/Models/Company/RateYourManagerSurvey.php b/app/Models/Company/RateYourManagerSurvey.php index 0768fd3ef..e7e537f49 100644 --- a/app/Models/Company/RateYourManagerSurvey.php +++ b/app/Models/Company/RateYourManagerSurvey.php @@ -53,7 +53,7 @@ public function manager() /** * Get the answers made by direct reports associated with the survey. * - * @return hasMany + * @return HasMany */ public function answers() { diff --git a/app/Models/Company/Ship.php b/app/Models/Company/Ship.php index 77b912838..4196abe4d 100644 --- a/app/Models/Company/Ship.php +++ b/app/Models/Company/Ship.php @@ -45,7 +45,7 @@ public function team() /** * Get the employee records associated with the ship. * - * @return belongsToMany + * @return BelongsToMany */ public function employees() { diff --git a/app/Models/Company/Skill.php b/app/Models/Company/Skill.php index 284b64dcb..a13bf47bc 100644 --- a/app/Models/Company/Skill.php +++ b/app/Models/Company/Skill.php @@ -64,7 +64,7 @@ public function company() /** * Get the employee records associated with the skill. * - * @return belongsToMany + * @return BelongsToMany */ public function employees() { diff --git a/app/Models/Company/Team.php b/app/Models/Company/Team.php index a386a912e..173e815ad 100644 --- a/app/Models/Company/Team.php +++ b/app/Models/Company/Team.php @@ -70,7 +70,7 @@ public function company() /** * Get the employee records associated with the team. * - * @return belongsToMany + * @return BelongsToMany */ public function employees() { @@ -90,7 +90,7 @@ public function leader() /** * Get the team useful link records associated with the team. * - * @return hasMany + * @return HasMany */ public function links() { @@ -100,7 +100,7 @@ public function links() /** * Get the team news records associated with the team. * - * @return hasMany + * @return HasMany */ public function news() { @@ -130,7 +130,7 @@ public function ships() /** * Get the project records associated with the team. * - * @return belongsToMany + * @return BelongsToMany */ public function projects() { diff --git a/app/Models/Company/TeamNews.php b/app/Models/Company/TeamNews.php index 6cb40c7d8..6751d3dab 100644 --- a/app/Models/Company/TeamNews.php +++ b/app/Models/Company/TeamNews.php @@ -41,7 +41,7 @@ class TeamNews extends Model /** * Get the team record associated with the team news. * - * @return belongsTo + * @return BelongsTo */ public function team() { @@ -50,6 +50,8 @@ public function team() /** * Get the employee record associated with the team news. + * + * @return BelongsTo */ public function author() { diff --git a/app/Models/User/User.php b/app/Models/User/User.php index 79f644cd4..fcc6cf224 100644 --- a/app/Models/User/User.php +++ b/app/Models/User/User.php @@ -66,7 +66,7 @@ class User extends Authenticatable implements MustVerifyEmail /** * Get the employee records associated with the user. * - * @return hasMany + * @return HasMany */ public function employees() { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index a54d05edd..fb460b306 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -29,9 +29,11 @@ public function boot() if (App::runningInConsole()) { Command::macro('exec', function (string $message, string $commandline) { + /** @var \Illuminate\Console\Command $this */ \App\Console\Commands\Helpers\Command::exec($this, $message, $commandline); // @codeCoverageIgnore }); Command::macro('artisan', function (string $message, string $commandline, array $arguments = []) { + /** @var \Illuminate\Console\Command $this */ \App\Console\Commands\Helpers\Command::artisan($this, $message, $commandline, $arguments); }); } diff --git a/app/Services/Company/Employee/Holiday/CreateTimeOff.php b/app/Services/Company/Employee/Holiday/CreateTimeOff.php index 0b31b922b..7201edf8a 100644 --- a/app/Services/Company/Employee/Holiday/CreateTimeOff.php +++ b/app/Services/Company/Employee/Holiday/CreateTimeOff.php @@ -95,23 +95,18 @@ public function execute(array $data): EmployeePlannedHoliday * @param Employee $employee * @param Carbon $date * - * @return EmployeePlannedHoliday + * @return EmployeePlannedHoliday|null */ - private function getExistingPlannedHoliday(Employee $employee, Carbon $date) + private function getExistingPlannedHoliday(Employee $employee, Carbon $date): ?EmployeePlannedHoliday { - $holiday = EmployeePlannedHoliday::where('employee_id', $employee->id) - ->where('planned_date', $date->format('Y-m-d 00:00:00')) - ->count(); + $holidays = EmployeePlannedHoliday::where('employee_id', $employee->id) + ->where('planned_date', $date->format('Y-m-d 00:00:00')); - if ($holiday > 1) { + if ($holidays->count() > 1) { throw new Exception(); } - $holiday = EmployeePlannedHoliday::where('employee_id', $employee->id) - ->where('planned_date', $date->format('Y-m-d 00:00:00')) - ->first(); - - return $holiday; + return $holidays->first(); } /** diff --git a/app/Services/Company/Employee/Team/RemoveEmployeeFromTeam.php b/app/Services/Company/Employee/Team/RemoveEmployeeFromTeam.php index 4622360e0..9ec663790 100644 --- a/app/Services/Company/Employee/Team/RemoveEmployeeFromTeam.php +++ b/app/Services/Company/Employee/Team/RemoveEmployeeFromTeam.php @@ -50,10 +50,7 @@ public function execute(array $data): Employee $team = $this->validateTeamBelongsToCompany($data); - $team->employees()->detach( - $data['employee_id'], - ['company_id' => $data['company_id']] - ); + $team->employees()->detach($data['employee_id']); $this->addNotification($team); diff --git a/app/Services/Company/GuessEmployeeGame/CreateGuessEmployeeGame.php b/app/Services/Company/GuessEmployeeGame/CreateGuessEmployeeGame.php index 39ffa73ae..8ffba8bd1 100644 --- a/app/Services/Company/GuessEmployeeGame/CreateGuessEmployeeGame.php +++ b/app/Services/Company/GuessEmployeeGame/CreateGuessEmployeeGame.php @@ -5,6 +5,7 @@ use OutOfRangeException; use App\Services\BaseService; use App\Models\Company\Answer; +use App\Models\Company\Employee; use App\Models\Company\GuessEmployeeGame; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -12,6 +13,7 @@ class CreateGuessEmployeeGame extends BaseService { protected array $data; protected GuessEmployeeGame $game; + protected Employee $employee; /** * Get the validation rules that apply to the service. diff --git a/app/Services/Company/GuessEmployeeGame/VoteGuessEmployeeGame.php b/app/Services/Company/GuessEmployeeGame/VoteGuessEmployeeGame.php index 03ad37339..df4e13825 100644 --- a/app/Services/Company/GuessEmployeeGame/VoteGuessEmployeeGame.php +++ b/app/Services/Company/GuessEmployeeGame/VoteGuessEmployeeGame.php @@ -2,6 +2,7 @@ namespace App\Services\Company\GuessEmployeeGame; +use App\Models\Company\Employee; use App\Services\BaseService; use App\Models\Company\GuessEmployeeGame; @@ -9,6 +10,7 @@ class VoteGuessEmployeeGame extends BaseService { protected array $data; protected GuessEmployeeGame $game; + protected Employee $employee; /** * Get the validation rules that apply to the service. diff --git a/app/Traits/Searchable.php b/app/Traits/Searchable.php index c2c22cddb..ba1f9dce6 100644 --- a/app/Traits/Searchable.php +++ b/app/Traits/Searchable.php @@ -21,10 +21,10 @@ trait Searchable * * @return LengthAwarePaginator|null */ - public function scopeSearch(Builder $builder, $needle, $companyId, $limitPerPage, $sortOrder, $whereCondition = null, $eagerLoadModel = null) + public function scopeSearch(Builder $builder, $needle, $companyId, $limitPerPage, $sortOrder, $whereCondition = null, $eagerLoadModel = null): ?LengthAwarePaginator { if ($this->searchableColumns == null) { - return; + return null; } $queryString = SearchHelper::buildQuery($this->searchableColumns, $needle); diff --git a/composer.json b/composer.json index a501660f6..115344f33 100644 --- a/composer.json +++ b/composer.json @@ -38,8 +38,7 @@ "nunomaduro/collision": "^5.0", "nunomaduro/larastan": "^0.6", "phpstan/phpstan-deprecation-rules": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", + "phpstan/phpstan-phpunit": "^0.12.16", "phpunit/phpunit": "^9.0", "psalm/plugin-laravel": "^1.4", "roave/security-advisories": "dev-master", diff --git a/composer.lock b/composer.lock index d0c3a2344..55bbb68a0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "113a20005a1b22b39fbe9d1b4da2884b", + "content-hash": "d0a0fe50107999279062f893c6a9f1e5", "packages": [ { "name": "asm89/stack-cors", @@ -8734,58 +8734,11 @@ "MIT" ], "description": "PHPUnit extensions and rules for PHPStan", - "time": "2020-08-05T13:28:50+00:00" - }, - { - "name": "phpstan/phpstan-strict-rules", - "version": "0.12.5", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "334898a32217e4605e0f9cfa3d3fc3101bda26be" + "support": { + "issues": "https://github.com/phpstan/phpstan-phpunit/issues", + "source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.16" }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/334898a32217e4605e0f9cfa3d3fc3101bda26be", - "reference": "334898a32217e4605e0f9cfa3d3fc3101bda26be", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0", - "phpstan/phpstan": "^0.12.33" - }, - "require-dev": { - "consistence/coding-standard": "^3.0.1", - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", - "ergebnis/composer-normalize": "^2.0.2", - "jakub-onderka/php-parallel-lint": "^1.0", - "phing/phing": "^2.16.0", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0", - "slevomat/coding-standard": "^4.5.2" - }, - "type": "phpstan-extension", - "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - }, - "phpstan": { - "includes": [ - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Extra strict and opinionated rules for PHPStan", - "time": "2020-08-30T15:42:06+00:00" + "time": "2020-08-05T13:28:50+00:00" }, { "name": "phpunit/php-code-coverage", @@ -11392,5 +11345,5 @@ "php": "^7.4" }, "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/package.json b/package.json index 311bb89b4..227705f06 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,9 @@ "lint:fix": "yarn lint --fix & yarn lint:cypress --fix", "cypress": "mv .env .env2 && mv .env.cypress.local .env && yarn run e2e-gui", "normal": "mv .env .env.cypress.local && mv .env2 .env", - "test": "DB_CONNECTION=testing php artisan migrate:fresh && DB_CONNECTION=testing php artisan db:seed", + "pretest": "DB_CONNECTION=testing php artisan migrate:fresh && DB_CONNECTION=testing php artisan db:seed", + "test": "vendor/bin/phpunit", + "posttest": "vendor/bin/phpstan analyse", "local": "php artisan migrate:fresh && php artisan db:seed", "composer update": "COMPOSER_MEMORY_LIMIT=-1 composer update" }, diff --git a/phpstan.neon b/phpstan.neon index 2d258ea6d..cd1598c00 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,32 +1,21 @@ includes: - ./vendor/nunomaduro/larastan/extension.neon # - ./vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon -# - ./vendor/phpstan/phpstan-phpunit/extension.neon -# - ./vendor/phpstan/phpstan-deprecation-rules/rules.neon -# - ./vendor/phpstan/phpstan-strict-rules/rules.neon + - ./vendor/phpstan/phpstan-deprecation-rules/rules.neon + - ./vendor/phpstan/phpstan-phpunit/extension.neon parameters: paths: - app + - tests inferPrivatePropertyTypeFromConstructor: true - level: 5 - checkMissingIterableValueType: false + level: 5 ignoreErrors: - - '#Unsafe usage of new static#' - - '#If condition is always true#' - - '#Negated boolean expression is always false.#' - - '#Access to an undefined property Illuminate\\Contracts\\Auth\\MustVerifyEmail::\$email\.#' - - '#Access to an undefined property Illuminate\\Support\\Fluent::\$[a-zA-Z0-9_]+\.#' - '#Argument of an invalid type Illuminate\\Contracts\\Pagination\\LengthAwarePaginator supplied for foreach, only iterables are supported#' - - '#Call to function is_null(.*?)#' - - '#Call to an undefined method \(Illuminate\\Database\\Eloquent\\Collection&iterable<[a-zA-Z0-9\\_]+>\)\|Illuminate\\Database\\Eloquent\\Model::[a-zA-Z0-9\\_]+\(\)\.#' - - '#Method [a-zA-Z0-9\\_:]+\(\) should return [a-zA-Z0-9\\_\|]+ but empty return statement found\.#' - - '#Method [a-zA-Z0-9\\_:]+\(\) should return [a-zA-Z0-9\\_\|]+ but returns [a-zA-Z0-9\\_]+\.#' - - '#Method [a-zA-Z0-9\\_:]+\(\) should return [a-zA-Z0-9\\_\|]+ but returns \(Illuminate\\Database\\Eloquent\\Collection&iterable<[a-zA-Z0-9\\_]+>\)\|Illuminate\\Database\\Eloquent\\Model.#' - - '#Parameter [a-zA-Z0-9\\_$\#:\(\)]+.#' - - '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::[a-zA-Z0-9_]+\(\)\.#' - - '#Call to an undefined method App\\Http\\Resources\\[a-zA-Z0-9\\_]+::[a-zA-Z0-9_]+\(\)\.#' - - '#Call to an undefined method Illuminate\\Http\\Resources\\[a-zA-Z0-9\\_]+::[a-zA-Z0-9_]+\(\)\.#' - excludes_analyse: - - */*/*/Authenticate.php + - '#Method [a-zA-Z0-9\\_:]+\(\) should return Illuminate\\Http\\(Json)?Response but returns Illuminate\\Http\\RedirectResponse\.#' + - '#Method [a-zA-Z0-9\\_:]+\(\) should return Inertia\\Response but returns Illuminate\\Http\\RedirectResponse\.#' + - message: '#Access to an undefined property App\\Models\\Company\\Employee::\$pivot\.#' + path: 'app/Http/ViewHelpers/Project/ProjectMembersViewHelper.php' + - message: '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::[a-zA-Z0-9\\_]+\(\)\.#' + path: 'tests/Unit/Traits/JsonRespondControllerTest.php' diff --git a/resources/js/Shared/Checkbox.vue b/resources/js/Shared/Checkbox.vue index 38f3563b0..eb7948c45 100644 --- a/resources/js/Shared/Checkbox.vue +++ b/resources/js/Shared/Checkbox.vue @@ -103,7 +103,7 @@ export default { computed: { hasError: function () { - return this.errors.length > 0 && this.required ? true : false; + return this.errors.length > 0 && this.required; } }, diff --git a/resources/js/Shared/EditableCheckbox.vue b/resources/js/Shared/EditableCheckbox.vue index 858c577bb..61ef953cc 100644 --- a/resources/js/Shared/EditableCheckbox.vue +++ b/resources/js/Shared/EditableCheckbox.vue @@ -197,7 +197,7 @@ export default { computed: { hasError: function () { - return this.errors.length > 0 && this.required ? true : false; + return this.errors.length > 0 && this.required; } }, diff --git a/resources/js/Shared/FileInput.vue b/resources/js/Shared/FileInput.vue index 3ad03f286..2b01bc037 100644 --- a/resources/js/Shared/FileInput.vue +++ b/resources/js/Shared/FileInput.vue @@ -105,7 +105,7 @@ export default { computed: { hasError: function () { - return this.errors.length > 0 && this.required ? true : false; + return this.errors.length > 0 && this.required; } }, diff --git a/resources/js/Shared/TextInput.vue b/resources/js/Shared/TextInput.vue index 09f1e0264..bd912dc4b 100644 --- a/resources/js/Shared/TextInput.vue +++ b/resources/js/Shared/TextInput.vue @@ -130,7 +130,7 @@ export default { computed: { hasError: function () { - return this.errors.length > 0 && this.required ? true : false; + return this.errors.length > 0 && this.required; } }, diff --git a/tests/ApiTestCase.php b/tests/ApiTestCase.php index 281d93fb2..34c6b4d67 100644 --- a/tests/ApiTestCase.php +++ b/tests/ApiTestCase.php @@ -10,11 +10,9 @@ class ApiTestCase extends TestCase /** * Create a user and sign in as that user. * - * @param null $user - * - * @return mixed + * @return User */ - public function signIn() + public function signIn(User $user): User { $user = factory(User::class)->create(); $this->actingAs($user); diff --git a/tests/Unit/Controllers/Auth/AuthenticateMiddlewareTest.php b/tests/Unit/Controllers/Auth/AuthenticateMiddlewareTest.php new file mode 100644 index 000000000..c97ad66bb --- /dev/null +++ b/tests/Unit/Controllers/Auth/AuthenticateMiddlewareTest.php @@ -0,0 +1,18 @@ +get('/home'); + + $response->assertStatus(302); + + $response->assertRedirect('/login'); + } +} diff --git a/tests/Unit/Controllers/Auth/RegisterControllerTest.php b/tests/Unit/Controllers/Auth/RegisterControllerTest.php index 7130405ee..35385bbb9 100644 --- a/tests/Unit/Controllers/Auth/RegisterControllerTest.php +++ b/tests/Unit/Controllers/Auth/RegisterControllerTest.php @@ -1,10 +1,9 @@ createAdministrator(); + $this->actingAs($employee->user); + + $question = factory(Question::class)->create([ + 'company_id' => $employee->company_id, + ]); + $team = factory(Team::class)->create([ + 'company_id' => $employee->company_id, + ]); + $answer = factory(Answer::class)->create([ + 'question_id' => $question->id, + 'employee_id' => $employee->id, + ]); + + $response = $this->get('/'.$employee->company_id.'/company/questions/'.$question->id.'/teams/'.$team->id); + + $response->assertStatus(200); + + $testJson = new AssertableJsonString($response->viewData('page')['props']); + $testJson->assertFragment([ + 'answer_by_employee' => [ + 'id' => $answer->id, + 'body' => $answer->body, + 'employee_id' => config('database.connections.testing.driver') == 'mysql' ? (int) $employee->id : (string) $employee->id, + 'question_id' => config('database.connections.testing.driver') == 'mysql' ? (int) $question->id : (string) $question->id, + 'created_at' => $answer->created_at, + 'updated_at' => $answer->updated_at, + ], + ]); + } +} diff --git a/tests/Unit/Helpers/LogHelperTest.php b/tests/Unit/Helpers/LogHelperTest.php index ddd4d3b8c..1e7c6748f 100644 --- a/tests/Unit/Helpers/LogHelperTest.php +++ b/tests/Unit/Helpers/LogHelperTest.php @@ -23,8 +23,8 @@ public function it_returns_the_string_explaining_the_audit_log(): void 'action' => 'employee_invited_to_become_user', 'objects' => json_encode([ 'author_id' => $michael->user->id, - 'employee_first_name' => $michael->user->firstname, - 'employee_last_name' => $michael->user->lastname, + 'employee_first_name' => $michael->user->first_name, + 'employee_last_name' => $michael->user->last_name, ]), 'company_id' => $michael->company_id, ]); diff --git a/tests/Unit/Helpers/MoneyHelperTest.php b/tests/Unit/Helpers/MoneyHelperTest.php index 5e3a6d7db..b621214b1 100644 --- a/tests/Unit/Helpers/MoneyHelperTest.php +++ b/tests/Unit/Helpers/MoneyHelperTest.php @@ -15,11 +15,11 @@ public function it_returns_the_amount_correctly_formatted_depending_on_the_curre { $this->assertEquals( 'CA$132.40', - MoneyHelper::format('13240', 'CAD') + MoneyHelper::format(13240, 'CAD') ); //NumberFormatter adds a non-breaking space to it's output (which makes sense for currency), more info here: https://www.php.net/manual/en/numberformatter.formatcurrency.php#118304 - $number = str_replace("\xc2\xa0", ' ', MoneyHelper::format('13240', 'EUR', 'fr_FR')); + $number = str_replace("\xc2\xa0", ' ', MoneyHelper::format(13240, 'EUR', 'fr_FR')); $this->assertEquals( '132,40 €', $number diff --git a/tests/Unit/Jobs/CheckIfPendingExpenseShouldBeMovedToAccountingWhenManagerChangesTest.php b/tests/Unit/Jobs/CheckIfPendingExpenseShouldBeMovedToAccountingWhenManagerChangesTest.php index 794552d3c..71630a86a 100644 --- a/tests/Unit/Jobs/CheckIfPendingExpenseShouldBeMovedToAccountingWhenManagerChangesTest.php +++ b/tests/Unit/Jobs/CheckIfPendingExpenseShouldBeMovedToAccountingWhenManagerChangesTest.php @@ -50,12 +50,12 @@ public function it_moves_all_expenses_for_employees_with_no_managers(): void $this->assertEquals( 1, - $michael->company->expenses()->where('status', Expense::AWAITING_MANAGER_APPROVAL)->get()->count() + $michael->company->expenses()->where('status', Expense::AWAITING_MANAGER_APPROVAL)->count() ); $this->assertEquals( 2, - $michael->company->expenses()->where('status', Expense::AWAITING_ACCOUTING_APPROVAL)->get()->count() + $michael->company->expenses()->where('status', Expense::AWAITING_ACCOUTING_APPROVAL)->count() ); } } diff --git a/tests/Unit/Jobs/ProcessCompanyMoraleTest.php b/tests/Unit/Jobs/ProcessCompanyMoraleTest.php index f7a86cc71..c88497a84 100644 --- a/tests/Unit/Jobs/ProcessCompanyMoraleTest.php +++ b/tests/Unit/Jobs/ProcessCompanyMoraleTest.php @@ -43,7 +43,7 @@ public function it_logs_the_statistics_about_how_employees_feel(): void $this->assertEquals( 1, - MoraleCompanyHistory::get()->count() + MoraleCompanyHistory::count() ); $this->assertDatabaseHas('morale_company_history', [ @@ -57,7 +57,7 @@ public function it_logs_the_statistics_about_how_employees_feel(): void $this->assertEquals( 1, - MoraleCompanyHistory::get()->count() + MoraleCompanyHistory::count() ); } } diff --git a/tests/Unit/Jobs/ProcessTeamMoraleTest.php b/tests/Unit/Jobs/ProcessTeamMoraleTest.php index 79d4257a4..2b316dc18 100644 --- a/tests/Unit/Jobs/ProcessTeamMoraleTest.php +++ b/tests/Unit/Jobs/ProcessTeamMoraleTest.php @@ -62,7 +62,7 @@ public function it_logs_the_statistics_about_how_the_team_feels(): void $this->assertEquals( 1, - MoraleTeamHistory::get()->count() + MoraleTeamHistory::count() ); $this->assertDatabaseHas('morale_team_history', [ @@ -75,7 +75,7 @@ public function it_logs_the_statistics_about_how_the_team_feels(): void $this->assertEquals( 1, - MoraleTeamHistory::get()->count() + MoraleTeamHistory::count() ); } } diff --git a/tests/Unit/Models/Company/AuditLogTest.php b/tests/Unit/Models/Company/AuditLogTest.php index 7a22b5add..5f5ee3aca 100644 --- a/tests/Unit/Models/Company/AuditLogTest.php +++ b/tests/Unit/Models/Company/AuditLogTest.php @@ -48,14 +48,14 @@ public function it_returns_the_content_attribute(): void 'action' => 'employee_invited_to_become_user', 'objects' => json_encode([ 'author_id' => $michael->user->id, - 'employee_first_name' => $michael->user->firstname, - 'employee_last_name' => $michael->user->lastname, + 'employee_first_name' => $michael->user->first_name, + 'employee_last_name' => $michael->user->last_name, ]), 'company_id' => $michael->company_id, ]); $this->assertEquals( - 'Sent an invitation to '.$michael->user->firstname.' '.$michael->user->lastname.' to join the company.', + 'Sent an invitation to '.$michael->user->first_name.' '.$michael->user->last_name.' to join the company.', $auditLog->content ); } diff --git a/tests/Unit/Models/Company/EmployeeTest.php b/tests/Unit/Models/Company/EmployeeTest.php index f93516f82..b251dcd83 100644 --- a/tests/Unit/Models/Company/EmployeeTest.php +++ b/tests/Unit/Models/Company/EmployeeTest.php @@ -427,7 +427,7 @@ public function it_scopes_the_employees_by_the_locked_status(): void $this->assertEquals( 3, - $company->employees()->notLocked()->get()->count() + $company->employees()->notLocked()->count() ); } @@ -639,6 +639,7 @@ public function it_returns_the_current_address(): void 'is_active' => true, ]); + $this->assertNotNull($dwight->getCurrentAddress()); $address = $dwight->getCurrentAddress(); $this->assertInstanceOf( Place::class, diff --git a/tests/Unit/Services/BaseServiceTest.php b/tests/Unit/Services/BaseServiceTest.php index b4d80f4cc..28eb88be1 100644 --- a/tests/Unit/Services/BaseServiceTest.php +++ b/tests/Unit/Services/BaseServiceTest.php @@ -34,8 +34,11 @@ public function it_validates_rules(): void 'street' => 'nullable|string|max:255', ]; - $stub = $this->getMockForAbstractClass(BaseService::class); - $stub->rules([$rules]); + $stub = $this->getMockForAbstractClass(BaseService::class, [], '', true, true, true, ['rules']); + + $stub->expects($this->any()) + ->method('rules') + ->will($this->returnValue($rules)); $this->assertTrue( $stub->validateRules([ @@ -44,6 +47,27 @@ public function it_validates_rules(): void ); } + /** @test */ + public function it_validates_rules_fail(): void + { + $rules = [ + 'street' => 'required|string|max:255', + ]; + + $stub = $this->getMockForAbstractClass(BaseService::class, [], '', true, true, true, ['rules']); + + $stub->expects($this->any()) + ->method('rules') + ->will($this->returnValue($rules)); + + $this->expectException(\Illuminate\Validation\ValidationException::class); + $this->assertFalse( + $stub->validateRules([ + 'street' => null, + ]) + ); + } + /** @test */ public function it_validates_that_the_employee_belongs_to_the_company(): void { @@ -180,7 +204,6 @@ public function it_validates_the_right_to_execute_the_service(): void $this->assertTrue( $stub->author($michael->id) ->inCompany($michael->company_id) - ->bypassPermissionLevel() ->canExecuteService() ); diff --git a/tests/Unit/Services/Company/Adminland/Expense/AllowEmployeeToManageExpensesTest.php b/tests/Unit/Services/Company/Adminland/Expense/AllowEmployeeToManageExpensesTest.php index 825307094..767d0caba 100644 --- a/tests/Unit/Services/Company/Adminland/Expense/AllowEmployeeToManageExpensesTest.php +++ b/tests/Unit/Services/Company/Adminland/Expense/AllowEmployeeToManageExpensesTest.php @@ -84,7 +84,7 @@ private function executeService(Employee $michael, Employee $dwight): void ]); }); - Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael, $dwight) { + Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael) { return $job->auditLog['action'] === 'employee_allowed_to_manage_expenses' && $job->auditLog['author_id'] === $michael->id && $job->auditLog['objects'] === json_encode([]); diff --git a/tests/Unit/Services/Company/Adminland/Expense/DisallowEmployeeToManageExpensesTest.php b/tests/Unit/Services/Company/Adminland/Expense/DisallowEmployeeToManageExpensesTest.php index f8c54f156..4fce439f3 100644 --- a/tests/Unit/Services/Company/Adminland/Expense/DisallowEmployeeToManageExpensesTest.php +++ b/tests/Unit/Services/Company/Adminland/Expense/DisallowEmployeeToManageExpensesTest.php @@ -83,7 +83,7 @@ private function executeService(Employee $michael, Employee $dwight): void ]); }); - Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael, $dwight) { + Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael) { return $job->auditLog['action'] === 'employee_disallowed_to_manage_expenses' && $job->auditLog['author_id'] === $michael->id && $job->auditLog['objects'] === json_encode([]); diff --git a/tests/Unit/Services/Company/Employee/Expense/CreateExpenseTest.php b/tests/Unit/Services/Company/Employee/Expense/CreateExpenseTest.php index 692e7c5be..ef01e4aba 100644 --- a/tests/Unit/Services/Company/Employee/Expense/CreateExpenseTest.php +++ b/tests/Unit/Services/Company/Employee/Expense/CreateExpenseTest.php @@ -106,7 +106,7 @@ public function it_fails_if_employee_doesnt_belong_to_authors_company(): void public function it_fails_if_expense_category_is_not_in_the_company(): void { $michael = $this->createAdministrator(); - $dwight = $this->createEmployee($michael); + $dwight = $this->createEmployee(); $category = factory(ExpenseCategory::class)->create(); $this->expectException(ModelNotFoundException::class); @@ -157,7 +157,7 @@ private function executeService(Employee $michael, Employee $dwight, ExpenseCate $expense ); - Queue::assertPushed(LogAccountAudit::class, function ($job) use ($michael, $dwight, $expense) { + Queue::assertPushed(LogAccountAudit::class, function ($job) use ($michael, $expense) { return $job->auditLog['action'] === 'expense_created' && $job->auditLog['author_id'] === $michael->id && $job->auditLog['objects'] === json_encode([ diff --git a/tests/Unit/Services/Company/Employee/PersonalDetails/SetSlackHandleTest.php b/tests/Unit/Services/Company/Employee/PersonalDetails/SetSlackHandleTest.php index 6225aadb9..cec1df081 100644 --- a/tests/Unit/Services/Company/Employee/PersonalDetails/SetSlackHandleTest.php +++ b/tests/Unit/Services/Company/Employee/PersonalDetails/SetSlackHandleTest.php @@ -107,7 +107,7 @@ private function executeService(Employee $michael, Employee $dwight): void ]); }); - Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael, $dwight) { + Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael) { return $job->auditLog['action'] === 'slack_set' && $job->auditLog['author_id'] === $michael->id && $job->auditLog['objects'] === json_encode([ @@ -143,7 +143,7 @@ private function executeService(Employee $michael, Employee $dwight): void ]); }); - Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael, $dwight) { + Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael) { return $job->auditLog['action'] === 'slack_reset' && $job->auditLog['author_id'] === $michael->id && $job->auditLog['objects'] === json_encode([]); diff --git a/tests/Unit/Services/Company/Employee/PersonalDetails/SetTwitterHandleTest.php b/tests/Unit/Services/Company/Employee/PersonalDetails/SetTwitterHandleTest.php index e66cba2a5..f11003053 100644 --- a/tests/Unit/Services/Company/Employee/PersonalDetails/SetTwitterHandleTest.php +++ b/tests/Unit/Services/Company/Employee/PersonalDetails/SetTwitterHandleTest.php @@ -107,7 +107,7 @@ private function executeService(Employee $michael, Employee $dwight): void ]); }); - Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael, $dwight) { + Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael) { return $job->auditLog['action'] === 'twitter_set' && $job->auditLog['author_id'] === $michael->id && $job->auditLog['objects'] === json_encode([ @@ -143,7 +143,7 @@ private function executeService(Employee $michael, Employee $dwight): void ]); }); - Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael, $dwight) { + Queue::assertPushed(LogEmployeeAudit::class, function ($job) use ($michael) { return $job->auditLog['action'] === 'twitter_reset' && $job->auditLog['author_id'] === $michael->id && $job->auditLog['objects'] === json_encode([]); diff --git a/tests/Unit/Services/Company/Project/CreateProjectStatusTest.php b/tests/Unit/Services/Company/Project/CreateProjectStatusTest.php index 40454cced..299f1fb11 100644 --- a/tests/Unit/Services/Company/Project/CreateProjectStatusTest.php +++ b/tests/Unit/Services/Company/Project/CreateProjectStatusTest.php @@ -110,7 +110,7 @@ private function executeService(Employee $michael, Project $project): void $projectStatus ); - Queue::assertPushed(LogAccountAudit::class, function ($job) use ($michael, $project, $projectStatus) { + Queue::assertPushed(LogAccountAudit::class, function ($job) use ($michael, $project) { return $job->auditLog['action'] === 'project_status_created' && $job->auditLog['author_id'] === $michael->id && $job->auditLog['objects'] === json_encode([ diff --git a/tests/Unit/ViewHelpers/Adminland/AdminEmployeeViewHelperTest.php b/tests/Unit/ViewHelpers/Adminland/AdminEmployeeViewHelperTest.php index c4ef4e18a..034fb9fda 100644 --- a/tests/Unit/ViewHelpers/Adminland/AdminEmployeeViewHelperTest.php +++ b/tests/Unit/ViewHelpers/Adminland/AdminEmployeeViewHelperTest.php @@ -61,7 +61,7 @@ public function it_gets_information_about_all_employees_in_the_company(): void 'permission_level' => $michael->permission_level, 'avatar' => $michael->avatar, 'invitation_link' => $michael->invitation_link, - 'invited' => ! $michael->invitation_used_at && $michael->invitation_link ? true : false, + 'invited' => (bool) (! $michael->invitation_used_at && $michael->invitation_link), 'lock_status' => $michael->locked, 'url_view' => route('employees.show', [ 'company' => $michael->company, diff --git a/tests/Unit/ViewHelpers/Adminland/AdminHardwareViewHelperTest.php b/tests/Unit/ViewHelpers/Adminland/AdminHardwareViewHelperTest.php index a7edef6ff..96bd608bc 100644 --- a/tests/Unit/ViewHelpers/Adminland/AdminHardwareViewHelperTest.php +++ b/tests/Unit/ViewHelpers/Adminland/AdminHardwareViewHelperTest.php @@ -161,8 +161,6 @@ public function it_gets_the_information_about_lent_hardware_in_the_company(): vo $this->assertArraySubset( [ - 'id' => $androidPhone->id, - 'name' => 'iOS phone', 'id' => $iosPhone->id, 'name' => 'iOS phone', 'employee' => [ diff --git a/tests/Unit/ViewHelpers/Dashboard/DashboardManagerViewHelperTest.php b/tests/Unit/ViewHelpers/Dashboard/DashboardManagerViewHelperTest.php index ca3b168ab..01129cdda 100644 --- a/tests/Unit/ViewHelpers/Dashboard/DashboardManagerViewHelperTest.php +++ b/tests/Unit/ViewHelpers/Dashboard/DashboardManagerViewHelperTest.php @@ -144,9 +144,9 @@ public function it_gets_a_collection_of_one_on_ones_for_direct_reports(): void 'position' => $dwight->position->title, 'url' => env('APP_URL').'/'.$dwight->company_id.'/employees/'.$dwight->id, 'entry' => [ - 'id' => OneOnOneEntry::all()->first()->id, + 'id' => OneOnOneEntry::first()->id, 'happened_at' => '2018-01-01', - 'url' => env('APP_URL').'/'.$dwight->company_id.'/dashboard/oneonones/'.OneOnOneEntry::all()->first()->id, + 'url' => env('APP_URL').'/'.$dwight->company_id.'/dashboard/oneonones/'.OneOnOneEntry::first()->id, ], ], 1 => [ @@ -156,9 +156,9 @@ public function it_gets_a_collection_of_one_on_ones_for_direct_reports(): void 'position' => $jim->position->title, 'url' => env('APP_URL').'/'.$jim->company_id.'/employees/'.$jim->id, 'entry' => [ - 'id' => OneOnOneEntry::all()->last()->id, + 'id' => OneOnOneEntry::orderBy('id', 'desc')->first()->id, 'happened_at' => '2018-01-01', - 'url' => env('APP_URL').'/'.$dwight->company_id.'/dashboard/oneonones/'.OneOnOneEntry::all()->last()->id, + 'url' => env('APP_URL').'/'.$dwight->company_id.'/dashboard/oneonones/'.OneOnOneEntry::orderBy('id', 'desc')->first()->id, ], ], ], diff --git a/tests/Unit/ViewHelpers/Dashboard/DashboardMeViewHelperTest.php b/tests/Unit/ViewHelpers/Dashboard/DashboardMeViewHelperTest.php index d3eee35cb..05d816786 100644 --- a/tests/Unit/ViewHelpers/Dashboard/DashboardMeViewHelperTest.php +++ b/tests/Unit/ViewHelpers/Dashboard/DashboardMeViewHelperTest.php @@ -143,8 +143,7 @@ public function it_gets_all_the_expense_categories_in_the_given_company(): void /** @test */ public function it_gets_a_collection_of_currencies(): void { - $michael = $this->createAdministrator(); - $response = DashboardMeViewHelper::currencies($michael->company); + $response = DashboardMeViewHelper::currencies(); $this->assertEquals( 179, @@ -264,8 +263,8 @@ public function it_gets_a_collection_of_managers(): void 'position' => $dwight->position->title, 'url' => env('APP_URL').'/'.$dwight->company_id.'/employees/'.$dwight->id, 'entry' => [ - 'id' => OneOnOneEntry::all()->first()->id, - 'url' => env('APP_URL').'/'.$dwight->company_id.'/dashboard/oneonones/'.OneOnOneEntry::all()->first()->id, + 'id' => OneOnOneEntry::first()->id, + 'url' => env('APP_URL').'/'.$dwight->company_id.'/dashboard/oneonones/'.OneOnOneEntry::first()->id, ], ], 1 => [ @@ -275,8 +274,8 @@ public function it_gets_a_collection_of_managers(): void 'position' => $michael->position->title, 'url' => env('APP_URL').'/'.$michael->company_id.'/employees/'.$michael->id, 'entry' => [ - 'id' => OneOnOneEntry::all()->last()->id, - 'url' => env('APP_URL').'/'.$dwight->company_id.'/dashboard/oneonones/'.OneOnOneEntry::all()->last()->id, + 'id' => OneOnOneEntry::orderBy('id', 'desc')->first()->id, + 'url' => env('APP_URL').'/'.$dwight->company_id.'/dashboard/oneonones/'.OneOnOneEntry::orderBy('id', 'desc')->first()->id, ], ], ], diff --git a/tests/Unit/ViewHelpers/Employee/EmployeeShowViewHelperTest.php b/tests/Unit/ViewHelpers/Employee/EmployeeShowViewHelperTest.php index bbd18dc3e..c52df82c7 100644 --- a/tests/Unit/ViewHelpers/Employee/EmployeeShowViewHelperTest.php +++ b/tests/Unit/ViewHelpers/Employee/EmployeeShowViewHelperTest.php @@ -251,7 +251,6 @@ public function it_gets_the_work_from_home_statistics(): void [ 'work_from_home_today' => true, 'number_times_this_year' => 3, - 'url' => 'dfsd', 'url' => env('APP_URL').'/'.$michael->company_id.'/employees/'.$michael->id.'/workfromhome', ], $array