Merge pull request #525 from jonnybarnes/develop
MTM Post Markdown content to Mastodon
This commit is contained in:
commit
52ac67ba7a
2 changed files with 31 additions and 1 deletions
|
@ -54,7 +54,7 @@ class SyndicateNoteToMastodon implements ShouldQueue
|
||||||
'json' => [
|
'json' => [
|
||||||
'type' => ['h-entry'],
|
'type' => ['h-entry'],
|
||||||
'properties' => [
|
'properties' => [
|
||||||
'content' => [$this->note->note],
|
'content' => [$this->note->getRawOriginal('note')],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,6 +8,7 @@ use Faker\Factory;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Handler\MockHandler;
|
use GuzzleHttp\Handler\MockHandler;
|
||||||
use GuzzleHttp\HandlerStack;
|
use GuzzleHttp\HandlerStack;
|
||||||
|
use GuzzleHttp\Middleware;
|
||||||
use GuzzleHttp\Psr7\Response;
|
use GuzzleHttp\Psr7\Response;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
@ -36,4 +37,33 @@ class SyndicateNoteToMastodonJobTest extends TestCase
|
||||||
'mastodon_url' => 'https://mastodon.example/@jonny/' . $randomNumber,
|
'mastodon_url' => 'https://mastodon.example/@jonny/' . $randomNumber,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function weSyndicateTheOriginalMarkdown(): void
|
||||||
|
{
|
||||||
|
config(['bridgy.mastodon_token' => 'test']);
|
||||||
|
$faker = Factory::create();
|
||||||
|
$randomNumber = $faker->randomNumber();
|
||||||
|
|
||||||
|
$container = [];
|
||||||
|
$history = Middleware::history($container);
|
||||||
|
$mock = new MockHandler([
|
||||||
|
new Response(201, ['Location' => 'https://mastodon.example/@jonny/' . $randomNumber]),
|
||||||
|
]);
|
||||||
|
$handler = HandlerStack::create($mock);
|
||||||
|
$handler->push($history);
|
||||||
|
$client = new Client(['handler' => $handler]);
|
||||||
|
|
||||||
|
$note = Note::factory()->create(['note' => 'This is a **test**']);
|
||||||
|
$job = new SyndicateNoteToMastodon($note);
|
||||||
|
$job->handle($client);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('notes', [
|
||||||
|
'mastodon_url' => 'https://mastodon.example/@jonny/' . $randomNumber,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$expectedRequestContent = '{"type":["h-entry"],"properties":{"content":["This is a **test**"]}}';
|
||||||
|
|
||||||
|
$this->assertEquals($expectedRequestContent, $container[0]['request']->getBody()->getContents());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue