mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\User;
|
|
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
|
use Laravel\Passport\Passport;
|
|
|
|
uses(LazilyRefreshDatabase::class);
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Collection Tests
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
describe('collections', function () {
|
|
it('lists self collections', function () {
|
|
$user = User::factory()->create();
|
|
$user->refresh();
|
|
Passport::actingAs($user, ['read']);
|
|
|
|
$this->getJson('/api/pixelfed/v1/collections/self')
|
|
->assertOk()
|
|
->assertJsonIsArray();
|
|
});
|
|
|
|
it('lists user collections by account id', function () {
|
|
$user = User::factory()->create();
|
|
$user->refresh();
|
|
Passport::actingAs($user, ['read']);
|
|
|
|
$this->getJson("/api/pixelfed/v1/collections/accounts/{$user->profile_id}")
|
|
->assertOk()
|
|
->assertJsonIsArray();
|
|
});
|
|
|
|
it('returns 404 for non-existent collection', function () {
|
|
$user = User::factory()->create();
|
|
$user->refresh();
|
|
Passport::actingAs($user, ['read']);
|
|
|
|
$this->getJson('/api/pixelfed/v1/collections/view/999999')
|
|
->assertNotFound();
|
|
});
|
|
|
|
it('requires authentication for self collections', function () {
|
|
$this->getJson('/api/pixelfed/v1/collections/self')
|
|
->assertUnauthorized();
|
|
});
|
|
});
|