diff --git a/resources/views/frontend/homepage.blade.php b/resources/views/frontend/homepage.blade.php index 31590b574..8dfc56056 100644 --- a/resources/views/frontend/homepage.blade.php +++ b/resources/views/frontend/homepage.blade.php @@ -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') }}" diff --git a/routes/web.php b/routes/web.php index 5e091eb51..c8fd0358e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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'); diff --git a/tests/Feature/FrontPage/ShortenUrl/CreateShortLinkTest.php b/tests/Feature/FrontPage/ShortenUrl/CreateShortLinkTest.php index e82274e2f..39aeb060c 100644 --- a/tests/Feature/FrontPage/ShortenUrl/CreateShortLinkTest.php +++ b/tests/Feature/FrontPage/ShortenUrl/CreateShortLinkTest.php @@ -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, ]); @@ -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, ]); @@ -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, ]); @@ -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, ]); @@ -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, ]); diff --git a/tests/Feature/FrontPage/ShortenUrl/ValidationTest.php b/tests/Feature/FrontPage/ShortenUrl/ValidationTest.php index a1c5c2f20..be9dd1d34 100644 --- a/tests/Feature/FrontPage/ShortenUrl/ValidationTest.php +++ b/tests/Feature/FrontPage/ShortenUrl/ValidationTest.php @@ -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', ]); @@ -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, ]); @@ -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, ]); diff --git a/tests/Unit/Controllers/UrlControllerTest.php b/tests/Unit/Controllers/UrlControllerTest.php index aff7ce09a..1e3a4587e 100644 --- a/tests/Unit/Controllers/UrlControllerTest.php +++ b/tests/Unit/Controllers/UrlControllerTest.php @@ -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); @@ -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); diff --git a/tests/Unit/Middleware/UrlHubLinkCheckerTest.php b/tests/Unit/Middleware/UrlHubLinkCheckerTest.php index 1c15fb9a9..a119e45a9 100644 --- a/tests/Unit/Middleware/UrlHubLinkCheckerTest.php +++ b/tests/Unit/Middleware/UrlHubLinkCheckerTest.php @@ -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') diff --git a/tests/Unit/Models/UrlTest.php b/tests/Unit/Models/UrlTest.php index c9625ed64..df73f9e6f 100644 --- a/tests/Unit/Models/UrlTest.php +++ b/tests/Unit/Models/UrlTest.php @@ -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(); diff --git a/tests/Unit/Models/UserTest.php b/tests/Unit/Models/UserTest.php index 0ecb61d1c..89f91f2d8 100644 --- a/tests/Unit/Models/UserTest.php +++ b/tests/Unit/Models/UserTest.php @@ -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()); } } diff --git a/tests/Unit/Services/KeyGeneratorServiceTest.php b/tests/Unit/Services/KeyGeneratorServiceTest.php index 01806905c..a7fb82027 100644 --- a/tests/Unit/Services/KeyGeneratorServiceTest.php +++ b/tests/Unit/Services/KeyGeneratorServiceTest.php @@ -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, ]);