Commit 86e27311 authored by vagrant's avatar vagrant

Blog Categories test --partial pending

parent 3120ec84
......@@ -57,7 +57,7 @@ class BlogCategoriesController extends Controller
$this->blogcategory->create($request->all());
return redirect()
->route('admin.blogcategories.index')
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.created'));
}
......@@ -67,10 +67,10 @@ class BlogCategoriesController extends Controller
*
* @return mixed
*/
public function edit(BlogCategory $blogcategory, EditBlogCategoriesRequest $request)
public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request)
{
return view('backend.blogcategories.edit')
->with('blogcategory', $blogcategory);
->with('blogcategory', $blogCategory);
}
/**
......@@ -79,12 +79,12 @@ class BlogCategoriesController extends Controller
*
* @return mixed
*/
public function update(BlogCategory $blogcategory, UpdateBlogCategoriesRequest $request)
public function update(BlogCategory $blogCategory, UpdateBlogCategoriesRequest $request)
{
$this->blogcategory->update($blogcategory, $request->all());
$this->blogcategory->update($blogCategory, $request->all());
return redirect()
->route('admin.blogcategories.index')
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.updated'));
}
......@@ -94,12 +94,12 @@ class BlogCategoriesController extends Controller
*
* @return mixed
*/
public function destroy(BlogCategory $blogcategory, DeleteBlogCategoriesRequest $request)
public function destroy(BlogCategory $blogCategory, DeleteBlogCategoriesRequest $request)
{
$this->blogcategory->delete($blogcategory);
$this->blogcategory->delete($blogCategory);
return redirect()
->route('admin.blogcategories.index')
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.deleted'));
}
}
<?php
use Faker\Generator as Faker;
use App\Models\Access\User\User;
use App\Models\BlogCategories\BlogCategory;
$factory->define(BlogCategory::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();
$table->integer('created_by')->unsigned()->nullable();
$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(),
];
......
......@@ -70,7 +70,7 @@
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.blogcategories.get") }}',
url: '{{ route("admin.blogCategories.get") }}',
type: 'post'
},
columns: [
......
<!--Action Button-->
@if(Active::checkUriPattern('admin/blogcategories'))
@if(Active::checkUriPattern('admin/blogCategories'))
<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.blogcategories.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.blogcategories.all')}}</a></li>
<li><a href="{{route('admin.blogCategories.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.blogcategories.all')}}</a></li>
@permission('create-blog-category')
<li><a href="{{route('admin.blogcategories.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.blogcategories.create')}}</a></li>
<li><a href="{{route('admin.blogCategories.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.blogcategories.create')}}</a></li>
@endauth
</ul>
</div>
\ No newline at end of file
......@@ -4,9 +4,9 @@
* Blogs Categories Management
*/
Route::group(['namespace' => 'BlogCategories'], function () {
Route::resource('blogcategories', 'BlogCategoriesController', ['except' => ['show']]);
Route::resource('blogCategories', 'BlogCategoriesController', ['except' => ['show']]);
//For DataTables
Route::post('blogcategories/get', 'BlogCategoriesTableController')
->name('blogcategories.get');
Route::post('blogCategories/get', 'BlogCategoriesTableController')
->name('blogCategories.get');
});
<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\BlogCategories\BlogCategory;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ManageBlogCategoriesTest extends TestCase
{
/** @test */
public function a_user_can_view_blog_categories_index_page()
{
$this->actingAs($this->admin)
->get(route('admin.blogCategories.index'))
->assertViewIs('backend.blogcategories.index')
->assertSee(trans('labels.backend.blogcategories.management'))
->assertSee(trans('labels.backend.blogcategories.table.title'))
->assertSee(trans('labels.backend.blogcategories.table.status'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_user_can_create_a_blog_category()
{
$this->actingAs($this->admin);
$category = make(BlogCategory::class);
$this->post(route('admin.blogCategories.store'), $category->toArray());
$this->assertDatabaseHas(config('module.blog_categories.table'), ['name' => $category->name]);
}
/** @test */
public function a_blog_category_requires_a_name_while_creating()
{
$this->actingAs($this->admin)->withExceptionHandling();
$category = make(BlogCategory::class, ['name' => '']);
$this->post(route('admin.blogCategories.store'), $category->toArray())
->assertSessionHasErrors('name');
}
// public function a_blog_category_requires_a_name_while_updating()
// {
// $this->actingAs($this->admin)->withExceptionHandling();
// $category = create(BlogCategory::class);
// $this->post(route('admin.blogCategories.store'), $category->toArray())
// ->assertSessionHasErrors('name');
// }
/** @test */
public function a_user_can_update_a_blog_category()
{
$this->actingAs($this->admin);
$category = create(BlogCategory::class);
$this->patch(route('admin.blogCategories.update', $category), ['name' => 'New Category']);
$this->assertDatabaseHas(config('module.blog_categories.table'), ['name' => 'New Category', 'id' => $category->id]);
}
/** @test */
public function a_user_can_delete_a_blog_category()
{
$this->actingAs($this->admin);
$category = create(BlogCategory::class);
$this->delete(route('admin.blogCategories.destroy', $category));
$this->assertDatabaseMissing(config('module.blog_categories.table'), ['name' => $category->name, 'id' => $category->id, 'deleted_at' => null]);
}
}
<?php
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class BlogCategoryTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
}
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