-
tests/Feature/API/UrlTest.php
Open in GitHubuse Illuminate\Http\Response; use Tests\TestCase; class UrlTest extends TestCase { public function canCreateUrl() { $data = [ 'long_url' => 'http://example.com', ]; $this->json('POST', '/api/url', $data) ->assertStatus(Response::HTTP_CREATED) ->assertJsonStructure([ 'id', 'long_url', 'short_url', ]); $this->assertDatabaseHas('urls', $data); } public function shortenUrlFail($value) { $data = [ 'long_url' => $value, ]; $this->json('POST', '/api/url', $data) ->assertJsonStructure([ 'errors', ]); } public function shortenUrlFailProvider() { return [ [''], ['foobar.com'], ]; } }