get('/likes'); $response->assertViewIs('likes.index'); } public function test_single_like_page() { $response = $this->get('/likes'); $response->assertViewIs('likes.index'); } public function test_like_micropub_request() { Queue::fake(); $response = $this->withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), ])->json('POST', '/api/post', [ 'type' => ['h-entry'], 'properties' => [ 'like-of' => ['https://example.org/blog-post'], ], ]); $response->assertJson(['response' => 'created']); Queue::assertPushed(ProcessLike::class); $this->assertDatabaseHas('likes', ['url' => 'https://example.org/blog-post']); } public function test_process_like_job() { $like = new Like(); $like->url = 'http://example.org/note/id'; $like->save(); $id = $like->id; $job = new ProcessLike($like); $content = <<
A post that I like.
by Fred Bloggs
END; $mock = new MockHandler([ new Response(200, [], $content), new Response(200, [], $content), ]); $handler = HandlerStack::create($mock); $client = new Client(['handler' => $handler]); $this->app->bind(Client::class, $client); $authorship = new Authorship(); $job->handle($client, $authorship); $this->assertEquals('Fred Bloggs', Like::find($id)->author_name); } }