Allow notes to be syndicated to Mastodon
This commit is contained in:
parent
ffe90b9399
commit
72cb4fd7eb
11 changed files with 200 additions and 5 deletions
39
tests/Unit/Jobs/SyndicateNoteToMastodonJobTest.php
Normal file
39
tests/Unit/Jobs/SyndicateNoteToMastodonJobTest.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit\Jobs;
|
||||
|
||||
use App\Jobs\SyndicateNoteToMastodon;
|
||||
use App\Models\Note;
|
||||
use Faker\Factory;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SyndicateNoteToMastodonJobTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
public function weSyndicateNotesToMastodon(): void
|
||||
{
|
||||
config(['bridgy.mastodon_token' => 'test']);
|
||||
$faker = Factory::create();
|
||||
$randomNumber = $faker->randomNumber();
|
||||
$mock = new MockHandler([
|
||||
new Response(201, ['Location' => 'https://mastodon.example/@jonny/' . $randomNumber]),
|
||||
]);
|
||||
$handler = HandlerStack::create($mock);
|
||||
$client = new Client(['handler' => $handler]);
|
||||
|
||||
$note = Note::factory()->create();
|
||||
$job = new SyndicateNoteToMastodon($note);
|
||||
$job->handle($client);
|
||||
|
||||
$this->assertDatabaseHas('notes', [
|
||||
'mastodon_url' => 'https://mastodon.example/@jonny/' . $randomNumber,
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue