initial commit
This commit is contained in:
35
tests/Feature/CreateApiTokenTest.php
Normal file
35
tests/Feature/CreateApiTokenTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Laravel\Jetstream\Features;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CreateApiTokenTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_api_tokens_can_be_created()
|
||||
{
|
||||
if (! Features::hasApiFeatures()) {
|
||||
return $this->markTestSkipped('API support is not enabled.');
|
||||
}
|
||||
|
||||
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
|
||||
|
||||
$response = $this->post('/user/api-tokens', [
|
||||
'name' => 'Test Token',
|
||||
'permissions' => [
|
||||
'read',
|
||||
'update',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertCount(1, $user->fresh()->tokens);
|
||||
$this->assertEquals('Test Token', $user->fresh()->tokens->first()->name);
|
||||
$this->assertTrue($user->fresh()->tokens->first()->can('read'));
|
||||
$this->assertFalse($user->fresh()->tokens->first()->can('delete'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user