From f84bf8e883e8e5bd9a24b908e2f90a2742d36d19 Mon Sep 17 00:00:00 2001 From: Dan Brown <ssddanbrown@googlemail.com> Date: Sat, 4 Apr 2020 01:16:05 +0100 Subject: [PATCH] Updated test files to be PSR-4 compliant Closes #1924 --- tests/Api/ApiAuthTest.php | 5 ++- tests/Api/ApiConfigTest.php | 7 ++-- tests/Api/ApiDocsTest.php | 4 +-- tests/Api/ApiListingTest.php | 5 ++- tests/Api/BooksApiTest.php | 3 +- tests/{ => Api}/TestsApi.php | 4 +-- tests/Auth/AuthTest.php | 3 +- tests/Auth/LdapTest.php | 3 +- tests/Auth/Saml2Test.php | 3 +- tests/Auth/SocialAuthTest.php | 3 +- tests/Auth/UserInviteTest.php | 3 +- tests/Entity/BookShelfTest.php | 3 +- tests/Entity/CommentSettingTest.php | 45 +++++++++++++++----------- tests/Entity/CommentTest.php | 3 +- tests/Entity/EntitySearchTest.php | 3 +- tests/Entity/EntityTest.php | 3 +- tests/Entity/ExportTest.php | 3 +- tests/Entity/MarkdownTest.php | 4 ++- tests/Entity/PageContentTest.php | 3 +- tests/Entity/PageDraftTest.php | 3 +- tests/Entity/PageRevisionTest.php | 2 +- tests/Entity/PageTemplateTest.php | 2 +- tests/Entity/SortTest.php | 3 +- tests/Entity/TagTest.php | 3 +- tests/Permissions/RestrictionsTest.php | 3 +- tests/Permissions/RolesTest.php | 3 +- tests/Unit/ConfigTest.php | 4 ++- tests/Unit/UrlTest.php | 4 ++- tests/Uploads/AttachmentTest.php | 3 +- tests/Uploads/UsesImages.php | 1 - tests/User/UserApiTokenTest.php | 2 +- tests/User/UserPreferencesTest.php | 4 ++- tests/User/UserProfileTest.php | 4 ++- 33 files changed, 89 insertions(+), 62 deletions(-) rename tests/{ => Api}/TestsApi.php (96%) diff --git a/tests/Api/ApiAuthTest.php b/tests/Api/ApiAuthTest.php index 1f283753a..302093947 100644 --- a/tests/Api/ApiAuthTest.php +++ b/tests/Api/ApiAuthTest.php @@ -1,10 +1,9 @@ -<?php - -namespace Tests; +<?php namespace Tests\Api; use BookStack\Auth\Permissions\RolePermission; use BookStack\Auth\User; use Carbon\Carbon; +use Tests\TestCase; class ApiAuthTest extends TestCase { diff --git a/tests/Api/ApiConfigTest.php b/tests/Api/ApiConfigTest.php index 1b3da2f34..def62c94d 100644 --- a/tests/Api/ApiConfigTest.php +++ b/tests/Api/ApiConfigTest.php @@ -1,9 +1,6 @@ -<?php +<?php namespace Tests\Api; -namespace Tests; - -use BookStack\Auth\Permissions\RolePermission; -use Carbon\Carbon; +use Tests\TestCase; class ApiConfigTest extends TestCase { diff --git a/tests/Api/ApiDocsTest.php b/tests/Api/ApiDocsTest.php index b240c1672..3cbcadfa3 100644 --- a/tests/Api/ApiDocsTest.php +++ b/tests/Api/ApiDocsTest.php @@ -1,6 +1,6 @@ -<?php +<?php namespace Tests\Api; -namespace Tests; +use Tests\TestCase; class ApiDocsTest extends TestCase { diff --git a/tests/Api/ApiListingTest.php b/tests/Api/ApiListingTest.php index 741b9664b..ac6d61aa1 100644 --- a/tests/Api/ApiListingTest.php +++ b/tests/Api/ApiListingTest.php @@ -1,8 +1,7 @@ -<?php - -namespace Tests; +<?php namespace Tests\Api; use BookStack\Entities\Book; +use Tests\TestCase; class ApiListingTest extends TestCase { diff --git a/tests/Api/BooksApiTest.php b/tests/Api/BooksApiTest.php index a40e4c93b..6f8753fb0 100644 --- a/tests/Api/BooksApiTest.php +++ b/tests/Api/BooksApiTest.php @@ -1,6 +1,7 @@ -<?php namespace Tests; +<?php namespace Tests\Api; use BookStack\Entities\Book; +use Tests\TestCase; class BooksApiTest extends TestCase { diff --git a/tests/TestsApi.php b/tests/Api/TestsApi.php similarity index 96% rename from tests/TestsApi.php rename to tests/Api/TestsApi.php index 0bb10a4cc..623fa6969 100644 --- a/tests/TestsApi.php +++ b/tests/Api/TestsApi.php @@ -1,6 +1,4 @@ -<?php - -namespace Tests; +<?php namespace Tests\Api; trait TestsApi { diff --git a/tests/Auth/AuthTest.php b/tests/Auth/AuthTest.php index eb83faded..cb27de961 100644 --- a/tests/Auth/AuthTest.php +++ b/tests/Auth/AuthTest.php @@ -1,10 +1,11 @@ -<?php namespace Tests; +<?php namespace Tests\Auth; use BookStack\Auth\User; use BookStack\Entities\Page; use BookStack\Notifications\ConfirmEmail; use BookStack\Settings\SettingService; use Illuminate\Support\Facades\Notification; +use Tests\BrowserKitTest; class AuthTest extends BrowserKitTest { diff --git a/tests/Auth/LdapTest.php b/tests/Auth/LdapTest.php index 324e3041f..de86b9fb6 100644 --- a/tests/Auth/LdapTest.php +++ b/tests/Auth/LdapTest.php @@ -1,10 +1,11 @@ -<?php namespace Tests; +<?php namespace Tests\Auth; use BookStack\Auth\Access\LdapService; use BookStack\Auth\Role; use BookStack\Auth\Access\Ldap; use BookStack\Auth\User; use Mockery\MockInterface; +use Tests\BrowserKitTest; class LdapTest extends BrowserKitTest { diff --git a/tests/Auth/Saml2Test.php b/tests/Auth/Saml2Test.php index 9a3d6d8ec..d0da45297 100644 --- a/tests/Auth/Saml2Test.php +++ b/tests/Auth/Saml2Test.php @@ -1,7 +1,8 @@ -<?php namespace Tests; +<?php namespace Tests\Auth; use BookStack\Auth\Role; use BookStack\Auth\User; +use Tests\TestCase; class Saml2Test extends TestCase { diff --git a/tests/Auth/SocialAuthTest.php b/tests/Auth/SocialAuthTest.php index 1a7a3fccc..d448b567e 100644 --- a/tests/Auth/SocialAuthTest.php +++ b/tests/Auth/SocialAuthTest.php @@ -1,10 +1,11 @@ -<?php namespace Tests; +<?php namespace Tests\Auth; use BookStack\Auth\User; use DB; use Laravel\Socialite\Contracts\Factory; use Laravel\Socialite\Contracts\Provider; use Mockery; +use Tests\TestCase; class SocialAuthTest extends TestCase { diff --git a/tests/Auth/UserInviteTest.php b/tests/Auth/UserInviteTest.php index d200134a5..f2a1d0e78 100644 --- a/tests/Auth/UserInviteTest.php +++ b/tests/Auth/UserInviteTest.php @@ -1,4 +1,4 @@ -<?php namespace Tests; +<?php namespace Tests\Auth; use BookStack\Auth\Access\UserInviteService; @@ -8,6 +8,7 @@ use Carbon\Carbon; use DB; use Illuminate\Support\Str; use Notification; +use Tests\TestCase; class UserInviteTest extends TestCase { diff --git a/tests/Entity/BookShelfTest.php b/tests/Entity/BookShelfTest.php index a318ebe24..f3d29f60c 100644 --- a/tests/Entity/BookShelfTest.php +++ b/tests/Entity/BookShelfTest.php @@ -1,10 +1,11 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; use BookStack\Auth\User; use BookStack\Entities\Book; use BookStack\Entities\Bookshelf; use BookStack\Uploads\Image; use Illuminate\Support\Str; +use Tests\TestCase; use Tests\Uploads\UsesImages; class BookShelfTest extends TestCase diff --git a/tests/Entity/CommentSettingTest.php b/tests/Entity/CommentSettingTest.php index 967e550a7..3c8cae68c 100644 --- a/tests/Entity/CommentSettingTest.php +++ b/tests/Entity/CommentSettingTest.php @@ -1,28 +1,35 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; -class CommentSettingTest extends BrowserKitTest { - protected $page; +use BookStack\Entities\Page; +use Tests\BrowserKitTest; - public function setUp(): void { - parent::setUp(); - $this->page = \BookStack\Entities\Page::first(); - } +class CommentSettingTest extends BrowserKitTest +{ + protected $page; - public function test_comment_disable () { - $this->asAdmin(); + public function setUp(): void + { + parent::setUp(); + $this->page = Page::first(); + } - $this->setSettings(['app-disable-comments' => 'true']); + public function test_comment_disable() + { + $this->asAdmin(); - $this->asAdmin()->visit($this->page->getUrl()) - ->pageNotHasElement('.comments-list'); - } + $this->setSettings(['app-disable-comments' => 'true']); - public function test_comment_enable () { - $this->asAdmin(); + $this->asAdmin()->visit($this->page->getUrl()) + ->pageNotHasElement('.comments-list'); + } - $this->setSettings(['app-disable-comments' => 'false']); + public function test_comment_enable() + { + $this->asAdmin(); - $this->asAdmin()->visit($this->page->getUrl()) - ->pageHasElement('.comments-list'); - } + $this->setSettings(['app-disable-comments' => 'false']); + + $this->asAdmin()->visit($this->page->getUrl()) + ->pageHasElement('.comments-list'); + } } \ No newline at end of file diff --git a/tests/Entity/CommentTest.php b/tests/Entity/CommentTest.php index 2b943f96f..a2126407b 100644 --- a/tests/Entity/CommentTest.php +++ b/tests/Entity/CommentTest.php @@ -1,7 +1,8 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; use BookStack\Entities\Page; use BookStack\Actions\Comment; +use Tests\TestCase; class CommentTest extends TestCase { diff --git a/tests/Entity/EntitySearchTest.php b/tests/Entity/EntitySearchTest.php index 34c3cd4a8..72eb808dc 100644 --- a/tests/Entity/EntitySearchTest.php +++ b/tests/Entity/EntitySearchTest.php @@ -1,10 +1,11 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; use BookStack\Actions\Tag; use BookStack\Entities\Book; use BookStack\Entities\Bookshelf; use BookStack\Entities\Chapter; use BookStack\Entities\Page; +use Tests\TestCase; class EntitySearchTest extends TestCase { diff --git a/tests/Entity/EntityTest.php b/tests/Entity/EntityTest.php index 97684ea4d..6d71d6090 100644 --- a/tests/Entity/EntityTest.php +++ b/tests/Entity/EntityTest.php @@ -1,4 +1,4 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; use BookStack\Entities\Bookshelf; use BookStack\Entities\Book; @@ -7,6 +7,7 @@ use BookStack\Entities\Page; use BookStack\Auth\UserRepo; use BookStack\Entities\Repos\PageRepo; use Carbon\Carbon; +use Tests\BrowserKitTest; class EntityTest extends BrowserKitTest { diff --git a/tests/Entity/ExportTest.php b/tests/Entity/ExportTest.php index 9a2d32028..5a94adac9 100644 --- a/tests/Entity/ExportTest.php +++ b/tests/Entity/ExportTest.php @@ -1,10 +1,11 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; use BookStack\Entities\Chapter; use BookStack\Entities\Page; use BookStack\Uploads\HttpFetcher; use Illuminate\Support\Str; +use Tests\TestCase; class ExportTest extends TestCase { diff --git a/tests/Entity/MarkdownTest.php b/tests/Entity/MarkdownTest.php index 5d3af4f6e..452b4c07f 100644 --- a/tests/Entity/MarkdownTest.php +++ b/tests/Entity/MarkdownTest.php @@ -1,4 +1,6 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; + +use Tests\BrowserKitTest; class MarkdownTest extends BrowserKitTest { diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.php index 8a78c8ac0..d714c3229 100644 --- a/tests/Entity/PageContentTest.php +++ b/tests/Entity/PageContentTest.php @@ -1,7 +1,8 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; use BookStack\Entities\Managers\PageContent; use BookStack\Entities\Page; +use Tests\TestCase; class PageContentTest extends TestCase { diff --git a/tests/Entity/PageDraftTest.php b/tests/Entity/PageDraftTest.php index e83f78a10..5c984940d 100644 --- a/tests/Entity/PageDraftTest.php +++ b/tests/Entity/PageDraftTest.php @@ -1,6 +1,7 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; use BookStack\Entities\Repos\PageRepo; +use Tests\BrowserKitTest; class PageDraftTest extends BrowserKitTest { diff --git a/tests/Entity/PageRevisionTest.php b/tests/Entity/PageRevisionTest.php index 38193ec1a..f8baccc54 100644 --- a/tests/Entity/PageRevisionTest.php +++ b/tests/Entity/PageRevisionTest.php @@ -1,4 +1,4 @@ -<?php namespace Entity; +<?php namespace Tests\Entity; use BookStack\Entities\Page; use BookStack\Entities\Repos\PageRepo; diff --git a/tests/Entity/PageTemplateTest.php b/tests/Entity/PageTemplateTest.php index 883de4a9f..8eba13557 100644 --- a/tests/Entity/PageTemplateTest.php +++ b/tests/Entity/PageTemplateTest.php @@ -1,4 +1,4 @@ -<?php namespace Entity; +<?php namespace Tests\Entity; use BookStack\Entities\Page; use Tests\TestCase; diff --git a/tests/Entity/SortTest.php b/tests/Entity/SortTest.php index 7d67f05c6..28c3adf31 100644 --- a/tests/Entity/SortTest.php +++ b/tests/Entity/SortTest.php @@ -1,9 +1,10 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; use BookStack\Entities\Book; use BookStack\Entities\Chapter; use BookStack\Entities\Page; use BookStack\Entities\Repos\PageRepo; +use Tests\TestCase; class SortTest extends TestCase { diff --git a/tests/Entity/TagTest.php b/tests/Entity/TagTest.php index 13876410a..87d57ea0b 100644 --- a/tests/Entity/TagTest.php +++ b/tests/Entity/TagTest.php @@ -1,4 +1,4 @@ -<?php namespace Tests; +<?php namespace Tests\Entity; use BookStack\Entities\Book; use BookStack\Entities\Chapter; @@ -6,6 +6,7 @@ use BookStack\Actions\Tag; use BookStack\Entities\Entity; use BookStack\Entities\Page; use BookStack\Auth\Permissions\PermissionService; +use Tests\BrowserKitTest; class TagTest extends BrowserKitTest { diff --git a/tests/Permissions/RestrictionsTest.php b/tests/Permissions/RestrictionsTest.php index d899c6396..7d6c1831a 100644 --- a/tests/Permissions/RestrictionsTest.php +++ b/tests/Permissions/RestrictionsTest.php @@ -1,4 +1,4 @@ -<?php namespace Tests; +<?php namespace Tests\Permissions; use BookStack\Entities\Book; use BookStack\Entities\Bookshelf; @@ -6,6 +6,7 @@ use BookStack\Entities\Chapter; use BookStack\Entities\Entity; use BookStack\Auth\User; use BookStack\Entities\Page; +use Tests\BrowserKitTest; class RestrictionsTest extends BrowserKitTest { diff --git a/tests/Permissions/RolesTest.php b/tests/Permissions/RolesTest.php index 2ef72fb0a..99080d354 100644 --- a/tests/Permissions/RolesTest.php +++ b/tests/Permissions/RolesTest.php @@ -1,4 +1,4 @@ -<?php namespace Tests; +<?php namespace Tests\Permissions; use BookStack\Entities\Bookshelf; use BookStack\Entities\Page; @@ -6,6 +6,7 @@ use BookStack\Auth\Permissions\PermissionsRepo; use BookStack\Auth\Role; use Laravel\BrowserKitTesting\HttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Tests\BrowserKitTest; class RolesTest extends BrowserKitTest { diff --git a/tests/Unit/ConfigTest.php b/tests/Unit/ConfigTest.php index c84305ad8..69b737d7d 100644 --- a/tests/Unit/ConfigTest.php +++ b/tests/Unit/ConfigTest.php @@ -1,4 +1,6 @@ -<?php namespace Tests; +<?php namespace Tests\Unit; + +use Tests\TestCase; /** * Class ConfigTest diff --git a/tests/Unit/UrlTest.php b/tests/Unit/UrlTest.php index c2386443c..feff47977 100644 --- a/tests/Unit/UrlTest.php +++ b/tests/Unit/UrlTest.php @@ -1,4 +1,6 @@ -<?php namespace Tests; +<?php namespace Tests\Unit; + +use Tests\TestCase; class UrlTest extends TestCase { diff --git a/tests/Uploads/AttachmentTest.php b/tests/Uploads/AttachmentTest.php index 12b254d00..e98a90b35 100644 --- a/tests/Uploads/AttachmentTest.php +++ b/tests/Uploads/AttachmentTest.php @@ -1,8 +1,9 @@ -<?php namespace Tests; +<?php namespace Tests\Uploads; use BookStack\Uploads\Attachment; use BookStack\Entities\Page; use BookStack\Auth\Permissions\PermissionService; +use Tests\TestCase; class AttachmentTest extends TestCase { diff --git a/tests/Uploads/UsesImages.php b/tests/Uploads/UsesImages.php index b24b483d9..251a61c9f 100644 --- a/tests/Uploads/UsesImages.php +++ b/tests/Uploads/UsesImages.php @@ -1,6 +1,5 @@ <?php namespace Tests\Uploads; - use BookStack\Entities\Page; use Illuminate\Http\UploadedFile; diff --git a/tests/User/UserApiTokenTest.php b/tests/User/UserApiTokenTest.php index 7787e34fa..f738eb579 100644 --- a/tests/User/UserApiTokenTest.php +++ b/tests/User/UserApiTokenTest.php @@ -1,4 +1,4 @@ -<?php namespace Test; +<?php namespace Test\User; use BookStack\Api\ApiToken; use Carbon\Carbon; diff --git a/tests/User/UserPreferencesTest.php b/tests/User/UserPreferencesTest.php index b81664275..b70d52dfa 100644 --- a/tests/User/UserPreferencesTest.php +++ b/tests/User/UserPreferencesTest.php @@ -1,4 +1,6 @@ -<?php namespace Tests; +<?php namespace Test\User; + +use Tests\TestCase; class UserPreferencesTest extends TestCase { diff --git a/tests/User/UserProfileTest.php b/tests/User/UserProfileTest.php index fc1a529ae..979064baa 100644 --- a/tests/User/UserProfileTest.php +++ b/tests/User/UserProfileTest.php @@ -1,4 +1,6 @@ -<?php namespace Tests; +<?php namespace Test\User; + +use Tests\BrowserKitTest; class UserProfileTest extends BrowserKitTest {