Created
December 8, 2017 10:38
-
-
Save mdcass/026cd6789b04151a5885c65db59e5e9f to your computer and use it in GitHub Desktop.
Laravel Test debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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