-
Notifications
You must be signed in to change notification settings - Fork 4
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
1523cb1
commit 7877f18
Showing
6 changed files
with
96 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@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"><h1>Create blog post</h1></div> | ||
|
||
<div class="panel-body"> | ||
<form method="post" action="/post"> | ||
{{ csrf_field() }} | ||
<div class="form-group"> | ||
<label for="title">Title</label> | ||
<input type="text" name="title" class="form-control"/> | ||
</div> | ||
<div class="form-group"> | ||
<label for="body">Body</label> | ||
<textarea name="body" rows="8" class="form-control"></textarea> | ||
</div> | ||
<input type="submit" class="btn btn-block btn-primary"> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection |
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,43 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use Tests\TestCase; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
|
||
class CreaetPostTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
public function test_a_user_can_create_post(){ | ||
$this->withoutExceptionHandling(); | ||
// Given a Guest | ||
$guest = factory('App\User')->create(); | ||
// make a guest become User | ||
$user = $this->be($guest); | ||
// And Giving Post object | ||
$post = factory('App\Post')->make(); | ||
// When the user create Post | ||
$this->post('/post',$post->toArray()); | ||
// When their redirect to post | ||
$response = $this->get('/blog/'.$post->id); | ||
// Then their should see post | ||
$response->assertSee($post->title); | ||
} | ||
public function test_a_guest_can_not_create_post(){ | ||
$this->withoutExceptionHandling(); | ||
// expect thrown exception | ||
$this->expectException('Illuminate\Auth\AuthenticationException'); | ||
// Given a Guest | ||
$guest = factory('App\User')->create(); | ||
// And Giving Post object | ||
$post = factory('App\Post')->make(); | ||
// When the user create Post | ||
$this->post('/post',$post->toArray()); | ||
|
||
} | ||
public function test_a_guest_can_not_access_create_post_page(){ | ||
$this->get('/blog/create') | ||
->assertRedirect('/login'); | ||
} | ||
} |
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