Unverified Commit 48809bd4 authored by Vipul Basapati's avatar Vipul Basapati Committed by GitHub

Merge pull request #124 from bvipul/develop

Blog Tags Test complete
parents 8b8ac133 1c2ee785
......@@ -62,7 +62,7 @@ class BlogCategoriesController extends Controller
}
/**
* @param \App\Models\BlogCategories\BlogCategory $blogcategory
* @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest $request
*
* @return mixed
......@@ -74,7 +74,7 @@ class BlogCategoriesController extends Controller
}
/**
* @param \App\Models\BlogCategories\BlogCategory $blogcategory
* @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest $request
*
* @return mixed
......@@ -89,7 +89,7 @@ class BlogCategoriesController extends Controller
}
/**
* @param \App\Models\BlogCategories\BlogCategory $blogcategory
* @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest $request
*
* @return mixed
......
......@@ -60,49 +60,49 @@ class BlogTagsController extends Controller
$this->blogtag->create($request->except('token'));
return redirect()
->route('admin.blogtags.index')
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.created'));
}
/**
* @param \App\Models\BlogTags\BlogTag $blogtag
* @param \App\Models\BlogTags\BlogTag $blogTag
* @param \App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest $request
*
* @return mixed
*/
public function edit(BlogTag $blogtag, EditBlogTagsRequest $request)
public function edit(BlogTag $blogTag, EditBlogTagsRequest $request)
{
return view('backend.blogtags.edit')
->with('blogtag', $blogtag);
->with('blogtag', $blogTag);
}
/**
* @param \App\Models\BlogTags\BlogTag $blogtag
* @param \App\Models\BlogTags\BlogTag $blogTag
* @param \App\Http\Requests\Backend\BlogTags\UpdateBlogTagsRequest $request
*
* @return mixed
*/
public function update(BlogTag $blogtag, UpdateBlogTagsRequest $request)
public function update(BlogTag $blogTag, UpdateBlogTagsRequest $request)
{
$this->blogtag->update($blogtag, $request->except(['_method', '_token']));
$this->blogtag->update($blogTag, $request->except(['_method', '_token']));
return redirect()
->route('admin.blogtags.index')
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.updated'));
}
/**
* @param \App\Models\BlogTags\BlogTag $blogtag
* @param \App\Models\BlogTags\BlogTag $blogTag
* @param \App\Http\Requests\Backend\BlogTags\DeleteBlogTagsRequest $request
*
* @return mixed
*/
public function destroy(BlogTag $blogtag, DeleteBlogTagsRequest $request)
public function destroy(BlogTag $blogTag, DeleteBlogTagsRequest $request)
{
$this->blogtag->delete($blogtag);
$this->blogtag->delete($blogTag);
return redirect()
->route('admin.blogtags.index')
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.deleted'));
}
}
......@@ -12,8 +12,8 @@ trait BlogCategoryRelationship
/**
* BlogCategories belongs to relationship with state.
*/
public function createdBy()
public function creator()
{
return $this->belongsTo(User::class, 'created_by', 'id');
return $this->belongsTo(User::class, 'created_by');
}
}
......@@ -12,8 +12,8 @@ trait BlogTagRelationship
/**
* BlogTags belongs to relationship with state.
*/
public function createdBy()
public function creator()
{
return $this->belongsTo(User::class, 'created_by', 'id');
return $this->belongsTo(User::class, 'created_by');
}
}
<?php
use Faker\Generator as Faker;
use App\Models\BlogTags\BlogTag;
use App\Models\Access\User\User;
$factory->define(BlogTag::class, function (Faker $faker) {
return [
'name' => $faker->word,
'status' => $faker->numberBetween(0,1),
'created_by' => function () {
return factory(User::class)->create()->id;
}
];
});
......@@ -16,7 +16,7 @@ class CreateBlogCategoriesTable extends Migration
$table->increments('id');
$table->string('name', 191);
$table->boolean('status')->default(1);
$table->integer('created_by')->unsigned()->nullable();
$table->integer('created_by')->unsigned();
$table->integer('updated_by')->unsigned()->nullable();
$table->timestamps();
$table->softDeletes();
......
......@@ -18,7 +18,7 @@ class MenuTableSeeder extends Seeder
'id' => 1,
'type' => 'backend',
'name' => 'Backend Sidebar Menu',
'items' => '[{"view_permission_id":"view-access-management","icon":"fa-users","open_in_new_tab":0,"url_type":"route","url":"","name":"Access Management","id":11,"content":"Access Management","children":[{"view_permission_id":"view-user-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.user.index","name":"User Management","id":12,"content":"User Management"},{"view_permission_id":"view-role-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.role.index","name":"Role Management","id":13,"content":"Role Management"},{"view_permission_id":"view-permission-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.permission.index","name":"Permission Management","id":14,"content":"Permission Management"}]},{"view_permission_id":"view-module","icon":"fa-wrench","open_in_new_tab":0,"url_type":"route","url":"admin.modules.index","name":"Module","id":1,"content":"Module"},{"view_permission_id":"view-menu","icon":"fa-bars","open_in_new_tab":0,"url_type":"route","url":"admin.menus.index","name":"Menus","id":3,"content":"Menus"},{"view_permission_id":"view-page","icon":"fa-file-text","open_in_new_tab":0,"url_type":"route","url":"admin.pages.index","name":"Pages","id":2,"content":"Pages"},{"view_permission_id":"view-email-template","icon":"fa-envelope","open_in_new_tab":0,"url_type":"route","url":"admin.emailtemplates.index","name":"Email Templates","id":8,"content":"Email Templates"},{"view_permission_id":"edit-settings","icon":"fa-gear","open_in_new_tab":0,"url_type":"route","url":"admin.settings.edit?id=1","name":"Settings","id":9,"content":"Settings"},{"view_permission_id":"view-blog","icon":"fa-commenting","open_in_new_tab":0,"url_type":"route","url":"","name":"Blog Management","id":15,"content":"Blog Management","children":[{"view_permission_id":"view-blog-category","open_in_new_tab":0,"url_type":"route","url":"admin.blogCategories.index","name":"Blog Category Management","id":16,"content":"Blog Category Management"},{"view_permission_id":"view-blog-tag","open_in_new_tab":0,"url_type":"route","url":"admin.blogtags.index","name":"Blog Tag Management","id":17,"content":"Blog Tag Management"},{"view_permission_id":"view-blog","open_in_new_tab":0,"url_type":"route","url":"admin.blogs.index","name":"Blog Management","id":18,"content":"Blog Management"}]},{"view_permission_id":"view-faq","icon":"fa-question-circle","open_in_new_tab":0,"url_type":"route","url":"admin.faqs.index","name":"Faq Management","id":19,"content":"Faq Management"}]',
'items' => '[{"view_permission_id":"view-access-management","icon":"fa-users","open_in_new_tab":0,"url_type":"route","url":"","name":"Access Management","id":11,"content":"Access Management","children":[{"view_permission_id":"view-user-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.user.index","name":"User Management","id":12,"content":"User Management"},{"view_permission_id":"view-role-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.role.index","name":"Role Management","id":13,"content":"Role Management"},{"view_permission_id":"view-permission-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.permission.index","name":"Permission Management","id":14,"content":"Permission Management"}]},{"view_permission_id":"view-module","icon":"fa-wrench","open_in_new_tab":0,"url_type":"route","url":"admin.modules.index","name":"Module","id":1,"content":"Module"},{"view_permission_id":"view-menu","icon":"fa-bars","open_in_new_tab":0,"url_type":"route","url":"admin.menus.index","name":"Menus","id":3,"content":"Menus"},{"view_permission_id":"view-page","icon":"fa-file-text","open_in_new_tab":0,"url_type":"route","url":"admin.pages.index","name":"Pages","id":2,"content":"Pages"},{"view_permission_id":"view-email-template","icon":"fa-envelope","open_in_new_tab":0,"url_type":"route","url":"admin.emailtemplates.index","name":"Email Templates","id":8,"content":"Email Templates"},{"view_permission_id":"edit-settings","icon":"fa-gear","open_in_new_tab":0,"url_type":"route","url":"admin.settings.edit?id=1","name":"Settings","id":9,"content":"Settings"},{"view_permission_id":"view-blog","icon":"fa-commenting","open_in_new_tab":0,"url_type":"route","url":"","name":"Blog Management","id":15,"content":"Blog Management","children":[{"view_permission_id":"view-blog-category","open_in_new_tab":0,"url_type":"route","url":"admin.blogCategories.index","name":"Blog Category Management","id":16,"content":"Blog Category Management"},{"view_permission_id":"view-blog-tag","open_in_new_tab":0,"url_type":"route","url":"admin.blogTags.index","name":"Blog Tag Management","id":17,"content":"Blog Tag Management"},{"view_permission_id":"view-blog","open_in_new_tab":0,"url_type":"route","url":"admin.blogs.index","name":"Blog Management","id":18,"content":"Blog Management"}]},{"view_permission_id":"view-faq","icon":"fa-question-circle","open_in_new_tab":0,"url_type":"route","url":"admin.faqs.index","name":"Faq Management","id":19,"content":"Faq Management"}]',
'created_by' => 1,
'created_at' => Carbon::now(),
];
......
......@@ -10,7 +10,7 @@
@endsection
@section('content')
{{ Form::open(['route' => 'admin.blogtags.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-permission']) }}
{{ Form::open(['route' => 'admin.blogTags.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-blogtags']) }}
<div class="box box-info">
<div class="box-header with-border">
......@@ -26,7 +26,7 @@
<div class="form-group">
@include("backend.blogtags.form")
<div class="edit-form-btn">
{{ link_to_route('admin.blogtags.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ link_to_route('admin.blogTags.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.create'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div>
</div>
......
......@@ -10,7 +10,7 @@
@endsection
@section('content')
{{ Form::model($blogtag, ['route' => ['admin.blogtags.update', $blogtag], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-role']) }}
{{ Form::model($blogtag, ['route' => ['admin.blogTags.update', $blogtag], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-blogtags']) }}
<div class="box box-info">
<div class="box-header with-border">
......@@ -26,7 +26,7 @@
<div class="form-group">
@include("backend.blogtags.form")
<div class="edit-form-btn">
{{ link_to_route('admin.blogtags.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ link_to_route('admin.blogTags.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.update'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div>
</div>
......
......@@ -70,7 +70,7 @@
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.blogtags.get") }}',
url: '{{ route("admin.blogTags.get") }}',
type: 'post'
},
columns: [
......
<!--Action Button-->
@if(Active::checkUriPattern('admin/blogtags'))
@if(Active::checkUriPattern('admin/blogTags'))
<div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
<span class="caret"></span>
......@@ -21,9 +21,9 @@
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="{{route('admin.blogtags.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.blogtags.all')}}</a></li>
<li><a href="{{route('admin.blogTags.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.blogtags.all')}}</a></li>
@permission('create-blog-tag')
<li><a href="{{route('admin.blogtags.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.blogtags.create')}}</a></li>
<li><a href="{{route('admin.blogTags.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.blogtags.create')}}</a></li>
@endauth
</ul>
</div>
......
......@@ -97,8 +97,8 @@
</li>
@endauth
@permission('view-blog-tag')
<li class="{{ active_class(Active::checkUriPattern('admin/blogtags*')) }}">
<a href="{{ route('admin.blogtags.index') }}">
<li class="{{ active_class(Active::checkUriPattern('admin/blogTags*')) }}">
<a href="{{ route('admin.blogTags.index') }}">
<span>{{ trans('menus.backend.blogtags.management') }}</span>
</a>
</li>
......
......@@ -4,9 +4,9 @@
* Blogs Tags Management
*/
Route::group(['namespace' => 'BlogTags'], function () {
Route::resource('blogtags', 'BlogTagsController', ['except' => ['show']]);
Route::resource('blogTags', 'BlogTagsController', ['except' => ['show']]);
//For DataTables
Route::post('blogtags/get', 'BlogTagsTableController')
->name('blogtags.get');
Route::post('blogTags/get', 'BlogTagsTableController')
->name('blogTags.get');
});
<?php
namespace Tests\Feature;
namespace Tests\Feature\Backend;
use App\Models\BlogCategories\BlogCategory;
use Tests\TestCase;
......@@ -43,15 +43,16 @@ class ManageBlogCategoriesTest extends TestCase
->assertSessionHasErrors('name');
}
// public function a_blog_category_requires_a_name_while_updating()
// {
// $this->actingAs($this->admin)->withExceptionHandling();
/** @test */
public function a_blog_category_requires_a_name_while_updating()
{
$this->actingAs($this->admin)->withExceptionHandling();
// $category = create(BlogCategory::class);
$category = create(BlogCategory::class);
// $this->post(route('admin.blogCategories.store'), $category->toArray())
// ->assertSessionHasErrors('name');
// }
$this->patch(route('admin.blogCategories.update', $category), ['name' => ''])
->assertSessionHasErrors('name');
}
/** @test */
public function a_user_can_update_a_blog_category()
......
<?php
namespace Tests\Feature\Backend;
use Tests\TestCase;
use App\Models\BlogTags\BlogTag;
class ManageBlogTagsTest extends TestCase
{
/** @test */
public function a_user_can_view_blog_tags_index_page()
{
$this->actingAs($this->admin)
->get(route('admin.blogTags.index'))
->assertViewIs('backend.blogtags.index')
->assertSee(trans('labels.backend.blogtags.management'))
->assertSee(trans('labels.backend.blogtags.table.title'))
->assertSee(trans('labels.backend.blogtags.table.status'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_create_a_blog_tag()
{
$this->actingAs($this->admin);
$tag = make(BlogTag::class);
$this->post(route('admin.blogTags.store'), $tag->toArray());
$this->assertDatabaseHas(config('module.blog_tags.table'), ['name' => $tag->name]);
}
/** @test */
public function a_blog_tag_requires_a_name_while_creating()
{
$this->actingAs($this->admin)->withExceptionHandling();
$tag = make(BlogTag::class, ['name' => '']);
$this->post(route('admin.blogTags.store'), $tag->toArray())
->assertSessionHasErrors('name');
}
/** @test */
public function a_blog_tag_requires_a_name_while_updating()
{
$this->actingAs($this->admin)->withExceptionHandling();
$tag = create(BlogTag::class);
$this->patch(route('admin.blogTags.update', $tag), ['name' => ''])
->assertSessionHasErrors('name');
}
/** @test */
public function a_user_can_update_a_blog_tag()
{
$this->actingAs($this->admin);
$tag = create(BlogTag::class);
$this->patch(route('admin.blogTags.update', $tag), ['name' => 'New Tag']);
$this->assertDatabaseHas(config('module.blog_tags.table'), ['name' => 'New Tag', 'id' => $tag->id]);
}
/** @test */
public function a_user_can_delete_a_blog_tag()
{
$this->actingAs($this->admin);
$tag = create(BlogTag::class);
$this->delete(route('admin.blogTags.destroy', $tag));
$this->assertDatabaseMissing(config('module.blog_tags.table'), ['name' => $tag->name, 'id' => $tag->id, 'deleted_at' => null]);
}
}
......@@ -124,4 +124,16 @@ class ManagePagesTest extends TestCase
->post(route('admin.pages.store'), $page3)
->assertSessionHasErrors('description');
}
/** @test */
public function a_user_can_delete_a_page()
{
$this->actingAs($this->admin);
$page = create(Page::class);
$this->delete(route('admin.pages.destroy', $page));
$this->assertDatabaseMissing(config('module.pages.table'), ['name' => $page->name, 'id' => $page->id, 'deleted_at' => null]);
}
}
<?php
namespace Tests\Unit;
use Tests\TestCase;
class BlogCategoryTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
}
<?php
namespace Tests\Unit\Models;
use Tests\TestCase;
use App\Models\Access\User\User;
use App\Models\BlogCategories\BlogCategory;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class BlogCategoryTest extends TestCase
{
/** @test */
public function it_has_a_creator()
{
$this->actingAs($this->admin);
$category = create(BlogCategory::class, ['created_by' => access()->id()]);
$this->assertInstanceOf(User::class, $category->creator);
$this->assertEquals($category->creator->id, access()->id());
}
}
<?php
namespace Tests\Unit\Models;
use Tests\TestCase;
use App\Models\BlogTags\BlogTag;
use App\Models\Access\User\User;
class BlogTagTest extends TestCase
{
/** @test */
public function it_has_a_creator()
{
$this->actingAs($this->admin);
$tag = create(BlogTag::class, ['created_by' => access()->id()]);
$this->assertInstanceOf(User::class, $tag->creator);
$this->assertEquals($tag->creator->id, access()->id());
}
}
<?php
namespace Tests\Unit;
namespace Tests\Unit\Models;
use App\Models\Access\User\User;
use App\Models\Page\Page;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment