mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-21 06:19:38 +08:00
Update tests for middleware
This commit is contained in:
parent
946e0c12e3
commit
3e5e2cc0ec
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\Facades\Option;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
@ -34,14 +35,29 @@ class MiddlewareTest extends TestCase
|
||||
'token' => $noEmailUser->getToken()
|
||||
])->visit('/user')->see('Bind')->dontSee('User Center');
|
||||
|
||||
$this->actAs($noEmailUser)
|
||||
->get('/user?email=email')
|
||||
->see('Bind');
|
||||
|
||||
$other = factory(User::class)->create();
|
||||
$this->actAs($noEmailUser)
|
||||
->get('/user?email='.$other->email)
|
||||
->see(trans('auth.bind.registered'));
|
||||
|
||||
$this->actAs($noEmailUser)
|
||||
->get('/user?email=a@b.c')
|
||||
->see('User Center');
|
||||
$this->assertEquals('a@b.c', User::find($noEmailUser->uid)->email);
|
||||
|
||||
// Without token
|
||||
$this->withSession([
|
||||
'uid' => 0
|
||||
])->visit('/user')->seePageIs('/auth/login');
|
||||
|
||||
// Without invalid token
|
||||
$user = factory(User::class)->create();
|
||||
$this->withSession([
|
||||
'uid' => 0,
|
||||
'uid' => $user->uid,
|
||||
'token' => 'invalid'
|
||||
])->visit('/user')->seePageIs('/auth/login');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user