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
50c304da
Commit
50c304da
authored
Apr 03, 2018
by
cygnet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes done for pages test and correcting a logic at one place from repository
parent
af02a4a4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
14 deletions
+70
-14
PagesController.php
app/Http/Controllers/Api/V1/PagesController.php
+4
-3
PagesRepository.php
app/Repositories/Backend/Pages/PagesRepository.php
+5
-2
PageFactory.php
database/factories/PageFactory.php
+0
-1
PageTest.php
tests/Feature/Api/V1/PageTest.php
+61
-8
No files found.
app/Http/Controllers/Api/V1/PagesController.php
View file @
50c304da
...
...
@@ -57,14 +57,15 @@ class PagesController extends APIController
*/
public
function
store
(
Request
$request
)
{
$validation
=
$this
->
validatePages
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
$this
->
repository
->
create
(
$request
->
all
());
return
new
PagesResource
(
Page
::
orderBy
(
'created_at'
,
'desc'
)
->
first
()
);
$page
=
$this
->
repository
->
create
(
$request
->
all
());
return
new
PagesResource
(
$page
);
}
/**
...
...
app/Repositories/Backend/Pages/PagesRepository.php
View file @
50c304da
...
...
@@ -57,11 +57,14 @@ class PagesRepository extends BaseRepository
if
(
$page
=
Page
::
create
(
$input
))
{
event
(
new
PageCreated
(
$page
));
return
tru
e
;
return
$pag
e
;
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.pages.create_error'
));
}
/**
...
...
database/factories/PageFactory.php
View file @
50c304da
...
...
@@ -10,7 +10,6 @@ $factory->define(Page::class, function (Faker $faker) {
$newestPage
=
Page
::
orderBy
(
'id'
,
'desc'
)
->
first
();
return
[
"id"
=>
$newestPage
->
id
+
1
,
'title'
=>
$title
,
'page_slug'
=>
str_slug
(
$title
),
'description'
=>
$faker
->
paragraph
,
...
...
tests/Feature/Api/V1/PageTest.php
View file @
50c304da
...
...
@@ -90,12 +90,15 @@ class PageTest extends TestCase
}
/**
* A basic test to create a page from api
* Author: Indra Shastri
* Date:03-03-2018
* A basic test to update a page from api
*
*
* @return void
*/
/** @test */
public
function
create_a_new
_page_in_db_and_get_response
()
public
function
update_a
_page_in_db_and_get_response
()
{
$page
=
make
(
Page
::
class
);
$payload
=
[
...
...
@@ -107,12 +110,12 @@ class PageTest extends TestCase
"seo_description"
=>
"<p> </p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>"
,
"status"
=>
"1"
,
];
$response
=
$this
->
json
(
'POST'
,
'/api/v1/pages'
,
$payload
,
$this
->
headers
);
$response
->
assertStatus
(
200
)
->
assertJson
([
$response
=
""
;
$response
=
$this
->
json
(
'PUT'
,
'/api/v1/pages/1'
,
$payload
,
$this
->
headers
);
$response
->
assertStatus
(
200
);
$response
->
assertJson
([
"data"
=>
[
"id"
=>
$page
->
id
,
"title"
=>
$page
->
title
,
"status_label"
=>
$page
->
status_label
,
"status"
=>
(
$page
->
isActive
())
?
'Active'
:
'InActive'
,
...
...
@@ -121,5 +124,55 @@ class PageTest extends TestCase
]);
}
/**
* Author: Indra Shastri
* Date:03-03-2018
* A basic test to create a page from api
*
* @return void
*/
/** @test */
public
function
create_a_new_page_in_db_and_get_response
()
{
$page
=
make
(
Page
::
class
);
$payload
=
[
"title"
=>
$page
->
title
,
"description"
=>
$page
->
description
,
"cannonical_link"
=>
$page
->
cannonical_link
,
"seo_title"
=>
"some tittle"
,
"seo_keyword"
=>
"some keywords"
,
"seo_description"
=>
"<p> </p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>"
,
"status"
=>
"1"
,
];
$response
=
""
;
$response
=
$this
->
json
(
'POST'
,
'/api/v1/pages'
,
$payload
,
$this
->
headers
);
$response
->
assertStatus
(
201
);
$response
->
assertJson
([
"data"
=>
[
"title"
=>
$page
->
title
,
"status_label"
=>
$page
->
status_label
,
"status"
=>
(
$page
->
isActive
())
?
'Active'
:
'InActive'
,
"created_by"
=>
$this
->
user
->
first_name
,
"created_at"
=>
(
\Carbon\Carbon
::
now
())
->
toDateString
()
],
]);
}
/**
* Author: Indra Shastri
* Date:03-03-2018
* A basic test to create a page from api
*
* @return void
*/
/** @test */
public
function
delete_page_in_db_and_get_response
(){
$page
=
create
(
Page
::
class
);
$payload
=
[];
$response
=
$this
->
json
(
'DELETE'
,
'/api/v1/pages/'
.
$page
->
id
,
$payload
,
$this
->
headers
);
$response
->
assertStatus
(
200
)
->
assertJson
([
"message"
=>
"The Page was successfully deleted."
]);
}
}
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