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
55b49b3a
Unverified
Commit
55b49b3a
authored
Jan 08, 2018
by
Viral Solani
Committed by
GitHub
Jan 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #138 from bvipul/develop
Blog and Faq Tests
parents
28f4d362
7f0cd844
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
556 additions
and
133 deletions
+556
-133
BlogRelationship.php
app/Models/Blogs/Traits/Relationship/BlogRelationship.php
+2
-2
BlogsRepository.php
app/Repositories/Backend/Blogs/BlogsRepository.php
+30
-18
composer.lock
composer.lock
+90
-90
BlogFactory.php
database/factories/BlogFactory.php
+27
-0
FaqFactory.php
database/factories/FaqFactory.php
+12
-0
PageFactory.php
database/factories/PageFactory.php
+4
-1
form.blade.php
resources/views/backend/blogs/form.blade.php
+1
-1
edit.blade.php
resources/views/backend/settings/edit.blade.php
+1
-1
ManageBlogsTest.php
tests/Feature/Backend/ManageBlogsTest.php
+203
-0
ManageFaqsTest.php
tests/Feature/Backend/ManageFaqsTest.php
+103
-0
ManagePagesTest.php
tests/Feature/Backend/ManagePagesTest.php
+17
-20
BlogTest.php
tests/Unit/Models/BlogTest.php
+66
-0
No files found.
app/Models/Blogs/Traits/Relationship/BlogRelationship.php
View file @
55b49b3a
...
...
@@ -30,8 +30,8 @@ trait BlogRelationship
/**
* Blogs belongsTo with User.
*/
public
function
createdBy
()
public
function
owner
()
{
return
$this
->
belongsTo
(
User
::
class
,
'created_by'
,
'id'
);
return
$this
->
belongsTo
(
User
::
class
,
'created_by'
);
}
}
app/Repositories/Backend/Blogs/BlogsRepository.php
View file @
55b49b3a
...
...
@@ -2,19 +2,20 @@
namespace
App\Repositories\Backend\Blogs
;
use
App\Events\Backend\Blogs\BlogCreated
;
use
DB
;
use
Carbon\Carbon
;
use
App\Models\Blogs\Blog
;
use
App\Models\BlogTags\BlogTag
;
use
App\Http\Utilities\FileUploads
;
use
App\Exceptions\GeneralException
;
use
App\Repositories\BaseRepository
;
use
App\Models\BlogMapTags\BlogMapTag
;
use
Illuminate\Support\Facades\Storage
;
use
App\Events\Backend\Blogs\BlogDeleted
;
use
App\Events\Backend\Blogs\BlogUpdated
;
use
App\Exceptions\GeneralException
;
use
App\Http\Utilities\FileUploads
;
use
App\Events\Backend\Blogs\BlogCreated
;
use
App\Models\BlogCategories\BlogCategory
;
use
App\Models\BlogMapCategories\BlogMapCategory
;
use
App\Models\BlogMapTags\BlogMapTag
;
use
App\Models\Blogs\Blog
;
use
App\Models\BlogTags\BlogTag
;
use
App\Repositories\BaseRepository
;
use
Carbon\Carbon
;
use
DB
;
/**
* Class BlogsRepository.
...
...
@@ -26,6 +27,21 @@ class BlogsRepository extends BaseRepository
*/
const
MODEL
=
Blog
::
class
;
protected
$upload_path
;
/**
* Storage Class Object.
*
* @var \Illuminate\Support\Facades\Storage
*/
protected
$storage
;
public
function
__construct
()
{
$this
->
upload_path
=
'img'
.
DIRECTORY_SEPARATOR
.
'blog'
.
DIRECTORY_SEPARATOR
;
$this
->
storage
=
Storage
::
disk
(
'public'
);
}
/**
* @return mixed
*/
...
...
@@ -210,13 +226,12 @@ class BlogsRepository extends BaseRepository
*/
public
function
uploadImage
(
$input
)
{
$uploadManager
=
new
FileUploads
();
$avatar
=
$input
[
'featured_image'
];
if
(
isset
(
$input
[
'featured_image'
])
&&
!
empty
(
$input
[
'featured_image'
]))
{
$fileName
=
$uploadManager
->
setBasePath
(
'backend/blog_images'
)
->
setThumbnailFlag
(
false
)
->
upload
(
$input
[
'featured_image'
]
);
$fileName
=
time
()
.
$avatar
->
getClientOriginalName
();
$this
->
storage
->
put
(
$this
->
upload_path
.
$fileName
,
file_get_contents
(
$avatar
->
getRealPath
())
);
$input
=
array_merge
(
$input
,
[
'featured_image'
=>
$fileName
]);
...
...
@@ -231,11 +246,8 @@ class BlogsRepository extends BaseRepository
*/
public
function
deleteOldFile
(
$model
)
{
$uploadManager
=
new
FileUploads
();
$fileName
=
$model
->
featured_image
;
$filePath
=
$uploadManager
->
setBasePath
(
'backend/blog_images'
);
$file
=
$filePath
->
filePath
.
DIRECTORY_SEPARATOR
.
$fileName
;
return
$uploadManager
->
deleteFile
(
$file
);
return
$this
->
storage
->
delete
(
$this
->
upload_path
.
$fileName
);
}
}
composer.lock
View file @
55b49b3a
This diff is collapsed.
Click to expand it.
database/factories/BlogFactory.php
0 → 100644
View file @
55b49b3a
<?php
use
App\Models\Blogs\Blog
;
use
Faker\Generator
as
Faker
;
use
App\Models\Access\User\User
;
$factory
->
define
(
Blog
::
class
,
function
(
Faker
$faker
)
{
$status
=
[
'Published'
,
'Draft'
,
'InActive'
,
'Scheduled'
];
return
[
'name'
=>
$faker
->
sentence
,
'publish_datetime'
=>
$faker
->
dateTime
(),
'featured_image'
=>
'logo.png'
,
'content'
=>
$faker
->
paragraph
(
3
),
'status'
=>
$status
[
$faker
->
numberBetween
(
0
,
3
)],
'created_by'
=>
function
()
{
return
factory
(
User
::
class
)
->
create
()
->
id
;
},
];
});
database/factories/FaqFactory.php
0 → 100644
View file @
55b49b3a
<?php
use
App\Models\Faqs\Faq
;
use
Faker\Generator
as
Faker
;
$factory
->
define
(
Faq
::
class
,
function
(
Faker
$faker
)
{
return
[
'question'
=>
rtrim
(
$faker
->
sentence
,
'.'
)
.
'?'
,
'answer'
=>
$faker
->
paragraph
,
'status'
=>
$faker
->
numberBetween
(
0
,
1
)
];
});
database/factories/PageFactory.php
View file @
55b49b3a
...
...
@@ -2,6 +2,7 @@
use
App\Models\Page\Page
;
use
Faker\Generator
as
Faker
;
use
App\Models\Access\User\User
;
$factory
->
define
(
Page
::
class
,
function
(
Faker
$faker
)
{
$title
=
$faker
->
sentence
;
...
...
@@ -10,6 +11,8 @@ $factory->define(Page::class, function (Faker $faker) {
'title'
=>
$title
,
'page_slug'
=>
str_slug
(
$title
),
'description'
=>
$faker
->
paragraph
,
'created_by'
=>
1
,
'created_by'
=>
function
()
{
return
factory
(
User
::
class
)
->
create
()
->
id
;
},
];
});
resources/views/backend/blogs/form.blade.php
View file @
55b49b3a
...
...
@@ -35,7 +35,7 @@
{{ Form::label('featured_image', trans('validation.attributes.backend.blogs.image'), ['class' => 'col-lg-2 control-label required']) }}
@if(!empty($blog->featured_image))
<div
class=
"col-lg-1"
>
<img
src=
"
/img/backend/blog_images/{{$blog->featured_image
}}"
height=
"80"
width=
"80"
>
<img
src=
"
{{ Storage::disk('public')->url('img/blog/' . $blog->featured_image)
}}"
height=
"80"
width=
"80"
>
</div>
<div
class=
"col-lg-5"
>
<div
class=
"custom-file-input"
>
...
...
resources/views/backend/settings/edit.blade.php
View file @
55b49b3a
...
...
@@ -58,7 +58,7 @@
</div>
<div class="
img
-
remove
-
logo
">
@if(
$setting->logo
)
<img height="
50
" width="
50
" src="
{{
Storage
::
disk
(
'public'
)
->
url
(
'img/
site_
logo/'
.
$setting
->
logo
)
}}
">
<img height="
50
" width="
50
" src="
{{
Storage
::
disk
(
'public'
)
->
url
(
'img/logo/'
.
$setting
->
logo
)
}}
">
<i id="
remove
-
logo
-
img
" class="
fa
fa
-
times
remove
-
logo
" data-id="
logo
" aria-hidden="
true
"></i>
@endif
</div>
...
...
tests/Feature/Backend/ManageBlogsTest.php
0 → 100644
View file @
55b49b3a
<?php
namespace
Tests\Feature\Backend
;
use
Tests\TestCase
;
use
App\Models\Blogs\Blog
;
use
App\Models\BlogTags\BlogTag
;
use
Illuminate\Http\UploadedFile
;
use
Illuminate\Support\Facades\Storage
;
use
App\Models\BlogCategories\BlogCategory
;
use
Illuminate\Foundation\Testing\WithFaker
;
class
ManageBlogsTest
extends
TestCase
{
use
WithFaker
;
protected
$blog
;
protected
$categories
;
protected
$tags
;
public
function
setUp
()
{
parent
::
setUp
();
$this
->
actingAs
(
$this
->
admin
);
$this
->
blog
=
create
(
Blog
::
class
);
$this
->
categories
=
[
$this
->
faker
->
word
,
$this
->
faker
->
word
];
$this
->
tags
=
[
$this
->
faker
->
word
,
$this
->
faker
->
word
];
}
/** @test */
public
function
a_user_can_view_blogs_index_page
()
{
$this
->
actingAs
(
$this
->
admin
)
->
get
(
route
(
'admin.blogs.index'
))
->
assertViewIs
(
'backend.blogs.index'
)
->
assertSee
(
trans
(
'labels.backend.blogs.management'
))
->
assertSee
(
trans
(
'labels.backend.blogs.table.title'
))
->
assertSee
(
trans
(
'labels.backend.blogs.table.publish'
))
->
assertSee
(
trans
(
'labels.backend.blogs.table.createdby'
))
->
assertSee
(
trans
(
'labels.backend.blogs.table.createdat'
))
->
assertSee
(
trans
(
'labels.backend.blogs.table.status'
))
->
assertSee
(
'Export'
)
->
assertSee
(
'Action'
);
}
/** @test */
public
function
a_user_can_create_a_blog
()
{
$blog
=
make
(
Blog
::
class
,
[
'featured_image'
=>
UploadedFile
::
fake
()
->
image
(
'logo.jpg'
),
'categories'
=>
$this
->
categories
,
'tags'
=>
$this
->
tags
]);
$this
->
post
(
route
(
'admin.blogs.store'
),
$blog
->
toArray
());
$this
->
assertDatabaseHas
(
config
(
'module.blogs.table'
),
[
'name'
=>
$blog
->
name
,
'status'
=>
$blog
->
status
]);
//Assert Tags have been saved
$this
->
assertDatabaseHas
(
config
(
'module.blog_tags.table'
),
[
'name'
=>
$this
->
tags
[
0
]]);
$this
->
assertDatabaseHas
(
config
(
'module.blog_tags.table'
),
[
'name'
=>
$this
->
tags
[
1
]]);
//Assert Categories have been saved
$this
->
assertDatabaseHas
(
config
(
'module.blog_categories.table'
),
[
'name'
=>
$this
->
categories
[
0
]]);
$this
->
assertDatabaseHas
(
config
(
'module.blog_categories.table'
),
[
'name'
=>
$this
->
categories
[
1
]]);
}
public
function
makeBlog
(
$overrides
=
[])
{
$this
->
withExceptionHandling
();
$blog
=
make
(
Blog
::
class
,
$overrides
);
return
$blog
;
}
/** @test */
public
function
it_requires_name_while_creating
()
{
$blog
=
$this
->
makeBlog
([
'name'
=>
''
]);
$this
->
post
(
route
(
'admin.blogs.store'
),
$blog
->
toArray
())
->
assertSessionHasErrors
(
'name'
);
}
/** @test */
public
function
it_requires_content_while_creating
()
{
$blog
=
$this
->
makeBlog
([
'content'
=>
''
]);
$this
->
post
(
route
(
'admin.blogs.store'
),
$blog
->
toArray
())
->
assertSessionHasErrors
(
'content'
);
}
/** @test */
public
function
it_requires_featured_image_while_creating
()
{
$blog
=
$this
->
makeBlog
([
'featured_image'
=>
''
]);
$this
->
post
(
route
(
'admin.blogs.store'
),
$blog
->
toArray
())
->
assertSessionHasErrors
(
'featured_image'
);
}
/** @test */
public
function
it_requires_categories_while_creating
()
{
$blog
=
$this
->
makeBlog
([
'categories'
=>
''
]);
$this
->
post
(
route
(
'admin.blogs.store'
),
$blog
->
toArray
())
->
assertSessionHasErrors
(
'categories'
);
}
/** @test */
public
function
it_requires_tags_while_creating
()
{
$blog
=
$this
->
makeBlog
([
'tags'
=>
''
]);
$this
->
post
(
route
(
'admin.blogs.store'
),
$blog
->
toArray
())
->
assertSessionHasErrors
(
'tags'
);
}
/** @test */
public
function
it_can_store_featured_image
()
{
$blog
=
make
(
Blog
::
class
,
[
'featured_image'
=>
UploadedFile
::
fake
()
->
image
(
'logo.jpg'
),
'categories'
=>
$this
->
categories
,
'tags'
=>
$this
->
tags
]);
$this
->
post
(
route
(
'admin.blogs.store'
),
$blog
->
toArray
());
$stored_blog
=
Blog
::
find
(
2
);
Storage
::
disk
(
'public'
)
->
assertExists
(
'img/blog/'
.
$stored_blog
->
featured_image
);
}
/** @test */
public
function
it_requires_name_while_updating
()
{
$this
->
withExceptionHandling
();
$this
->
blog
->
name
=
''
;
$this
->
patch
(
route
(
'admin.blogs.update'
,
$this
->
blog
),
$this
->
blog
->
toArray
())
->
assertSessionHasErrors
(
'name'
);
}
/** @test */
public
function
it_requires_content_while_updating
()
{
$this
->
withExceptionHandling
();
$this
->
blog
->
content
=
''
;
$this
->
patch
(
route
(
'admin.blogs.update'
,
$this
->
blog
),
$this
->
blog
->
toArray
())
->
assertSessionHasErrors
(
'content'
);
}
/** @test */
public
function
it_requires_categories_while_updating
()
{
$this
->
withExceptionHandling
();
$this
->
patch
(
route
(
'admin.blogs.update'
,
$this
->
blog
),
$this
->
blog
->
toArray
())
->
assertSessionHasErrors
(
'categories'
);
}
/** @test */
public
function
it_requires_tags_while_updating
()
{
$this
->
withExceptionHandling
();
$this
->
patch
(
route
(
'admin.blogs.update'
,
$this
->
blog
),
$this
->
blog
->
toArray
())
->
assertSessionHasErrors
(
'tags'
);
}
/** @test */
public
function
a_user_can_update_blog
()
{
$blog
=
make
(
Blog
::
class
,
[
'featured_image'
=>
UploadedFile
::
fake
()
->
image
(
'logo.jpg'
),
'name'
=>
'Changed Name'
,
'categories'
=>
$this
->
categories
,
'tags'
=>
$this
->
tags
]);
$this
->
patch
(
route
(
'admin.blogs.update'
,
$this
->
blog
),
$blog
->
toArray
());
$this
->
assertDatabaseHas
(
config
(
'module.blogs.table'
),
[
'id'
=>
$this
->
blog
->
id
,
'name'
=>
'Changed Name'
]);
}
/** @test */
public
function
a_user_can_delete_a_blog
()
{
$this
->
delete
(
route
(
'admin.blogs.destroy'
,
$this
->
blog
));
$this
->
assertDatabaseMissing
(
config
(
'module.blogs.table'
),
[
'id'
=>
$this
->
blog
->
id
,
'deleted_at'
=>
null
]);
}
}
tests/Feature/Backend/ManageFaqsTest.php
0 → 100644
View file @
55b49b3a
<?php
namespace
Tests\Feature\Backend
;
use
Tests\TestCase
;
use
App\Models\Faqs\Faq
;
class
ManageFaqsTest
extends
TestCase
{
/** @test */
public
function
a_user_can_view_faqs_index_page
()
{
$this
->
actingAs
(
$this
->
admin
)
->
get
(
route
(
'admin.faqs.index'
))
->
assertViewIs
(
'backend.faqs.index'
)
->
assertSee
(
trans
(
'labels.backend.faqs.management'
))
->
assertSee
(
trans
(
'labels.backend.faqs.table.question'
))
->
assertSee
(
trans
(
'labels.backend.faqs.table.answer'
))
->
assertSee
(
trans
(
'labels.backend.faqs.table.status'
))
->
assertSee
(
'Export'
)
->
assertSee
(
'Action'
);
}
/** @test */
public
function
a_user_can_create_faq
()
{
$faq
=
make
(
Faq
::
class
);
$this
->
actingAs
(
$this
->
admin
)
->
post
(
route
(
'admin.faqs.store'
),
$faq
->
toArray
());
$this
->
assertDatabaseHas
(
config
(
'module.faqs.table'
),
[
'question'
=>
$faq
->
question
,
'answer'
=>
$faq
->
answer
]);
}
/** @test */
public
function
it_requires_question_while_creating
()
{
$faq
=
make
(
Faq
::
class
,
[
'question'
=>
''
]);
$this
->
actingAs
(
$this
->
admin
)
->
withExceptionHandling
()
->
post
(
route
(
'admin.faqs.store'
),
$faq
->
toArray
())
->
assertSessionHasErrors
(
'question'
);
}
/** @test */
public
function
it_requires_answer_while_creating
()
{
$faq
=
make
(
Faq
::
class
,
[
'answer'
=>
''
]);
$this
->
actingAs
(
$this
->
admin
)
->
withExceptionHandling
()
->
post
(
route
(
'admin.faqs.store'
),
$faq
->
toArray
())
->
assertSessionHasErrors
(
'answer'
);
}
/** @test */
public
function
it_requires_question_while_updating
()
{
$faq
=
create
(
Faq
::
class
);
$this
->
actingAs
(
$this
->
admin
)
->
withExceptionHandling
()
->
patch
(
route
(
'admin.faqs.update'
,
$faq
),
[
'question'
=>
''
,
'answer'
=>
$faq
->
answer
])
->
assertSessionHasErrors
(
'question'
);
}
/** @test */
public
function
it_requires_answer_while_updating
()
{
$faq
=
create
(
Faq
::
class
);
$this
->
actingAs
(
$this
->
admin
)
->
withExceptionHandling
()
->
patch
(
route
(
'admin.faqs.update'
,
$faq
),
[
'question'
=>
$faq
->
question
,
'answer'
=>
''
])
->
assertSessionHasErrors
(
'answer'
);
}
/** @test */
public
function
a_user_can_update_faq
()
{
$faq
=
create
(
Faq
::
class
);
$changed_question
=
"What is Life?"
;
$changed_answer
=
$faq
->
answer
;
$this
->
actingAs
(
$this
->
admin
)
->
patch
(
route
(
'admin.faqs.update'
,
$faq
),
[
'question'
=>
$changed_question
,
'answer'
=>
$changed_answer
]);
$this
->
assertDatabaseHas
(
config
(
'module.faqs.table'
),
[
'id'
=>
$faq
->
id
,
'question'
=>
$changed_question
,
'answer'
=>
$changed_answer
]);
}
/** @test */
public
function
a_user_can_delete_faq
()
{
$faq
=
create
(
Faq
::
class
);
$this
->
actingAs
(
$this
->
admin
)
->
delete
(
route
(
'admin.faqs.destroy'
,
$faq
));
$this
->
assertDatabaseMissing
(
config
(
'module.faqs.table'
),
[
'id'
=>
$faq
->
id
,
'deleted_at'
=>
null
]);
}
}
tests/Feature/Backend/ManagePagesTest.php
View file @
55b49b3a
...
...
@@ -57,22 +57,19 @@ class ManagePagesTest extends TestCase
}
/** @test */
public
function
it_
fails_for_validation_on_create_pag
e
()
public
function
it_
requires_title_on_creat
e
()
{
$page
=
make
(
Page
::
class
,
[
'title'
=>
''
,
'description'
=>
''
]);
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
post
(
route
(
'admin.pages.store'
),
$page
->
toArray
())
->
assertSessionHasErrors
([
'title'
,
'description'
]);
$page
=
make
(
Page
::
class
,
[
'title'
=>
''
]);
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
post
(
route
(
'admin.pages.store'
),
$page
->
toArray
())
->
assertSessionHasErrors
(
'title'
);
}
/** @test */
public
function
it_requires_description_while_create
()
{
$page
=
make
(
Page
::
class
,
[
'description'
=>
''
]);
$this
->
withExceptionHandling
()
...
...
@@ -96,32 +93,32 @@ class ManagePagesTest extends TestCase
}
/** @test */
public
function
it_
fails_for_validation
_on_update
()
public
function
it_
requires_title
_on_update
()
{
$page
=
create
(
Page
::
class
);
$page1
=
$page
2
=
$page3
=
$page
->
toArray
();
$page1
=
$page
->
toArray
();
$page1
[
'title'
]
=
''
;
$page1
[
'description'
]
=
''
;
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
post
(
route
(
'admin.pages.store'
),
$page1
)
->
assertSessionHasErrors
([
'title'
,
'description'
]);
->
patch
(
route
(
'admin.pages.update'
,
$page
),
$page1
)
->
assertSessionHasErrors
(
'title'
);
}
$page2
[
'title'
]
=
''
;
/** @test */
public
function
it_requires_description_while_update
()
{
$page
=
create
(
Page
::
class
);
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
post
(
route
(
'admin.pages.store'
),
$page2
)
->
assertSessionHasErrors
(
'title'
);
$page1
=
$page
->
toArray
();
$page
3
[
'description'
]
=
''
;
$page
1
[
'description'
]
=
''
;
$this
->
withExceptionHandling
()
->
actingAs
(
$this
->
admin
)
->
p
ost
(
route
(
'admin.pages.store'
),
$page3
)
->
p
atch
(
route
(
'admin.pages.update'
,
$page
),
$page1
)
->
assertSessionHasErrors
(
'description'
);
}
...
...
tests/Unit/Models/BlogTest.php
0 → 100644
View file @
55b49b3a
<?php
namespace
Tests\Unit\Models
;
use
Carbon\Carbon
;
use
Tests\TestCase
;
use
App\Models\Blogs\Blog
;
use
App\Models\BlogTags\BlogTag
;
use
App\Models\Access\User\User
;
use
App\Models\BlogCategories\BlogCategory
;
use
Illuminate\Foundation\Testing\WithFaker
;
class
BlogTest
extends
TestCase
{
/** @test */
public
function
it_has_categories
()
{
$this
->
actingAs
(
$this
->
admin
);
$blog
=
create
(
Blog
::
class
,
[
'created_by'
=>
access
()
->
id
()]);
$category
=
create
(
BlogCategory
::
class
);
$blog
->
categories
()
->
sync
(
array
(
$category
->
id
));
$this
->
assertInstanceOf
(
BlogCategory
::
class
,
$blog
->
categories
->
first
());
$this
->
assertEquals
(
$category
->
id
,
$blog
->
categories
->
first
()
->
id
);
}
/** @test */
public
function
it_has_tags
()
{
$this
->
actingAs
(
$this
->
admin
);
$blog
=
create
(
Blog
::
class
,
[
'created_by'
=>
access
()
->
id
()]);
$tag
=
create
(
BlogTag
::
class
);
$blog
->
tags
()
->
sync
(
array
(
$tag
->
id
));
$this
->
assertInstanceOf
(
BlogTag
::
class
,
$blog
->
tags
->
first
());
$this
->
assertEquals
(
$tag
->
id
,
$blog
->
tags
->
first
()
->
id
);
}
/** @test */
public
function
it_has_an_owner
()
{
$this
->
actingAs
(
$this
->
admin
);
$blog
=
create
(
Blog
::
class
);
$this
->
assertInstanceOf
(
User
::
class
,
$blog
->
owner
);
}
/** @test */
public
function
it_has_a_carbon_date_field_for_publish_datetime
()
{
$this
->
actingAs
(
$this
->
admin
);
$blog
=
create
(
Blog
::
class
);
$this
->
assertInstanceOf
(
Carbon
::
class
,
$blog
->
publish_datetime
);
}
}
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