Skip to main content

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

Read more here

laravelio/laravel.io

2497 stars
1 code files
View laravelio/laravel.io on GitHub

tests/Feature/ProfileTest.php

Open in GitHub
use Illuminate\Foundation\Testing\DatabaseMigrations;
 
class ProfileTest extends BrowserKitTestCase
{
use DatabaseMigrations;
 
/** @test */
public function anyone_can_see_a_user_profile()
{
$this->createUser();
 
$this->visit('/user/johndoe')
->see('John Doe');
}
 
/** @test */
public function admin_buttons_are_not_shown_to_logged_out_users()
{
$this->createUser();
 
$this->visit('/user/johndoe')
->dontSee('Ban user')
->dontSee('Unban user')
->dontSee('Delete user');
}
 
/** @test */
public function admin_buttons_are_not_shown_to_non_admin_users()
{
$this->login();
 
$this->visit('/user/johndoe')
->dontSee('Ban user')
->dontSee('Unban user')
->dontSee('Delete user');
}
 
/** @test */
public function admin_buttons_are_shown_to_admin_users()
{
$this->createUser([
'username' => 'janedoe',
'email' => '[email protected]',
]);
$this->loginAsAdmin();
 
$this->visit('/user/janedoe')
->see('Ban user')
->see('Delete user');
}
 
/** @test */
public function delete_button_is_not_shown_to_moderators()
{
$this->createUser([
'username' => 'janedoe',
'email' => '[email protected]',
]);
$this->loginAsModerator();
 
$this->visit('/user/janedoe')
->see('Ban user')
->dontSee('Delete user');
}
}

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.