Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

realodix/urlhub

532 stars
1 code files
View realodix/urlhub on GitHub

tests/Feature/API/UrlTest.php

Open in GitHub
use 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'],
];
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.