Update tests for middleware
This commit is contained in:
parent
946e0c12e3
commit
3e5e2cc0ec
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use App\Services\Facades\Option;
|
use App\Services\Facades\Option;
|
||||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
|
|
@ -34,14 +35,29 @@ class MiddlewareTest extends TestCase
|
||||||
'token' => $noEmailUser->getToken()
|
'token' => $noEmailUser->getToken()
|
||||||
])->visit('/user')->see('Bind')->dontSee('User Center');
|
])->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
|
// Without token
|
||||||
$this->withSession([
|
$this->withSession([
|
||||||
'uid' => 0
|
'uid' => 0
|
||||||
])->visit('/user')->seePageIs('/auth/login');
|
])->visit('/user')->seePageIs('/auth/login');
|
||||||
|
|
||||||
// Without invalid token
|
// Without invalid token
|
||||||
|
$user = factory(User::class)->create();
|
||||||
$this->withSession([
|
$this->withSession([
|
||||||
'uid' => 0,
|
'uid' => $user->uid,
|
||||||
'token' => 'invalid'
|
'token' => 'invalid'
|
||||||
])->visit('/user')->seePageIs('/auth/login');
|
])->visit('/user')->seePageIs('/auth/login');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user