forked from puncoz-bookmarks/laravel-mailcoach-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8b80f1
commit d43fc5a
Showing
3 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Spatie\Mailcoach\Tests\Http\Middleware; | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use Spatie\Mailcoach\Tests\TestCase; | ||
|
||
class AuthenticateTest extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Route::get('login')->name('login'); | ||
|
||
$this->withExceptionHandling(); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_use_the_default_guard() | ||
{ | ||
$this->get(route('mailcoach.campaigns'))->assertRedirect(route('login')); | ||
} | ||
|
||
/** @test */ | ||
public function the_default_behaviour_works() | ||
{ | ||
$this->authenticate(); | ||
|
||
$this->get(route('mailcoach.campaigns'))->assertSuccessful(); | ||
} | ||
|
||
/** @test */ | ||
public function it_will_fail_when_authentication_with_a_wrong_guard() | ||
{ | ||
config()->set('mailcoach.guard', 'api'); | ||
|
||
$this->authenticate('web'); | ||
|
||
$this->get(route('mailcoach.campaigns'))->assertRedirect(route('login')); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_authenticate_using_the_guard_specified_in_the_config_file() | ||
{ | ||
config()->set('mailcoach.guard', 'api'); | ||
|
||
$this->authenticate('api'); | ||
|
||
$this->get(route('mailcoach.campaigns'))->assertSuccessful(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters