Finish re-working tests to run on test database
This commit is contained in:
parent
09fc211623
commit
1abca77bdc
50 changed files with 535 additions and 265 deletions
|
@ -10,18 +10,20 @@ use GuzzleHttp\Client;
|
|||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SyndicateBookmarkToTwitterJobTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
public function weSendBookmarksToTwitter(): void
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$randomNumber = $faker->randomNumber();
|
||||
$json = json_encode([
|
||||
'url' => 'https://twitter.com/123'
|
||||
'url' => 'https://twitter.com/' . $randomNumber
|
||||
]);
|
||||
$mock = new MockHandler([
|
||||
new Response(201, ['Content-Type' => 'application/json'], $json),
|
||||
|
@ -29,13 +31,12 @@ class SyndicateBookmarkToTwitterJobTest extends TestCase
|
|||
$handler = HandlerStack::create($mock);
|
||||
$client = new Client(['handler' => $handler]);
|
||||
|
||||
$bookmark = Bookmark::find(1);
|
||||
$bookmark = Bookmark::factory()->create();
|
||||
$job = new SyndicateBookmarkToTwitter($bookmark);
|
||||
$job->handle($client);
|
||||
|
||||
$this->assertDatabaseHas('bookmarks', [
|
||||
'id' => 1,
|
||||
'syndicates' => '{"twitter": "https://twitter.com/123"}',
|
||||
'syndicates' => '{"twitter": "https://twitter.com/' . $randomNumber . '"}',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue