Move some tests into their own subfodlers

This commit is contained in:
Jonny Barnes 2017-12-18 17:53:22 +00:00
parent 0dd6adfa0e
commit e1aa814d8c
18 changed files with 29 additions and 31 deletions

View file

@ -0,0 +1,38 @@
<?php
namespace Tests\Unit\Jobs;
use App\Note;
use Tests\TestCase;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Handler\MockHandler;
use App\Jobs\SyndicateNoteToTwitter;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class SyndicateNoteToTwitterJobTest extends TestCase
{
use DatabaseTransactions;
public function test_the_job()
{
$json = json_encode([
'url' => 'https://twitter.com/i/web/status/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 SyndicateNoteToTwitter($note);
$job->handle($client);
$this->assertDatabaseHas('notes', [
'id' => 1,
'tweet_id' => '123',
]);
}
}