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
7f0cd844
Commit
7f0cd844
authored
Jan 08, 2018
by
Vipul Basapati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Faqs Tests Completed
parent
75264183
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
1 deletion
+115
-1
FaqFactory.php
database/factories/FaqFactory.php
+12
-0
ManageBlogsTest.php
tests/Feature/Backend/ManageBlogsTest.php
+0
-1
ManageFaqsTest.php
tests/Feature/Backend/ManageFaqsTest.php
+103
-0
No files found.
database/factories/FaqFactory.php
0 → 100644
View file @
7f0cd844
<?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
)
];
});
tests/Feature/Backend/ManageBlogsTest.php
View file @
7f0cd844
...
@@ -9,7 +9,6 @@ use Illuminate\Http\UploadedFile;
...
@@ -9,7 +9,6 @@ use Illuminate\Http\UploadedFile;
use
Illuminate\Support\Facades\Storage
;
use
Illuminate\Support\Facades\Storage
;
use
App\Models\BlogCategories\BlogCategory
;
use
App\Models\BlogCategories\BlogCategory
;
use
Illuminate\Foundation\Testing\WithFaker
;
use
Illuminate\Foundation\Testing\WithFaker
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
class
ManageBlogsTest
extends
TestCase
class
ManageBlogsTest
extends
TestCase
{
{
...
...
tests/Feature/Backend/ManageFaqsTest.php
0 → 100644
View file @
7f0cd844
<?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
]);
}
}
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