Merge branch 'release/0.17.1'
This commit is contained in:
commit
9f21410349
12 changed files with 5 additions and 328 deletions
|
@ -1,59 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Jobs;
|
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
|
||||||
use App\Models\Bookmark;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
|
|
||||||
class SyndicateBookmarkToFacebook implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
protected $bookmark;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new job instance.
|
|
||||||
*
|
|
||||||
* @param \App\Models\Bookmark $bookmark
|
|
||||||
*/
|
|
||||||
public function __construct(Bookmark $bookmark)
|
|
||||||
{
|
|
||||||
$this->bookmark = $bookmark;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the job.
|
|
||||||
*
|
|
||||||
* @param \GuzzleHttp\Client $guzzle
|
|
||||||
*/
|
|
||||||
public function handle(Client $guzzle)
|
|
||||||
{
|
|
||||||
//send webmention
|
|
||||||
$response = $guzzle->request(
|
|
||||||
'POST',
|
|
||||||
'https://brid.gy/publish/webmention',
|
|
||||||
[
|
|
||||||
'form_params' => [
|
|
||||||
'source' => $this->bookmark->longurl,
|
|
||||||
'target' => 'https://brid.gy/publish/facebook',
|
|
||||||
'bridgy_omit_link' => 'maybe',
|
|
||||||
],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
//parse for syndication URL
|
|
||||||
if ($response->getStatusCode() == 201) {
|
|
||||||
$json = json_decode((string) $response->getBody());
|
|
||||||
$syndicates = $this->bookmark->syndicates;
|
|
||||||
$syndicates['facebook'] = $json->url;
|
|
||||||
$this->bookmark->syndicates = $syndicates;
|
|
||||||
$this->bookmark->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Jobs;
|
|
||||||
|
|
||||||
use App\Models\Note;
|
|
||||||
use GuzzleHttp\Client;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
|
|
||||||
class SyndicateNoteToFacebook implements ShouldQueue
|
|
||||||
{
|
|
||||||
use InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
protected $note;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new job instance.
|
|
||||||
*
|
|
||||||
* @param \App\Models\Note $note
|
|
||||||
*/
|
|
||||||
public function __construct(Note $note)
|
|
||||||
{
|
|
||||||
$this->note = $note;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the job.
|
|
||||||
*
|
|
||||||
* @param \GuzzleHttp\Client $guzzle
|
|
||||||
*/
|
|
||||||
public function handle(Client $guzzle)
|
|
||||||
{
|
|
||||||
//send webmention
|
|
||||||
$response = $guzzle->request(
|
|
||||||
'POST',
|
|
||||||
'https://brid.gy/publish/webmention',
|
|
||||||
[
|
|
||||||
'form_params' => [
|
|
||||||
'source' => $this->note->longurl,
|
|
||||||
'target' => 'https://brid.gy/publish/facebook',
|
|
||||||
'bridgy_omit_link' => 'maybe',
|
|
||||||
],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
//parse for syndication URL
|
|
||||||
if ($response->getStatusCode() == 201) {
|
|
||||||
$json = json_decode((string) $response->getBody());
|
|
||||||
$this->note->facebook_url = $json->url;
|
|
||||||
$this->note->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -400,50 +400,6 @@ class Note extends Model
|
||||||
return $this->convertMarkdown($swapped);
|
return $this->convertMarkdown($swapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a specific form of the note for Facebook.
|
|
||||||
*
|
|
||||||
* That is we swap the contacts names for their known Facebook usernames.
|
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function getFacebookContentAttribute(): ?string
|
|
||||||
{
|
|
||||||
if ($this->contacts === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($this->contacts) === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count(array_unique(array_values($this->contacts))) === 1
|
|
||||||
&& array_unique(array_values($this->contacts))[0] === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// swap in facebook usernames
|
|
||||||
$swapped = preg_replace_callback(
|
|
||||||
self::USERNAMES_REGEX,
|
|
||||||
function ($matches) {
|
|
||||||
if (is_null($this->contacts[$matches[1]])) {
|
|
||||||
return $matches[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
$contact = $this->contacts[$matches[1]];
|
|
||||||
if ($contact->facebook) {
|
|
||||||
return '<a class="u-category h-card" href="https://facebook.com/'
|
|
||||||
. $contact->facebook . '">' . $contact->name . '</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $contact->name;
|
|
||||||
},
|
|
||||||
$this->getOriginal('note')
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->convertMarkdown($swapped);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope a query to select a note via a NewBase60 id.
|
* Scope a query to select a note via a NewBase60 id.
|
||||||
*
|
*
|
||||||
|
|
|
@ -11,7 +11,6 @@ use App\Jobs\ProcessBookmark;
|
||||||
use App\Models\{Bookmark, Tag};
|
use App\Models\{Bookmark, Tag};
|
||||||
use Spatie\Browsershot\Browsershot;
|
use Spatie\Browsershot\Browsershot;
|
||||||
use App\Jobs\SyndicateBookmarkToTwitter;
|
use App\Jobs\SyndicateBookmarkToTwitter;
|
||||||
use App\Jobs\SyndicateBookmarkToFacebook;
|
|
||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use App\Exceptions\InternetArchiveException;
|
use App\Exceptions\InternetArchiveException;
|
||||||
|
|
||||||
|
@ -63,9 +62,6 @@ class BookmarkService
|
||||||
if ($service == 'Twitter') {
|
if ($service == 'Twitter') {
|
||||||
SyndicateBookmarkToTwitter::dispatch($bookmark);
|
SyndicateBookmarkToTwitter::dispatch($bookmark);
|
||||||
}
|
}
|
||||||
if ($service == 'Facebook') {
|
|
||||||
SyndicateBookmarkToFacebook::dispatch($bookmark);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (is_array($mpSyndicateTo)) {
|
if (is_array($mpSyndicateTo)) {
|
||||||
foreach ($mpSyndicateTo as $uid) {
|
foreach ($mpSyndicateTo as $uid) {
|
||||||
|
@ -73,9 +69,6 @@ class BookmarkService
|
||||||
if ($service == 'Twitter') {
|
if ($service == 'Twitter') {
|
||||||
SyndicateBookmarkToTwitter::dispatch($bookmark);
|
SyndicateBookmarkToTwitter::dispatch($bookmark);
|
||||||
}
|
}
|
||||||
if ($service == 'Facebook') {
|
|
||||||
SyndicateBookmarkToFacebook::dispatch($bookmark);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Models\{Media, Note, Place};
|
use App\Models\{Media, Note, Place};
|
||||||
use App\Jobs\{SendWebMentions, SyndicateNoteToFacebook, SyndicateNoteToTwitter};
|
use App\Jobs\{SendWebMentions, SyndicateNoteToTwitter};
|
||||||
|
|
||||||
class NoteService
|
class NoteService
|
||||||
{
|
{
|
||||||
|
@ -52,9 +52,6 @@ class NoteService
|
||||||
if (in_array('twitter', $this->getSyndicationTargets($request))) {
|
if (in_array('twitter', $this->getSyndicationTargets($request))) {
|
||||||
dispatch(new SyndicateNoteToTwitter($note));
|
dispatch(new SyndicateNoteToTwitter($note));
|
||||||
}
|
}
|
||||||
if (in_array('facebook', $this->getSyndicationTargets($request))) {
|
|
||||||
dispatch(new SyndicateNoteToFacebook($note));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $note;
|
return $note;
|
||||||
|
@ -211,9 +208,6 @@ class NoteService
|
||||||
if ($service == 'Twitter') {
|
if ($service == 'Twitter') {
|
||||||
$syndication[] = 'twitter';
|
$syndication[] = 'twitter';
|
||||||
}
|
}
|
||||||
if ($service == 'Facebook') {
|
|
||||||
$syndication[] = 'facebook';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (is_array($mpSyndicateTo)) {
|
if (is_array($mpSyndicateTo)) {
|
||||||
foreach ($mpSyndicateTo as $uid) {
|
foreach ($mpSyndicateTo as $uid) {
|
||||||
|
@ -221,9 +215,6 @@ class NoteService
|
||||||
if ($service == 'Twitter') {
|
if ($service == 'Twitter') {
|
||||||
$syndication[] = 'twitter';
|
$syndication[] = 'twitter';
|
||||||
}
|
}
|
||||||
if ($service == 'Facebook') {
|
|
||||||
$syndication[] = 'facebook';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Version 0.17.1 (2018-10-12)
|
||||||
|
- Remove settinga and code for syndicatong to Facebook (issue#88)
|
||||||
|
|
||||||
## Version 0.17
|
## Version 0.17
|
||||||
- Update the underlying Laravel framework to release 5.7
|
- Update the underlying Laravel framework to release 5.7
|
||||||
|
|
||||||
|
|
|
@ -19,21 +19,8 @@ return [
|
||||||
'user' => [
|
'user' => [
|
||||||
'name' => 'jonnybarnes',
|
'name' => 'jonnybarnes',
|
||||||
'url' => 'https://twitter.com/jonnybarnes',
|
'url' => 'https://twitter.com/jonnybarnes',
|
||||||
'photo' => 'https://pbs.twimg.com/profile_images/1853565405/jmb-bw.jpg',
|
'photo' => 'https://pbs.twimg.com/profile_images/875422855932121089/W628ZI8w_400x400.jpg',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'uid' => 'https://facebook.com/jonnybarnes',
|
|
||||||
'name' => 'jonnybarnes on Facebook',
|
|
||||||
'service' => [
|
|
||||||
'name' => 'Facebook',
|
|
||||||
'url' => 'https://facebook.com',
|
|
||||||
'photo' => 'https://en.facebookbrand.com/wp-content/uploads/2016/05/FB-fLogo-Blue-broadcast-2.png',
|
|
||||||
],
|
|
||||||
'user' => [
|
|
||||||
'name' => 'jonnybarnes',
|
|
||||||
'url' => 'https://facebook.com/jonnybarnes',
|
|
||||||
],
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
@ -7,7 +7,6 @@ use Tests\TestToken;
|
||||||
use App\Jobs\ProcessBookmark;
|
use App\Jobs\ProcessBookmark;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
use App\Jobs\SyndicateBookmarkToTwitter;
|
use App\Jobs\SyndicateBookmarkToTwitter;
|
||||||
use App\Jobs\SyndicateBookmarkToFacebook;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
class BookmarksTest extends TestCase
|
class BookmarksTest extends TestCase
|
||||||
|
@ -37,7 +36,6 @@ class BookmarksTest extends TestCase
|
||||||
'bookmark-of' => 'https://example.org/blog-post',
|
'bookmark-of' => 'https://example.org/blog-post',
|
||||||
'mp-syndicate-to' => [
|
'mp-syndicate-to' => [
|
||||||
'https://twitter.com/jonnybarnes',
|
'https://twitter.com/jonnybarnes',
|
||||||
'https://facebook.com/jonnybarnes',
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -45,7 +43,6 @@ class BookmarksTest extends TestCase
|
||||||
|
|
||||||
Queue::assertPushed(ProcessBookmark::class);
|
Queue::assertPushed(ProcessBookmark::class);
|
||||||
Queue::assertPushed(SyndicateBookmarkToTwitter::class);
|
Queue::assertPushed(SyndicateBookmarkToTwitter::class);
|
||||||
Queue::assertPushed(SyndicateBookmarkToFacebook::class);
|
|
||||||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +58,6 @@ class BookmarksTest extends TestCase
|
||||||
'bookmark-of' => ['https://example.org/blog-post'],
|
'bookmark-of' => ['https://example.org/blog-post'],
|
||||||
'mp-syndicate-to' => [
|
'mp-syndicate-to' => [
|
||||||
'https://twitter.com/jonnybarnes',
|
'https://twitter.com/jonnybarnes',
|
||||||
'https://facebook.com/jonnybarnes',
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
@ -70,7 +66,6 @@ class BookmarksTest extends TestCase
|
||||||
|
|
||||||
Queue::assertPushed(ProcessBookmark::class);
|
Queue::assertPushed(ProcessBookmark::class);
|
||||||
Queue::assertPushed(SyndicateBookmarkToTwitter::class);
|
Queue::assertPushed(SyndicateBookmarkToTwitter::class);
|
||||||
Queue::assertPushed(SyndicateBookmarkToFacebook::class);
|
|
||||||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,25 +88,6 @@ class BookmarksTest extends TestCase
|
||||||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_single_facebook_syndication_target_causes_job_dispatch_http_post_syntax()
|
|
||||||
{
|
|
||||||
Queue::fake();
|
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
|
||||||
'Authorization' => 'Bearer ' . $this->getToken(),
|
|
||||||
])->post('/api/post', [
|
|
||||||
'h' => 'entry',
|
|
||||||
'bookmark-of' => 'https://example.org/blog-post',
|
|
||||||
'mp-syndicate-to' => 'https://facebook.com/jonnybarnes',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response->assertJson(['response' => 'created']);
|
|
||||||
|
|
||||||
Queue::assertPushed(ProcessBookmark::class);
|
|
||||||
Queue::assertPushed(SyndicateBookmarkToFacebook::class);
|
|
||||||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_tags_created_with_new_bookmark()
|
public function test_tags_created_with_new_bookmark()
|
||||||
{
|
{
|
||||||
Queue::fake();
|
Queue::fake();
|
||||||
|
|
|
@ -13,12 +13,4 @@ class BridgyPosseTest extends TestCase
|
||||||
$html = $response->content();
|
$html = $response->content();
|
||||||
$this->assertTrue(is_string(mb_stristr($html, 'p-bridgy-twitter-content')));
|
$this->assertTrue(is_string(mb_stristr($html, 'p-bridgy-twitter-content')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_bridgy_facebook_content()
|
|
||||||
{
|
|
||||||
$response = $this->get('/notes/E');
|
|
||||||
|
|
||||||
$html = $response->content();
|
|
||||||
$this->assertTrue(is_string(mb_stristr($html, 'p-bridgy-facebook-content')));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ use App\Models\{Media, Place};
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use App\Jobs\SyndicateNoteToTwitter;
|
use App\Jobs\SyndicateNoteToTwitter;
|
||||||
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
||||||
use App\Jobs\SyndicateNoteToFacebook;
|
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Phaza\LaravelPostgis\Geometries\Point;
|
use Phaza\LaravelPostgis\Geometries\Point;
|
||||||
|
@ -169,33 +168,6 @@ class MicropubControllerTest extends TestCase
|
||||||
Queue::assertPushed(SyndicateNoteToTwitter::class);
|
Queue::assertPushed(SyndicateNoteToTwitter::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test a valid micropub requests creates a new note and syndicates to Facebook.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function test_micropub_post_request_creates_new_note_sends_to_facebook()
|
|
||||||
{
|
|
||||||
Queue::fake();
|
|
||||||
$faker = \Faker\Factory::create();
|
|
||||||
$note = $faker->text;
|
|
||||||
$response = $this->call(
|
|
||||||
'POST',
|
|
||||||
'/api/post',
|
|
||||||
[
|
|
||||||
'h' => 'entry',
|
|
||||||
'content' => $note,
|
|
||||||
'mp-syndicate-to' => 'https://facebook.com/jonnybarnes'
|
|
||||||
],
|
|
||||||
[],
|
|
||||||
[],
|
|
||||||
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
|
|
||||||
);
|
|
||||||
$response->assertJson(['response' => 'created']);
|
|
||||||
$this->assertDatabaseHas('notes', ['note' => $note]);
|
|
||||||
Queue::assertPushed(SyndicateNoteToFacebook::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a valid micropub requests creates a new place.
|
* Test a valid micropub requests creates a new place.
|
||||||
*
|
*
|
||||||
|
@ -320,7 +292,6 @@ class MicropubControllerTest extends TestCase
|
||||||
'in-reply-to' => ['https://aaronpk.localhost'],
|
'in-reply-to' => ['https://aaronpk.localhost'],
|
||||||
'mp-syndicate-to' => [
|
'mp-syndicate-to' => [
|
||||||
'https://twitter.com/jonnybarnes',
|
'https://twitter.com/jonnybarnes',
|
||||||
'https://facebook.com/jonnybarnes',
|
|
||||||
],
|
],
|
||||||
'photo' => [config('filesystems.disks.s3.url') . '/test-photo.jpg'],
|
'photo' => [config('filesystems.disks.s3.url') . '/test-photo.jpg'],
|
||||||
],
|
],
|
||||||
|
@ -332,7 +303,6 @@ class MicropubControllerTest extends TestCase
|
||||||
->assertJson(['response' => 'created']);
|
->assertJson(['response' => 'created']);
|
||||||
Queue::assertPushed(SendWebMentions::class);
|
Queue::assertPushed(SendWebMentions::class);
|
||||||
Queue::assertPushed(SyndicateNoteToTwitter::class);
|
Queue::assertPushed(SyndicateNoteToTwitter::class);
|
||||||
Queue::assertPushed(SyndicateNoteToFacebook::class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Unit\Jobs;
|
|
||||||
|
|
||||||
use Tests\TestCase;
|
|
||||||
use GuzzleHttp\Client;
|
|
||||||
use App\Models\Bookmark;
|
|
||||||
use GuzzleHttp\HandlerStack;
|
|
||||||
use GuzzleHttp\Psr7\Response;
|
|
||||||
use GuzzleHttp\Handler\MockHandler;
|
|
||||||
use App\Jobs\SyndicateBookmarkToFacebook;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
||||||
|
|
||||||
class SyndicateBookmarkToFacebookJobTest extends TestCase
|
|
||||||
{
|
|
||||||
use DatabaseTransactions;
|
|
||||||
|
|
||||||
public function test_the_job()
|
|
||||||
{
|
|
||||||
$json = json_encode([
|
|
||||||
'url' => 'https://facebook.com/123'
|
|
||||||
]);
|
|
||||||
$mock = new MockHandler([
|
|
||||||
new Response(201, ['Content-Type' => 'application/json'], $json),
|
|
||||||
]);
|
|
||||||
$handler = HandlerStack::create($mock);
|
|
||||||
$client = new Client(['handler' => $handler]);
|
|
||||||
|
|
||||||
$bookmark = Bookmark::find(1);
|
|
||||||
$job = new SyndicateBookmarkToFacebook($bookmark);
|
|
||||||
$job->handle($client);
|
|
||||||
|
|
||||||
$this->assertDatabaseHas('bookmarks', [
|
|
||||||
'id' => 1,
|
|
||||||
'syndicates' => '{"facebook": "https://facebook.com/123"}',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Unit\Jobs;
|
|
||||||
|
|
||||||
use Tests\TestCase;
|
|
||||||
use App\Models\Note;
|
|
||||||
use GuzzleHttp\Client;
|
|
||||||
use GuzzleHttp\HandlerStack;
|
|
||||||
use GuzzleHttp\Psr7\Response;
|
|
||||||
use GuzzleHttp\Handler\MockHandler;
|
|
||||||
use App\Jobs\SyndicateNoteToFacebook;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
||||||
|
|
||||||
class SyndicateNoteToFacebookJobTest extends TestCase
|
|
||||||
{
|
|
||||||
use DatabaseTransactions;
|
|
||||||
|
|
||||||
public function test_the_job()
|
|
||||||
{
|
|
||||||
$json = json_encode([
|
|
||||||
'url' => 'https://facebook.com/123'
|
|
||||||
]);
|
|
||||||
$mock = new MockHandler([
|
|
||||||
new Response(201, ['Content-Type' => 'application/json'], $json),
|
|
||||||
]);
|
|
||||||
$handler = HandlerStack::create($mock);
|
|
||||||
$client = new Client(['handler' => $handler]);
|
|
||||||
|
|
||||||
$note = Note::find(1);
|
|
||||||
$job = new SyndicateNoteToFacebook($note);
|
|
||||||
$job->handle($client);
|
|
||||||
|
|
||||||
$this->assertDatabaseHas('notes', [
|
|
||||||
'id' => 1,
|
|
||||||
'facebook_url' => 'https://facebook.com/123',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue