jonnybarnes.uk/tests/Feature/ActivityStreamTest.php

61 lines
1.9 KiB
PHP
Raw Normal View History

2017-09-11 16:08:58 +01:00
<?php
2021-03-17 18:38:18 +00:00
declare(strict_types=1);
2017-09-11 16:08:58 +01:00
namespace Tests\Feature;
2021-03-17 18:38:18 +00:00
use App\Models\Note;
use Illuminate\Foundation\Testing\RefreshDatabase;
2017-09-11 16:08:58 +01:00
use Tests\TestCase;
class ActivityStreamTest extends TestCase
{
use RefreshDatabase;
2021-03-17 18:38:18 +00:00
/** @test */
public function homepageRequestReturnsDataForSiteOwner(): void
2017-09-11 16:08:58 +01:00
{
$response = $this->get('/', ['Accept' => 'application/activity+json']);
2022-05-14 17:44:14 +01:00
$response->assertHeader('Content-Type', 'application/activity+json');
$response->assertJson([
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => config('app.url'),
'type' => 'Person',
'name' => config('user.displayname'),
]);
}
/** @test */
public function notesPageContainsAuthorActivityStreamData(): void
{
$response = $this->get('/notes', ['Accept' => 'application/activity+json']);
2017-09-11 16:08:58 +01:00
$response->assertHeader('Content-Type', 'application/activity+json');
$response->assertJson([
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => config('app.url'),
'type' => 'Person',
2017-09-13 17:56:47 +01:00
'name' => config('user.displayname'),
2017-09-11 16:08:58 +01:00
]);
}
2017-09-13 15:49:37 +01:00
2021-03-17 18:38:18 +00:00
/** @test */
public function requestForNoteIncludesActivityStreamData(): void
2017-09-13 15:49:37 +01:00
{
$note = Note::factory()->create();
$response = $this->get($note->longurl, ['Accept' => 'application/activity+json']);
2017-09-13 15:49:37 +01:00
$response->assertHeader('Content-Type', 'application/activity+json');
$response->assertJson([
'@context' => 'https://www.w3.org/ns/activitystreams',
'type' => 'Add',
'actor' => [
'type' => 'Person',
'id' => config('app.url'),
],
'object' => [
'type' => 'Note',
2022-07-09 10:08:26 +01:00
'name' => strip_tags($note->note),
],
2017-09-13 15:49:37 +01:00
]);
}
2017-09-11 16:08:58 +01:00
}