Comments & Discussion
Hi there, thanks for the course!
Today, I cloned the repo, ran tests, and got an error in test_employee_timesheet_report.
It happens because of this condition (today is the 1st February):
->where('start', '>=', now()->startOfMonth())
app/tests/Feature/GrouppingExamples/TimesheetReportTest.php:57
Maybe it's not the best solution, you shall travel in time in the begining of function:
$this->travelTo(now()->setDay(15));
Like it was in the lesson Travel in Time to Reproduce Test Scenarios of Advanced Laravel Testing course.
Also, maybe someone already noticed it, in test_the_application_returns_a_successful_response get 302 status because of:
Route::get('/', function () { return to_route('dashboard');});
app/routes/web.php:37
Thanks!
Hi, thank you for your comment! It is always nice to see people using multiple courses to reference things that might be off, thank you for that!
As per the issue - I will have to check and see if any adjustments are needed, but this just proves that working with dates is hard :) What works one day, might not function on a specific race-condition day.
I noticed that for each
select, you added a->addSelect(), but it's possible to leave everything grouped. These are just choices on how to write the code, right?At first I'm using it in my code like this:
You can definitely add them to a single function (this was done for readability and clarity), but keep in mind that it has to be:
->addSelect([])and not just->select()Or in other words:
Oops, Thanks for that observation, I didn't know that. At first the code worked perfectly as I had done, not even PHPStan on level 6 showed anything.
But I will correct.