Skip to content

Commit

Permalink
link_create to link.create
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Dec 23, 2024
1 parent 87a1a06 commit de680c4
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion resources/views/frontend/homepage.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<div class="flex flex-wrap justify-center mt-12 px-4 lg:px-0">
<div class="w-full max-w-4xl">
<form method="post" action="{{ route('link_create') }}" class="mb-4 mt-12" id="formUrl">
<form method="post" action="{{ route('link.create') }}" class="mb-4 mt-12" id="formUrl">
@csrf
<div class="mt-1 text-center">
<input name="long_url" value="{{ old('long_url') }}" placeholder="{{ __('Shorten your link') }}"
Expand Down
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Support\Facades\Route;

Route::view('/', 'frontend.homepage')->name('home');
Route::post('/shorten', [UrlController::class, 'create'])->name('link_create');
Route::post('/shorten', [UrlController::class, 'create'])->name('link.create');
Route::get('/+{url:keyword}', [UrlController::class, 'showDetail'])->name('link_detail');
Route::get('/delete/{url:keyword}', [UrlController::class, 'delete'])->name('link_detail.delete');

Expand Down
10 changes: 5 additions & 5 deletions tests/Feature/FrontPage/ShortenUrl/CreateShortLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CreateShortLinkTest extends TestCase
public function testShortenUrl(): void
{
$longUrl = 'https://laravel.com';
$response = $this->post(route('link_create'), [
$response = $this->post(route('link.create'), [
'long_url' => $longUrl,
]);

Expand All @@ -36,7 +36,7 @@ public function testShortenUrlWithCustomKeyword(): void

$customKey = 'foobar';
config(['urlhub.keyword_length' => strlen($customKey) + 1]);
$response = $this->post(route('link_create'), [
$response = $this->post(route('link.create'), [
'long_url' => $longUrl,
'custom_key' => $customKey,
]);
Expand All @@ -46,7 +46,7 @@ public function testShortenUrlWithCustomKeyword(): void

$customKey = 'barfoo';
config(['urlhub.keyword_length' => strlen($customKey) - 1]);
$response = $this->post(route('link_create'), [
$response = $this->post(route('link.create'), [
'long_url' => $longUrl,
'custom_key' => $customKey,
]);
Expand All @@ -68,7 +68,7 @@ public function testCustomKeyAlreadyExist(): void
{
$url = Url::factory()->create();

$response = $this->post(route('link_create'), [
$response = $this->post(route('link.create'), [
'long_url' => 'https://laravel-news.com',
'custom_key' => $url->keyword,
]);
Expand All @@ -89,7 +89,7 @@ public function testCustomKeyAlreadyExist2(): void
$url = Url::factory()->create();

$response = $this->actingAs($this->basicUser())
->post(route('link_create'), [
->post(route('link.create'), [
'long_url' => 'https://laravel-news.com',
'custom_key' => $url->keyword,
]);
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/FrontPage/ShortenUrl/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ValidationTest extends TestCase
{
public function testShortUrlGenerationWithIncorrectUrlFormat(): void
{
$response = $this->post(route('link_create'), [
$response = $this->post(route('link.create'), [
'long_url' => 'wrong-url-format',
]);

Expand All @@ -36,7 +36,7 @@ public static function customKeyPassProvider(): array
#[PHPUnit\DataProvider('customKeyPassProvider')]
public function testCustomKeyValidationShouldPass($value): void
{
$response = $this->post(route('link_create'), [
$response = $this->post(route('link.create'), [
'long_url' => 'https://laravel.com/',
'custom_key' => $value,
]);
Expand Down Expand Up @@ -74,7 +74,7 @@ public static function customKeyFailProvider(): array
#[PHPUnit\DataProvider('customKeyFailProvider')]
public function testCustomKeyValidationShouldFail($value): void
{
$response = $this->post(route('link_create'), [
$response = $this->post(route('link.create'), [
'long_url' => 'https://laravel.com/',
'custom_key' => $value,
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Controllers/UrlControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function guestShortenURL(): void
{
$longUrl = 'https://laravel.com';

$this->post(route('link_create'), ['long_url' => $longUrl]);
$this->post(route('link.create'), ['long_url' => $longUrl]);

$url = Url::whereDestination($longUrl)->first();
$this->assertSame(null, $url->user_id);
Expand All @@ -35,7 +35,7 @@ public function userShortenURL(): void
$longUrl = 'https://laravel.com';

$this->actingAs($user)
->post(route('link_create'), ['long_url' => $longUrl]);
->post(route('link.create'), ['long_url' => $longUrl]);

$url = Url::whereDestination($longUrl)->first();
$this->assertSame($user->id, $url->user_id);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Middleware/UrlHubLinkCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function remainingCapacityIsZero(): void
{
config(['urlhub.keyword_length' => 0]);

$response = $this->post(route('link_create'), ['long_url' => 'https://laravel.com']);
$response = $this->post(route('link.create'), ['long_url' => 'https://laravel.com']);

$response
->assertRedirectToRoute('home')
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Models/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function defaultGuestId(): void
{
$longUrl = 'https://example.com';

$this->post(route('link_create'), ['long_url' => $longUrl]);
$this->post(route('link.create'), ['long_url' => $longUrl]);

$url = Url::whereDestination($longUrl)->first();

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Models/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testSignature(): void

$user = $this->basicUser();
$this->actingAs($user)
->post(route('link_create'), ['long_url' => 'https://laravel.com']);
->post(route('link.create'), ['long_url' => 'https://laravel.com']);
$this->assertEquals($user->id, $user->signature());
}
}
2 changes: 1 addition & 1 deletion tests/Unit/Services/KeyGeneratorServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function urlKey_string_lenght2(): void
config(['urlhub.keyword_length' => 10]);
$longUrl = 'https://t.co';
$customKey = 'tco';
$response = $this->post(route('link_create'), [
$response = $this->post(route('link.create'), [
'long_url' => $longUrl,
'custom_key' => $customKey,
]);
Expand Down

0 comments on commit de680c4

Please sign in to comment.