Created
May 27, 2020 01:24
-
-
Save elenakondrateva/1ed0af23fe563bde3c8e53dab399b904 to your computer and use it in GitHub Desktop.
To test Laravel Backpack edit/update action we need to pass some extra parameters
This file contains hidden or 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; | |
use App\Models\Permission; | |
use App\Models\Role; | |
use Tests\TestCase; | |
/** | |
* Class RoleTest | |
* @package Tests\Feature | |
* @group roles | |
*/ | |
class RoleTest extends TestCase | |
{ | |
/** | |
* @test | |
*/ | |
public function a_super_admin_can_update_role_permissions() | |
{ | |
$this->superUserSignIn(); | |
/** @var Role $role */ | |
$role = factory(Role::class)->create(); | |
/** @var Permission $permission */ | |
$permission = factory(Permission::class)->create(); | |
$this->withSession(['_token' => 'FAKE_CSRF_TOKEN']) | |
->put( backpack_url('role') . '/' . $role->id, [ | |
'name' => $role->name, | |
'permissions' => [$permission->id], | |
'id' => $role->id, | |
]) | |
->assertStatus(302) | |
; | |
$role->refresh(); | |
$this->assertTrue($role->hasPermissionTo($permission)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment