Skip to content

Instantly share code, notes, and snippets.

@mdcass
Created December 8, 2017 10:38
Show Gist options
  • Save mdcass/026cd6789b04151a5885c65db59e5e9f to your computer and use it in GitHub Desktop.
Save mdcass/026cd6789b04151a5885c65db59e5e9f to your computer and use it in GitHub Desktop.
Laravel Test debugging
<?php
namespace Tests\Feature\Api\V1\CMS;
use App\Models\User;
use CMS\Models\Page;
use CMS\Models\Section;
use Faker\Generator as Faker;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class SectionTest extends TestCase
{
use DatabaseTransactions;
/**
* @var string
*/
protected $connectionsToTransact = ['cms'];
/**
* Test update route
*/
public function testUpdate()
{
/** @var User $user */
$user = factory(User::class)->states('admin')->create();
/** @var Page $page */
$page = factory(Page::class)->create();
$section = factory(Section::class)->create();
$newSectionName = uniqid('New Name Here');
$response = $this->json(
'PATCH',
route('api.v1.cms.pages.sections.update', [$page, $section]),
[
'name' => $newSectionName
],
['Authorization' => 'Bearer ' . $user->jwt_auth_token ]
);
/** Our debugging */
\Storage::disk('local')->put('output.html', $response->getContent());
dd($response->decodeResponseJson()->message);
$response
->assertStatus(200)
->assertJsonFragment([
'title' => $newSectionName
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment