Unverified Commit 4438a441 authored by Viral Solani's avatar Viral Solani Committed by GitHub

Merge pull request #202 from viralsolani/analysis-q5QrRW

Apply fixes from StyleCI
parents 7000b869 613f5070
......@@ -57,7 +57,6 @@ class PagesController extends APIController
*/
public function store(Request $request)
{
$validation = $this->validatePages($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
......
......@@ -2,7 +2,6 @@
namespace App\Http\Controllers\Api\V1;
use App\Http\Requests\Backend\Access\User\ManageUserRequest;
use App\Http\Resources\UserResource;
use App\Models\Access\User\User;
use App\Repositories\Backend\Access\User\UserRepository;
......
......@@ -12,6 +12,6 @@ class VerifyCsrfToken extends BaseVerifier
* @var array
*/
protected $except = [
'api/*'
'api/*',
];
}
......@@ -62,9 +62,6 @@ class PagesRepository extends BaseRepository
}
throw new GeneralException(trans('exceptions.backend.pages.create_error'));
}
/**
......
......@@ -13,7 +13,7 @@ $factory->define(Page::class, function (Faker $faker) {
'title' => $title,
'page_slug' => str_slug($title),
'description' => $faker->paragraph,
'cannonical_link' => "http://localhost:8000/".str_slug($title),
'cannonical_link' => 'http://localhost:8000/'.str_slug($title),
'created_by' => function () {
return factory(User::class)->create()->id;
},
......
......@@ -2,29 +2,26 @@
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\Page\Page;
use JWTAuth;
use Tests\TestCase;
class PageTest extends TestCase
{
public $token='';
public $headers='';
public $user='';
public $token = '';
public $headers = '';
public $user = '';
public function setUp()
{
parent::setUp();
$this->user = User::find(1);
$this->token = JWTAuth::fromUser($this->user);
$this->headers = ['Authorization' => "Bearer ".$this->token];
$this->headers = ['Authorization' => 'Bearer '.$this->token];
}
/**
* A basic test example.
*
......@@ -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
*/
/** @test */
public function Get_records_from_pages()
{
$payload = [];
$response = $this->json('GET', '/api/v1/pages',$payload, $this->headers);
$response = $this->json('GET', '/api/v1/pages', $payload, $this->headers);
$response
->assertStatus(200)
->assertJsonStructure([
'data'=>[
'data'=> [
[
"id",
"title",
"status_label",
"status",
"created_at",
"created_by"
]
'id',
'title',
'status_label',
'status',
'created_at',
'created_by',
],
],
'links',
'meta'
'meta',
]);
}
/**
* A basic test to get response form pages api
* A basic test to get response form pages api.
*
* @return void
*/
/** @test */
public function get_one_created_page_from_db()
{
......@@ -79,101 +76,104 @@ class PageTest extends TestCase
$response
->assertStatus(200)
->assertJson([
"data"=>[
"id" => $page->id,
"title" => $page->title,
"status_label" => $page->status_label,
"status" => ($page->isActive()) ? 'Active' :'InActive',
"created_by" => $page->created_by,
'data'=> [
'id' => $page->id,
'title' => $page->title,
'status_label' => $page->status_label,
'status' => ($page->isActive()) ? 'Active' : 'InActive',
'created_by' => $page->created_by,
],
]);
}
/**
* Author: Indra Shastri
* Date:03-03-2018
* A basic test to update a page from api
* A basic test to update a page from api.
*
*
* @return void
*/
/** @test */
public function update_a_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>&nbsp;</p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>",
"status" => "1",
'title' => $page->title,
'description' => $page->description,
'cannonical_link' => $page->cannonical_link,
'seo_title' => 'some tittle',
'seo_keyword' => 'some keywords',
'seo_description' => '<p>&nbsp;</p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>',
'status' => '1',
];
$response = "";
$response = '';
$response = $this->json('PUT', '/api/v1/pages/1', $payload, $this->headers);
$response->assertStatus(200);
$response->assertJson([
"data"=>[
"title" => $page->title,
"status_label" => $page->status_label,
"status" => ($page->isActive()) ? 'Active' :'InActive',
"created_by" => "".$this->user->id,
'data'=> [
'title' => $page->title,
'status_label' => $page->status_label,
'status' => ($page->isActive()) ? 'Active' : 'InActive',
'created_by' => ''.$this->user->id,
],
]);
}
/**
* Author: Indra Shastri
* Date:03-03-2018
* A basic test to create a page from api
* 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>&nbsp;</p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>",
"status" => "1",
'title' => $page->title,
'description' => $page->description,
'cannonical_link' => $page->cannonical_link,
'seo_title' => 'some tittle',
'seo_keyword' => 'some keywords',
'seo_description' => '<p>&nbsp;</p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p>',
'status' => '1',
];
$response = "";
$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()
'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
* A basic test to create a page from api.
*
* @return void
*/
/** @test */
public function delete_page_in_db_and_get_response(){
public function delete_page_in_db_and_get_response()
{
$page = create(Page::class);
$payload=[];
$payload = [];
$response = $this->json('DELETE', '/api/v1/pages/'.$page->id, $payload, $this->headers);
$response->assertStatus(200)
->assertJson([
"message"=> "The Page was successfully deleted."
'message'=> 'The Page was successfully deleted.',
]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment