Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

caneara/lumeno

14 stars
1 code files
View caneara/lumeno on GitHub

tests/Acceptance/User/DashboardTest.php

Open in GitHub
use App\Models\User;
use App\Types\Browser;
use App\Types\ClientTest;
use Illuminate\Support\Str;
 
class DashboardTest extends ClientTest
{
/**
* Determine the relevant greeting to show based on the time of day.
*
*/
protected function greeting() : string
{
$time_zone = shell_exec('date +"%z"');
 
$offset = (int) substr($time_zone, 1, 2);
 
$method = Str::startsWith($time_zone, '+') ? 'addHours' : 'subHours';
 
$hour = now()->$method($offset)->hour;
 
return $hour < 12 ? 'morning' : ($hour < 18 ? 'afternoon' : 'evening');
}
 
/** @test */
public function a_user_can_view_the_dashboard_page() : void
{
$this->browse(function(Browser $browser) {
$user = User::factory()
->create(['name' => 'John Doe']);
 
$browser->loginAs($user)
->visitRoute('dashboard.user')
->assertTitle('Dashboard');
 
$browser->assertSee("Good {$this->greeting()}, {$user->name}");
});
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.