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
4438a441
Unverified
Commit
4438a441
authored
Apr 03, 2018
by
Viral Solani
Committed by
GitHub
Apr 03, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #202 from viralsolani/analysis-q5QrRW
Apply fixes from StyleCI
parents
7000b869
613f5070
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
87 deletions
+82
-87
PagesController.php
app/Http/Controllers/Api/V1/PagesController.php
+2
-3
UsersController.php
app/Http/Controllers/Api/V1/UsersController.php
+0
-1
VerifyCsrfToken.php
app/Http/Middleware/VerifyCsrfToken.php
+1
-1
PagesRepository.php
app/Repositories/Backend/Pages/PagesRepository.php
+1
-4
PageFactory.php
database/factories/PageFactory.php
+7
-7
PageTest.php
tests/Feature/Api/V1/PageTest.php
+71
-71
No files found.
app/Http/Controllers/Api/V1/PagesController.php
View file @
4438a441
...
@@ -57,14 +57,13 @@ class PagesController extends APIController
...
@@ -57,14 +57,13 @@ class PagesController extends APIController
*/
*/
public
function
store
(
Request
$request
)
public
function
store
(
Request
$request
)
{
{
$validation
=
$this
->
validatePages
(
$request
);
$validation
=
$this
->
validatePages
(
$request
);
if
(
$validation
->
fails
())
{
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
}
$page
=
$this
->
repository
->
create
(
$request
->
all
());
$page
=
$this
->
repository
->
create
(
$request
->
all
());
return
new
PagesResource
(
$page
);
return
new
PagesResource
(
$page
);
}
}
...
...
app/Http/Controllers/Api/V1/UsersController.php
View file @
4438a441
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
namespace
App\Http\Controllers\Api\V1
;
namespace
App\Http\Controllers\Api\V1
;
use
App\Http\Requests\Backend\Access\User\ManageUserRequest
;
use
App\Http\Resources\UserResource
;
use
App\Http\Resources\UserResource
;
use
App\Models\Access\User\User
;
use
App\Models\Access\User\User
;
use
App\Repositories\Backend\Access\User\UserRepository
;
use
App\Repositories\Backend\Access\User\UserRepository
;
...
...
app/Http/Middleware/VerifyCsrfToken.php
View file @
4438a441
...
@@ -12,6 +12,6 @@ class VerifyCsrfToken extends BaseVerifier
...
@@ -12,6 +12,6 @@ class VerifyCsrfToken extends BaseVerifier
* @var array
* @var array
*/
*/
protected
$except
=
[
protected
$except
=
[
'api/*'
'api/*'
,
];
];
}
}
app/Repositories/Backend/Pages/PagesRepository.php
View file @
4438a441
...
@@ -57,14 +57,11 @@ class PagesRepository extends BaseRepository
...
@@ -57,14 +57,11 @@ class PagesRepository extends BaseRepository
if
(
$page
=
Page
::
create
(
$input
))
{
if
(
$page
=
Page
::
create
(
$input
))
{
event
(
new
PageCreated
(
$page
));
event
(
new
PageCreated
(
$page
));
return
$page
;
return
$page
;
}
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.pages.create_error'
));
throw
new
GeneralException
(
trans
(
'exceptions.backend.pages.create_error'
));
}
}
/**
/**
...
...
database/factories/PageFactory.php
View file @
4438a441
...
@@ -10,15 +10,15 @@ $factory->define(Page::class, function (Faker $faker) {
...
@@ -10,15 +10,15 @@ $factory->define(Page::class, function (Faker $faker) {
$newestPage
=
Page
::
orderBy
(
'id'
,
'desc'
)
->
first
();
$newestPage
=
Page
::
orderBy
(
'id'
,
'desc'
)
->
first
();
return
[
return
[
'title'
=>
$title
,
'title'
=>
$title
,
'page_slug'
=>
str_slug
(
$title
),
'page_slug'
=>
str_slug
(
$title
),
'description'
=>
$faker
->
paragraph
,
'description'
=>
$faker
->
paragraph
,
'cannonical_link'
=>
"http://localhost:8000/"
.
str_slug
(
$title
),
'cannonical_link'
=>
'http://localhost:8000/'
.
str_slug
(
$title
),
'created_by'
=>
function
()
{
'created_by'
=>
function
()
{
return
factory
(
User
::
class
)
->
create
()
->
id
;
return
factory
(
User
::
class
)
->
create
()
->
id
;
},
},
'status'
=>
1
,
'status'
=>
1
,
'created_at'
=>
Carbon\Carbon
::
now
(),
'created_at'
=>
Carbon\Carbon
::
now
(),
'updated_at'
=>
Carbon\Carbon
::
now
(),
'updated_at'
=>
Carbon\Carbon
::
now
(),
];
];
});
});
tests/Feature/Api/V1/PageTest.php
View file @
4438a441
...
@@ -2,29 +2,26 @@
...
@@ -2,29 +2,26 @@
namespace
Tests\Feature\Api\V1
;
namespace
Tests\Feature\Api\V1
;
use
Tests\TestCase
;
use
Illuminate\Foundation\Testing\WithFaker
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
use
Tests\BrowserKitTestCase
;
use
App\Models\Access\User\User
;
use
App\Models\Access\User\User
;
use
App\Models\Page\Page
;
use
App\Models\Page\Page
;
use
JWTAuth
;
use
JWTAuth
;
use
Tests\TestCase
;
class
PageTest
extends
TestCase
class
PageTest
extends
TestCase
{
{
public
$token
=
''
;
public
$token
=
''
;
public
$headers
=
''
;
public
$headers
=
''
;
public
$user
=
''
;
public
$user
=
''
;
public
function
setUp
()
public
function
setUp
()
{
{
parent
::
setUp
();
parent
::
setUp
();
$this
->
user
=
User
::
find
(
1
);
$this
->
user
=
User
::
find
(
1
);
$this
->
token
=
JWTAuth
::
fromUser
(
$this
->
user
);
$this
->
token
=
JWTAuth
::
fromUser
(
$this
->
user
);
$this
->
headers
=
[
'Authorization'
=>
"Bearer "
.
$this
->
token
];
$this
->
headers
=
[
'Authorization'
=>
'Bearer '
.
$this
->
token
];
}
}
/**
/**
* A basic test example.
* A basic test example.
*
*
...
@@ -36,40 +33,40 @@ class PageTest extends TestCase
...
@@ -36,40 +33,40 @@ class PageTest extends TestCase
}
}
/**
/**
* A basic test to get response form pages api
* A basic test to get response form pages api
.
*
*
* @return void
* @return void
*/
*/
/** @test */
/** @test */
public
function
Get_records_from_pages
()
public
function
Get_records_from_pages
()
{
{
$payload
=
[];
$payload
=
[];
$response
=
$this
->
json
(
'GET'
,
'/api/v1/pages'
,
$payload
,
$this
->
headers
);
$response
=
$this
->
json
(
'GET'
,
'/api/v1/pages'
,
$payload
,
$this
->
headers
);
$response
$response
->
assertStatus
(
200
)
->
assertStatus
(
200
)
->
assertJsonStructure
([
->
assertJsonStructure
([
'data'
=>
[
'data'
=>
[
[
[
"id"
,
'id'
,
"title"
,
'title'
,
"status_label"
,
'status_label'
,
"status"
,
'status'
,
"created_at"
,
'created_at'
,
"created_by"
'created_by'
,
]
]
,
],
],
'links'
,
'links'
,
'meta'
'meta'
,
]);
]);
}
}
/**
/**
* A basic test to get response form pages api
* A basic test to get response form pages api
.
*
*
* @return void
* @return void
*/
*/
/** @test */
/** @test */
public
function
get_one_created_page_from_db
()
public
function
get_one_created_page_from_db
()
{
{
...
@@ -79,101 +76,104 @@ class PageTest extends TestCase
...
@@ -79,101 +76,104 @@ class PageTest extends TestCase
$response
$response
->
assertStatus
(
200
)
->
assertStatus
(
200
)
->
assertJson
([
->
assertJson
([
"data"
=>
[
'data'
=>
[
"id"
=>
$page
->
id
,
'id'
=>
$page
->
id
,
"title"
=>
$page
->
title
,
'title'
=>
$page
->
title
,
"status_label"
=>
$page
->
status_label
,
'status_label'
=>
$page
->
status_label
,
"status"
=>
(
$page
->
isActive
())
?
'Active'
:
'InActive'
,
'status'
=>
(
$page
->
isActive
())
?
'Active'
:
'InActive'
,
"created_by"
=>
$page
->
created_by
,
'created_by'
=>
$page
->
created_by
,
],
],
]);
]);
}
}
/**
/**
* Author: Indra Shastri
* Author: Indra Shastri
* Date:03-03-2018
* Date:03-03-2018
* A basic test to update a page from api
* A basic test to update a page from api
.
*
*
*
*
* @return void
* @return void
*/
*/
/** @test */
/** @test */
public
function
update_a_page_in_db_and_get_response
()
public
function
update_a_page_in_db_and_get_response
()
{
{
$page
=
make
(
Page
::
class
);
$page
=
make
(
Page
::
class
);
$payload
=
[
$payload
=
[
"title"
=>
$page
->
title
,
'title'
=>
$page
->
title
,
"description"
=>
$page
->
description
,
'description'
=>
$page
->
description
,
"cannonical_link"
=>
$page
->
cannonical_link
,
'cannonical_link'
=>
$page
->
cannonical_link
,
"seo_title"
=>
"some tittle"
,
'seo_title'
=>
'some tittle'
,
"seo_keyword"
=>
"some keywords"
,
'seo_keyword'
=>
'some keywords'
,
"seo_description"
=>
"<p> </p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>"
,
'seo_description'
=>
'<p> </p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>'
,
"status"
=>
"1"
,
'status'
=>
'1'
,
];
];
$response
=
""
;
$response
=
''
;
$response
=
$this
->
json
(
'PUT'
,
'/api/v1/pages/1'
,
$payload
,
$this
->
headers
);
$response
=
$this
->
json
(
'PUT'
,
'/api/v1/pages/1'
,
$payload
,
$this
->
headers
);
$response
->
assertStatus
(
200
);
$response
->
assertStatus
(
200
);
$response
->
assertJson
([
$response
->
assertJson
([
"data"
=>
[
'data'
=>
[
"title"
=>
$page
->
title
,
'title'
=>
$page
->
title
,
"status_label"
=>
$page
->
status_label
,
'status_label'
=>
$page
->
status_label
,
"status"
=>
(
$page
->
isActive
())
?
'Active'
:
'InActive'
,
'status'
=>
(
$page
->
isActive
())
?
'Active'
:
'InActive'
,
"created_by"
=>
""
.
$this
->
user
->
id
,
'created_by'
=>
''
.
$this
->
user
->
id
,
],
],
]);
]);
}
}
/**
/**
* Author: Indra Shastri
* Author: Indra Shastri
* Date:03-03-2018
* Date:03-03-2018
* A basic test to create a page from api
* A basic test to create a page from api
.
*
*
* @return void
* @return void
*/
*/
/** @test */
/** @test */
public
function
create_a_new_page_in_db_and_get_response
()
public
function
create_a_new_page_in_db_and_get_response
()
{
{
$page
=
make
(
Page
::
class
);
$page
=
make
(
Page
::
class
);
$payload
=
[
$payload
=
[
"title"
=>
$page
->
title
,
'title'
=>
$page
->
title
,
"description"
=>
$page
->
description
,
'description'
=>
$page
->
description
,
"cannonical_link"
=>
$page
->
cannonical_link
,
'cannonical_link'
=>
$page
->
cannonical_link
,
"seo_title"
=>
"some tittle"
,
'seo_title'
=>
'some tittle'
,
"seo_keyword"
=>
"some keywords"
,
'seo_keyword'
=>
'some keywords'
,
"seo_description"
=>
"<p> </p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>"
,
'seo_description'
=>
'<p> </p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>'
,
"status"
=>
"1"
,
'status'
=>
'1'
,
];
];
$response
=
""
;
$response
=
''
;
$response
=
$this
->
json
(
'POST'
,
'/api/v1/pages'
,
$payload
,
$this
->
headers
);
$response
=
$this
->
json
(
'POST'
,
'/api/v1/pages'
,
$payload
,
$this
->
headers
);
$response
->
assertStatus
(
201
);
$response
->
assertStatus
(
201
);
$response
->
assertJson
([
$response
->
assertJson
([
"data"
=>
[
'data'
=>
[
"title"
=>
$page
->
title
,
'title'
=>
$page
->
title
,
"status_label"
=>
$page
->
status_label
,
'status_label'
=>
$page
->
status_label
,
"status"
=>
(
$page
->
isActive
())
?
'Active'
:
'InActive'
,
'status'
=>
(
$page
->
isActive
())
?
'Active'
:
'InActive'
,
"created_by"
=>
$this
->
user
->
first_name
,
'created_by'
=>
$this
->
user
->
first_name
,
"created_at"
=>
(
\Carbon\Carbon
::
now
())
->
toDateString
()
'created_at'
=>
(
\Carbon\Carbon
::
now
())
->
toDateString
(),
],
],
]);
]);
}
}
/**
/**
* Author: Indra Shastri
* Author: Indra Shastri
* Date:03-03-2018
* Date:03-03-2018
* A basic test to create a page from api
* A basic test to create a page from api
.
*
*
* @return void
* @return void
*/
*/
/** @test */
/** @test */
public
function
delete_page_in_db_and_get_response
(){
public
function
delete_page_in_db_and_get_response
()
{
$page
=
create
(
Page
::
class
);
$page
=
create
(
Page
::
class
);
$payload
=
[];
$payload
=
[];
$response
=
$this
->
json
(
'DELETE'
,
'/api/v1/pages/'
.
$page
->
id
,
$payload
,
$this
->
headers
);
$response
=
$this
->
json
(
'DELETE'
,
'/api/v1/pages/'
.
$page
->
id
,
$payload
,
$this
->
headers
);
$response
->
assertStatus
(
200
)
$response
->
assertStatus
(
200
)
->
assertJson
([
->
assertJson
([
"message"
=>
"The Page was successfully deleted."
'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