Browse Source

Change URL from singular to singular

baijunyao 3 years ago
parent
commit
819131ba61

+ 2 - 2
app/Http/Controllers/RedirectController.php

@@ -28,12 +28,12 @@ class RedirectController extends Controller
 
     public function note(): RedirectResponse
     {
-        return redirect()->route('home.note.index');
+        return redirect()->route('home.notes.index');
     }
 
     public function openSource(): RedirectResponse
     {
-        return redirect()->route('home.openSource.index');
+        return redirect()->route('home.openSources.index');
     }
 
     public function login(): RedirectResponse

+ 24 - 24
routes/breadcrumbs.php

@@ -7,46 +7,46 @@ use App\Models\Category;
 use App\Models\Tag;
 use DaveJamesMiller\Breadcrumbs\BreadcrumbsGenerator;
 
-Breadcrumbs::for('home.article.index', function (BreadcrumbsGenerator $trail) {
+Breadcrumbs::for('home.articles.index', function (BreadcrumbsGenerator $trail) {
     $trail->push('Home', url('/'));
 });
 
-Breadcrumbs::for('home.category.show', function (BreadcrumbsGenerator $trail, Category $category) {
-    $trail->parent('home.article.index');
-    $trail->push($category->name, route('home.category.show', $category->id));
+Breadcrumbs::for('home.categories.show', function (BreadcrumbsGenerator $trail, Category $category) {
+    $trail->parent('home.articles.index');
+    $trail->push($category->name, route('home.categories.show', $category->id));
 });
 
-Breadcrumbs::for('home.tag.show', function (BreadcrumbsGenerator $trail, Tag $tag) {
-    $trail->parent('home.article.index');
-    $trail->push($tag->name, route('home.tag.show', $tag->id));
+Breadcrumbs::for('home.tags.show', function (BreadcrumbsGenerator $trail, Tag $tag) {
+    $trail->parent('home.articles.index');
+    $trail->push($tag->name, route('home.tags.show', $tag->id));
 });
 
-Breadcrumbs::for('home.note.index', function (BreadcrumbsGenerator $trail) {
-    $trail->parent('home.article.index');
-    $trail->push(translate('Note'), route('home.note.index'));
+Breadcrumbs::for('home.notes.index', function (BreadcrumbsGenerator $trail) {
+    $trail->parent('home.articles.index');
+    $trail->push(translate('Note'), route('home.notes.index'));
 });
 
 Breadcrumbs::for('home.chat.index', function (BreadcrumbsGenerator $trail) {
-    $trail->parent('home.article.index');
-    $trail->push(translate('Note'), route('home.note.index'));
+    $trail->parent('home.articles.index');
+    $trail->push(translate('Note'), route('home.notes.index'));
 });
 
-Breadcrumbs::for('home.openSource.index', function (BreadcrumbsGenerator $trail) {
-    $trail->parent('home.article.index');
-    $trail->push(translate('Open Source'), route('home.openSource.index'));
+Breadcrumbs::for('home.openSources.index', function (BreadcrumbsGenerator $trail) {
+    $trail->parent('home.articles.index');
+    $trail->push(translate('Open Source'), route('home.openSources.index'));
 });
 
-Breadcrumbs::for('home.site.index', function (BreadcrumbsGenerator $trail) {
-    $trail->parent('home.article.index');
-    $trail->push(translate('Site'), route('home.site.index'));
+Breadcrumbs::for('home.sites.index', function (BreadcrumbsGenerator $trail) {
+    $trail->parent('home.articles.index');
+    $trail->push(translate('Site'), route('home.sites.index'));
 });
 
-Breadcrumbs::for('home.article.show', function (BreadcrumbsGenerator $trail, Article $article) {
-    $trail->parent('home.category.show', $article->category);
-    $trail->push($article->title, route('home.tag.show', $article->id));
+Breadcrumbs::for('home.articles.show', function (BreadcrumbsGenerator $trail, Article $article) {
+    $trail->parent('home.categories.show', $article->category);
+    $trail->push($article->title, route('home.tags.show', $article->id));
 });
 
-Breadcrumbs::for('home.article.search', function (BreadcrumbsGenerator $trail) {
-    $trail->parent('home.article.index');
-    $trail->push(translate('Search'), route('home.article.search'));
+Breadcrumbs::for('home.articles.search', function (BreadcrumbsGenerator $trail) {
+    $trail->parent('home.articles.index');
+    $trail->push(translate('Search'), route('home.articles.search'));
 });

+ 11 - 11
routes/web.php

@@ -4,24 +4,24 @@ declare(strict_types=1);
 
 // Home 模块
 Route::name('home.')->group(function () {
-    Route::name('article.')->group(function () {
+    Route::name('articles.')->group(function () {
         Route::get('/', \App\Http\Controllers\Home\ArticleController::class . '@index')->name('index');
-        Route::get('article/{article}/{slug?}', \App\Http\Controllers\Home\ArticleController::class . '@show')->name('show');
+        Route::get('articles/{article}/{slug?}', \App\Http\Controllers\Home\ArticleController::class . '@show')->name('show');
         Route::get('search', \App\Http\Controllers\Home\ArticleController::class . '@search')->name('search');
     });
-    Route::get('category/{category}/{slug?}', \App\Http\Controllers\Home\CategoryController::class . '@show')->name('category.show');
-    Route::get('tag/{tag}/{slug?}', \App\Http\Controllers\Home\TagController::class . '@show')->name('tag.show');
-    Route::get('note', \App\Http\Controllers\Home\NoteController::class . '@index')->name('note.index');
-    Route::get('openSource', \App\Http\Controllers\Home\OpenSourceController::class . '@index')->name('openSource.index');
-    Route::get('feed', \App\Http\Controllers\Home\FeedController::class . '@index')->name('feed.index');
-    Route::prefix('site')->name('site.')->group(function () {
+    Route::get('categories/{category}/{slug?}', \App\Http\Controllers\Home\CategoryController::class . '@show')->name('categories.show');
+    Route::get('tags/{tag}/{slug?}', \App\Http\Controllers\Home\TagController::class . '@show')->name('tags.show');
+    Route::get('notes', \App\Http\Controllers\Home\NoteController::class . '@index')->name('notes.index');
+    Route::get('openSources', \App\Http\Controllers\Home\OpenSourceController::class . '@index')->name('openSources.index');
+    Route::get('feeds', \App\Http\Controllers\Home\FeedController::class . '@index')->name('feeds.index');
+    Route::prefix('sites')->name('sites.')->group(function () {
         Route::get('/', \App\Http\Controllers\Home\SiteController::class . '@index')->name('index');
         Route::post('store', \App\Http\Controllers\Home\SiteController::class . '@store')->name('store')->middleware('auth:socialite', 'clean.xss');
     });
     Route::middleware('auth:socialite')->group(function () {
-        Route::get('socialiteUser/{socialiteUser}', \App\Http\Controllers\Home\SocialiteUserController::class . '@show')->name('socialiteUser.show');
-        Route::post('comment', \App\Http\Controllers\Home\CommentController::class . '@store')->name('comment.store');
-        Route::prefix('like')->name('like.')->group(function () {
+        Route::get('socialiteUsers/{socialiteUser}', \App\Http\Controllers\Home\SocialiteUserController::class . '@show')->name('socialiteUsers.show');
+        Route::post('comments', \App\Http\Controllers\Home\CommentController::class . '@store')->name('comments.store');
+        Route::prefix('likes')->name('likes.')->group(function () {
             Route::post('store', \App\Http\Controllers\Home\LikeController::class . '@store')->name('store');
             Route::delete('destroy', \App\Http\Controllers\Home\LikeController::class . '@destroy')->name('destroy');
         });

+ 2 - 2
tests/Feature/Home/ArticleControllerTest.php

@@ -13,12 +13,12 @@ class ArticleControllerTest extends TestCase
 
     public function testShow()
     {
-        $this->get('/article/1')->assertStatus(200);
+        $this->get('/articles/1')->assertStatus(200);
     }
 
     public function testShowNotFound()
     {
-        $this->get('/article/100')->assertNotFound();
+        $this->get('/articles/100')->assertNotFound();
     }
 
     public function testSearch()

+ 2 - 2
tests/Feature/Home/CategoryControllerTest.php

@@ -8,11 +8,11 @@ class CategoryControllerTest extends TestCase
 {
     public function testShow()
     {
-        $this->get('/category/1')->assertStatus(200);
+        $this->get('/categories/1')->assertStatus(200);
     }
 
     public function testShowNotFound()
     {
-        $this->get('/category/100')->assertNotFound();
+        $this->get('/categories/100')->assertNotFound();
     }
 }

+ 11 - 11
tests/Feature/Home/CommentControllerTest.php

@@ -28,7 +28,7 @@ class CommentControllerTest extends TestCase
         ];
 
         $this->loginByUserId(1)
-            ->post('/comment', $comment + [
+            ->post('/comments', $comment + [
                 'content' => $content,
                 'email'   => $email,
             ])
@@ -47,7 +47,7 @@ class CommentControllerTest extends TestCase
         });
 
         $this->loginByUserId(1)
-            ->post('/comment', $comment + [
+            ->post('/comments', $comment + [
                 'content' => $content,
                 'email'   => $email,
             ])
@@ -79,7 +79,7 @@ class CommentControllerTest extends TestCase
         ];
 
         $this->loginByUserId($socialiteUser1->id)
-            ->post('/comment', $comment + [
+            ->post('/comments', $comment + [
                 'content' => $content,
                 'email'   => $email,
             ])
@@ -110,7 +110,7 @@ class CommentControllerTest extends TestCase
         ]);
 
         $this->loginByUserId(1)
-            ->post('/comment', $comment + [
+            ->post('/comments', $comment + [
                 'content' => $content,
             ])
             ->assertStatus(200);
@@ -134,7 +134,7 @@ class CommentControllerTest extends TestCase
             'content'    => 'no audited comment',
         ];
         $this->loginByUserId(1)
-            ->post('/comment', $comment)
+            ->post('/comments', $comment)
             ->assertStatus(200);
 
         static::assertDatabaseHas('comments', [
@@ -156,7 +156,7 @@ class CommentControllerTest extends TestCase
         ];
 
         $this->loginByUserId(1)
-            ->post('/comment', $comment)
+            ->post('/comments', $comment)
             ->assertStatus(302);
     }
 
@@ -168,7 +168,7 @@ class CommentControllerTest extends TestCase
             'content'    => '',
         ];
         $this->loginByUserId(1)
-            ->post('/comment', $comment)
+            ->post('/comments', $comment)
             ->assertStatus(302);
     }
 
@@ -180,7 +180,7 @@ class CommentControllerTest extends TestCase
             'content'    => 'test',
         ];
         $this->loginByUserId(1)
-            ->post('/comment', $comment)
+            ->post('/comments', $comment)
             ->assertStatus(302);
     }
 
@@ -191,7 +191,7 @@ class CommentControllerTest extends TestCase
             'parent_id'  => 0,
             'content'    => '评论666',
         ];
-        $this->post('/comment', $comment)
+        $this->post('/comments', $comment)
             ->assertStatus(302)
             ->assertRedirect(route('login'));
     }
@@ -206,7 +206,7 @@ class CommentControllerTest extends TestCase
             ];
 
             $this->loginByUserId(1)
-                ->post('/comment', $comment)
+                ->post('/comments', $comment)
                 ->assertOk();
 
             DB::table('comments')->update([
@@ -221,7 +221,7 @@ class CommentControllerTest extends TestCase
         ];
 
         $this->loginByUserId(1)
-            ->post('/comment', $comment)
+            ->post('/comments', $comment)
             ->assertStatus(302);
     }
 }

+ 1 - 1
tests/Feature/Home/FeedControllerTest.php

@@ -8,6 +8,6 @@ class FeedControllerTest extends TestCase
 {
     public function testFeed()
     {
-        $this->get('/feed')->assertStatus(200);
+        $this->get('/feeds')->assertStatus(200);
     }
 }

+ 1 - 1
tests/Feature/Home/LikeControllerTest.php

@@ -8,7 +8,7 @@ use App\Models\Article;
 
 class LikeControllerTest extends TestCase
 {
-    protected $urlPrefix = 'like/';
+    protected $urlPrefix = 'likes/';
     protected $storeData = [
         'article_id' => 1,
     ];

+ 1 - 1
tests/Feature/Home/NoteControllerTest.php

@@ -8,6 +8,6 @@ class NoteControllerTest extends TestCase
 {
     public function testIndex()
     {
-        $this->get('/note')->assertStatus(200);
+        $this->get('/notes')->assertStatus(200);
     }
 }

+ 1 - 1
tests/Feature/Home/OpenSourceControllerTest.php

@@ -8,6 +8,6 @@ class OpenSourceControllerTest extends TestCase
 {
     public function testIndex()
     {
-        $this->get('/openSource')->assertStatus(200);
+        $this->get('/openSources')->assertStatus(200);
     }
 }

+ 1 - 1
tests/Feature/Home/SiteControllerTest.php

@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Notification;
 
 class SiteControllerTest extends TestCase
 {
-    protected $urlPrefix = 'site/';
+    protected $urlPrefix = 'sites/';
     protected $table     = 'sites';
     protected $storeData = [
         'name'        => '新增',

+ 2 - 2
tests/Feature/Home/SocialiteUserControllerTest.php

@@ -12,14 +12,14 @@ class SocialiteUserControllerTest extends TestCase
     {
         auth()->guard('socialite')->loginUsingId(1);
 
-        $this->get('/socialiteUser/me')
+        $this->get('/socialiteUsers/me')
             ->assertStatus(200)
             ->assertJson(SocialiteUser::find(1)->only('id', 'name', 'avatar', 'email'));
     }
 
     public function testCheckLoginWhenLogout()
     {
-        $this->get('/socialiteUser/me')
+        $this->get('/socialiteUsers/me')
             ->assertStatus(302)
             ->assertRedirect(route('login'));
     }

+ 2 - 2
tests/Feature/Home/TagControllerTest.php

@@ -8,11 +8,11 @@ class TagControllerTest extends TestCase
 {
     public function testShow()
     {
-        $this->get('/tag/1')->assertStatus(200);
+        $this->get('/tags/1')->assertStatus(200);
     }
 
     public function testShowNotFound()
     {
-        $this->get('/tag/100')->assertNotFound();
+        $this->get('/tags/100')->assertNotFound();
     }
 }

+ 3 - 3
tests/Feature/Home/TestCase.php

@@ -8,16 +8,16 @@ abstract class TestCase extends \Tests\Feature\TestCase
 {
     protected function UserGet($uri, array $headers = [])
     {
-        return $this->loginByUserId(static::SOCIALITE_USER_ID, 'socialite')->get($this->urlPrefix . $uri, $headers);
+        return $this->loginByUserId(static::SOCIALITE_USER_ID)->get($this->urlPrefix . $uri, $headers);
     }
 
     protected function UserPost($uri, array $data = [], array $headers = [])
     {
-        return $this->loginByUserId(static::SOCIALITE_USER_ID, 'socialite')->post($this->urlPrefix . $uri, $data, $headers);
+        return $this->loginByUserId(static::SOCIALITE_USER_ID)->post($this->urlPrefix . $uri, $data, $headers);
     }
 
     protected function UserDelete($uri, array $data = [], array $headers = [])
     {
-        return $this->loginByUserId(static::SOCIALITE_USER_ID, 'socialite')->delete($this->urlPrefix . $uri, $data, $headers);
+        return $this->loginByUserId(static::SOCIALITE_USER_ID)->delete($this->urlPrefix . $uri, $data, $headers);
     }
 }

+ 2 - 2
tests/Feature/RedirectControllerTest.php

@@ -25,12 +25,12 @@ class RedirectControllerTest extends TestCase
 
     public function testNote()
     {
-        $this->get('chat')->assertRedirect('note');
+        $this->get('chat')->assertRedirect('notes');
     }
 
     public function testOpenSource()
     {
-        $this->get('git')->assertRedirect('openSource');
+        $this->get('git')->assertRedirect('openSources');
     }
 
     public function testLogin()