Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
86e27311
Commit
86e27311
authored
Dec 29, 2017
by
vagrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Blog Categories test --partial pending
parent
3120ec84
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
134 additions
and
18 deletions
+134
-18
BlogCategoriesController.php
...llers/Backend/BlogCategories/BlogCategoriesController.php
+9
-9
BlogCategoryFactory.php
database/factories/BlogCategoryFactory.php
+15
-0
2017_11_02_060149_create_blog_categories_table.php
...ations/2017_11_02_060149_create_blog_categories_table.php
+1
-1
MenuTableSeeder.php
database/seeds/MenuTableSeeder.php
+1
-1
index.blade.php
resources/views/backend/blogcategories/index.blade.php
+1
-1
blogcategories-header-buttons.blade.php
...tegories/partials/blogcategories-header-buttons.blade.php
+3
-3
BlogCategories.php
routes/Backend/BlogCategories.php
+3
-3
ManageBlogCategoriesTest.php
tests/Feature/ManageBlogCategoriesTest.php
+81
-0
BlogCategoryTest.php
tests/Unit/BlogCategoryTest.php
+20
-0
No files found.
app/Http/Controllers/Backend/BlogCategories/BlogCategoriesController.php
View file @
86e27311
...
...
@@ -57,7 +57,7 @@ class BlogCategoriesController extends Controller
$this
->
blogcategory
->
create
(
$request
->
all
());
return
redirect
()
->
route
(
'admin.blog
c
ategories.index'
)
->
route
(
'admin.blog
C
ategories.index'
)
->
with
(
'flash_success'
,
trans
(
'alerts.backend.blogcategories.created'
));
}
...
...
@@ -67,10 +67,10 @@ class BlogCategoriesController extends Controller
*
* @return mixed
*/
public
function
edit
(
BlogCategory
$blog
c
ategory
,
EditBlogCategoriesRequest
$request
)
public
function
edit
(
BlogCategory
$blog
C
ategory
,
EditBlogCategoriesRequest
$request
)
{
return
view
(
'backend.blogcategories.edit'
)
->
with
(
'blogcategory'
,
$blog
c
ategory
);
->
with
(
'blogcategory'
,
$blog
C
ategory
);
}
/**
...
...
@@ -79,12 +79,12 @@ class BlogCategoriesController extends Controller
*
* @return mixed
*/
public
function
update
(
BlogCategory
$blog
c
ategory
,
UpdateBlogCategoriesRequest
$request
)
public
function
update
(
BlogCategory
$blog
C
ategory
,
UpdateBlogCategoriesRequest
$request
)
{
$this
->
blogcategory
->
update
(
$blog
c
ategory
,
$request
->
all
());
$this
->
blogcategory
->
update
(
$blog
C
ategory
,
$request
->
all
());
return
redirect
()
->
route
(
'admin.blog
c
ategories.index'
)
->
route
(
'admin.blog
C
ategories.index'
)
->
with
(
'flash_success'
,
trans
(
'alerts.backend.blogcategories.updated'
));
}
...
...
@@ -94,12 +94,12 @@ class BlogCategoriesController extends Controller
*
* @return mixed
*/
public
function
destroy
(
BlogCategory
$blog
c
ategory
,
DeleteBlogCategoriesRequest
$request
)
public
function
destroy
(
BlogCategory
$blog
C
ategory
,
DeleteBlogCategoriesRequest
$request
)
{
$this
->
blogcategory
->
delete
(
$blog
c
ategory
);
$this
->
blogcategory
->
delete
(
$blog
C
ategory
);
return
redirect
()
->
route
(
'admin.blog
c
ategories.index'
)
->
route
(
'admin.blog
C
ategories.index'
)
->
with
(
'flash_success'
,
trans
(
'alerts.backend.blogcategories.deleted'
));
}
}
database/factories/BlogCategoryFactory.php
0 → 100644
View file @
86e27311
<?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
;
},
];
});
database/migrations/2017_11_02_060149_create_blog_categories_table.php
View file @
86e27311
...
...
@@ -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
();
...
...
database/seeds/MenuTableSeeder.php
View file @
86e27311
...
...
@@ -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.blog
c
ategories.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.blog
C
ategories.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
(),
];
...
...
resources/views/backend/blogcategories/index.blade.php
View file @
86e27311
...
...
@@ -70,7 +70,7 @@
processing: true,
serverSide: true,
ajax: {
url: '{{ route("
admin
.
blog
c
ategories
.
get
") }}',
url: '{{ route("
admin
.
blog
C
ategories
.
get
") }}',
type: 'post'
},
columns: [
...
...
resources/views/backend/blogcategories/partials/blogcategories-header-buttons.blade.php
View file @
86e27311
<!--Action Button-->
@if(Active::checkUriPattern('admin/blog
c
ategories'))
@if(Active::checkUriPattern('admin/blog
C
ategories'))
<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.blog
c
ategories.index')}}"
><i
class=
"fa fa-list-ul"
></i>
{{trans('menus.backend.blogcategories.all')}}
</a></li>
<li><a
href=
"{{route('admin.blog
C
ategories.index')}}"
><i
class=
"fa fa-list-ul"
></i>
{{trans('menus.backend.blogcategories.all')}}
</a></li>
@permission('create-blog-category')
<li><a
href=
"{{route('admin.blog
c
ategories.create')}}"
><i
class=
"fa fa-plus"
></i>
{{trans('menus.backend.blogcategories.create')}}
</a></li>
<li><a
href=
"{{route('admin.blog
C
ategories.create')}}"
><i
class=
"fa fa-plus"
></i>
{{trans('menus.backend.blogcategories.create')}}
</a></li>
@endauth
</ul>
</div>
\ No newline at end of file
routes/Backend/BlogCategories.php
View file @
86e27311
...
...
@@ -4,9 +4,9 @@
* Blogs Categories Management
*/
Route
::
group
([
'namespace'
=>
'BlogCategories'
],
function
()
{
Route
::
resource
(
'blog
c
ategories'
,
'BlogCategoriesController'
,
[
'except'
=>
[
'show'
]]);
Route
::
resource
(
'blog
C
ategories'
,
'BlogCategoriesController'
,
[
'except'
=>
[
'show'
]]);
//For DataTables
Route
::
post
(
'blog
c
ategories/get'
,
'BlogCategoriesTableController'
)
->
name
(
'blog
c
ategories.get'
);
Route
::
post
(
'blog
C
ategories/get'
,
'BlogCategoriesTableController'
)
->
name
(
'blog
C
ategories.get'
);
});
tests/Feature/ManageBlogCategoriesTest.php
0 → 100644
View file @
86e27311
<?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
]);
}
}
tests/Unit/BlogCategoryTest.php
0 → 100644
View file @
86e27311
<?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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment