-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize unit tests and add feature tests for blade view
- Loading branch information
1 parent
1a5cfcb
commit a2313ba
Showing
19 changed files
with
568 additions
and
60 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
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
This file was deleted.
Oops, something went wrong.
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,56 @@ | ||
<?php namespace GeneaLabs\LaravelImpersonator\Tests\Feature; | ||
|
||
use GeneaLabs\LaravelImpersonator\Tests\Fixtures\User; | ||
use GeneaLabs\LaravelImpersonator\Tests\FeatureTestCase; | ||
|
||
class ImpersonationTest extends FeatureTestCase | ||
{ | ||
public function testImpersonatingPageLoads() | ||
{ | ||
$user = factory(User::class)->create([ | ||
'canImpersonate' => true, | ||
'canBeImpersonated' => false, | ||
]); | ||
|
||
$response = $this | ||
->actingAs($user) | ||
->get(route('impersonatees.index')); | ||
|
||
$response->assertResponseOk(); | ||
} | ||
|
||
public function testImpersonatableUsersAreListed() | ||
{ | ||
config(['genealabs-laravel-impersonator.user-model' => User::class]); | ||
$user = factory(User::class)->create([ | ||
'canImpersonate' => true, | ||
'canBeImpersonated' => false, | ||
]); | ||
$users = factory(User::class, 10)->create(); | ||
|
||
$response = $this | ||
->actingAs($user) | ||
->get(route('impersonatees.index')); | ||
|
||
$response->assertResponseOk(); | ||
foreach ($users as $user) { | ||
$response->see(htmlspecialchars($user->name)); | ||
} | ||
} | ||
|
||
public function testUserCanBeImpersonated() | ||
{ | ||
config(['genealabs-laravel-impersonator.user-model' => User::class]); | ||
$user = factory(User::class)->create([ | ||
'canImpersonate' => true, | ||
'canBeImpersonated' => false, | ||
]); | ||
$users = factory(User::class, 10)->create(); | ||
|
||
$response = $this->actingAs($user) | ||
->visit(route('impersonatees.index')) | ||
->press($users->first()->name); | ||
|
||
$response->assertSessionHas('impersonator', $user); | ||
} | ||
} |
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,13 @@ | ||
<?php namespace GeneaLabs\LaravelImpersonator\Tests; | ||
|
||
use Illuminate\Foundation\Testing\WithoutMiddleware; | ||
use Illuminate\Foundation\Testing\DatabaseMigrations; | ||
use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
use Laravel\BrowserKitTesting\TestCase; | ||
|
||
abstract class FeatureTestCase extends TestCase | ||
{ | ||
use CreatesApplication; | ||
use DatabaseMigrations; | ||
use DatabaseTransactions; | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
|
||
class HomeController extends Controller | ||
{ | ||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('auth'); | ||
} | ||
|
||
/** | ||
* Show the application dashboard. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index() | ||
{ | ||
return view('home'); | ||
} | ||
} |
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,69 @@ | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-8 col-md-offset-2"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Login</div> | ||
|
||
<div class="panel-body"> | ||
<form class="form-horizontal" method="POST" action="{{ route('login') }}"> | ||
{{ csrf_field() }} | ||
|
||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> | ||
<label for="email" class="col-md-4 control-label">E-Mail Address</label> | ||
|
||
<div class="col-md-6"> | ||
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus> | ||
|
||
@if ($errors->has('email')) | ||
<span class="help-block"> | ||
<strong>{{ $errors->first('email') }}</strong> | ||
</span> | ||
@endif | ||
</div> | ||
</div> | ||
|
||
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> | ||
<label for="password" class="col-md-4 control-label">Password</label> | ||
|
||
<div class="col-md-6"> | ||
<input id="password" type="password" class="form-control" name="password" required> | ||
|
||
@if ($errors->has('password')) | ||
<span class="help-block"> | ||
<strong>{{ $errors->first('password') }}</strong> | ||
</span> | ||
@endif | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<div class="col-md-6 col-md-offset-4"> | ||
<div class="checkbox"> | ||
<label> | ||
<input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<div class="col-md-8 col-md-offset-4"> | ||
<button type="submit" class="btn btn-primary"> | ||
Login | ||
</button> | ||
|
||
<a class="btn btn-link" href="{{ route('password.request') }}"> | ||
Forgot Your Password? | ||
</a> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection |
47 changes: 47 additions & 0 deletions
47
tests/Fixtures/resources/views/auth/passwords/email.blade.php
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,47 @@ | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-8 col-md-offset-2"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Reset Password</div> | ||
|
||
<div class="panel-body"> | ||
@if (session('status')) | ||
<div class="alert alert-success"> | ||
{{ session('status') }} | ||
</div> | ||
@endif | ||
|
||
<form class="form-horizontal" method="POST" action="{{ route('password.email') }}"> | ||
{{ csrf_field() }} | ||
|
||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> | ||
<label for="email" class="col-md-4 control-label">E-Mail Address</label> | ||
|
||
<div class="col-md-6"> | ||
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required> | ||
|
||
@if ($errors->has('email')) | ||
<span class="help-block"> | ||
<strong>{{ $errors->first('email') }}</strong> | ||
</span> | ||
@endif | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<div class="col-md-6 col-md-offset-4"> | ||
<button type="submit" class="btn btn-primary"> | ||
Send Password Reset Link | ||
</button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection |
Oops, something went wrong.