浏览代码

Upgrade to Laravel 8

Will 4 年之前
父节点
当前提交
e3ac41d007
共有 79 个文件被更改,包括 922 次插入856 次删除
  1. 1 0
      .env.example
  2. 1 1
      app/Console/Commands/ListUsers.php
  3. 8 9
      app/Console/Commands/ReceiveEmail.php
  4. 1 1
      app/Console/Commands/ResetBandwidth.php
  5. 3 17
      app/Exceptions/Handler.php
  6. 1 1
      app/Http/Controllers/Api/AdditionalUsernameController.php
  7. 3 3
      app/Http/Controllers/Api/AliasController.php
  8. 1 1
      app/Http/Controllers/Api/DomainController.php
  9. 1 1
      app/Http/Controllers/Api/ReorderRuleController.php
  10. 1 1
      app/Http/Controllers/Auth/ForgotPasswordController.php
  11. 1 1
      app/Http/Controllers/Auth/ForgotUsernameController.php
  12. 3 3
      app/Http/Controllers/Auth/RegisterController.php
  13. 2 2
      app/Http/Controllers/Auth/VerificationController.php
  14. 7 22
      app/Http/Kernel.php
  15. 2 2
      app/Http/Middleware/PreventRequestsDuringMaintenance.php
  16. 9 4
      app/Http/Middleware/RedirectIfAuthenticated.php
  17. 3 2
      app/Jobs/DeleteAccount.php
  18. 3 3
      app/Mail/ForwardEmail.php
  19. 3 3
      app/Mail/ReplyToEmail.php
  20. 3 3
      app/Mail/SendFromEmail.php
  21. 3 2
      app/Models/AdditionalUsername.php
  22. 4 3
      app/Models/Alias.php
  23. 1 1
      app/Models/AliasRecipient.php
  24. 3 2
      app/Models/DeletedUsername.php
  25. 3 2
      app/Models/Domain.php
  26. 1 1
      app/Models/EmailData.php
  27. 3 2
      app/Models/Recipient.php
  28. 3 2
      app/Models/Rule.php
  29. 3 2
      app/Models/User.php
  30. 1 3
      app/Providers/AuthServiceProvider.php
  31. 0 3
      app/Providers/EventServiceProvider.php
  32. 26 36
      app/Providers/RouteServiceProvider.php
  33. 1 1
      app/Rules/NotDeletedUsername.php
  34. 1 1
      app/Rules/RegisterUniqueRecipient.php
  35. 1 1
      app/Rules/UniqueRecipient.php
  36. 15 16
      composer.json
  37. 235 298
      composer.lock
  38. 0 1
      config/app.php
  39. 1 1
      config/auth.php
  40. 1 1
      config/database.php
  41. 1 1
      config/services.php
  42. 25 8
      database/factories/AdditionalUsernameFactory.php
  43. 32 12
      database/factories/AliasFactory.php
  44. 24 7
      database/factories/DeletedUsername.php
  45. 27 8
      database/factories/DomainFactory.php
  46. 28 9
      database/factories/RecipientFactory.php
  47. 38 21
      database/factories/RuleFactory.php
  48. 30 23
      database/factories/UserFactory.php
  49. 39 0
      database/migrations/2020_09_26_084912_update_aliasable_type_in_aliases_table.php
  50. 3 1
      database/seeds/DatabaseSeeder.php
  51. 3 3
      package-lock.json
  52. 1 1
      package.json
  53. 4 4
      phpunit.xml
  54. 22 27
      public/index.php
  55. 3 1
      resources/js/pages/Aliases.vue
  56. 3 1
      routes/api.php
  57. 3 1
      routes/channels.php
  58. 2 1
      routes/console.php
  59. 3 0
      routes/web.php
  60. 19 19
      tests/Feature/Api/AdditionalUsernamesTest.php
  61. 17 17
      tests/Feature/Api/AliasRecipientsTest.php
  62. 17 17
      tests/Feature/Api/AliasesTest.php
  63. 2 2
      tests/Feature/Api/ApiTokensTest.php
  64. 15 15
      tests/Feature/Api/DomainsTest.php
  65. 12 12
      tests/Feature/Api/RecipientsTest.php
  66. 17 17
      tests/Feature/Api/RulesTest.php
  67. 2 2
      tests/Feature/LoginTest.php
  68. 34 34
      tests/Feature/ReceiveEmailTest.php
  69. 9 9
      tests/Feature/RegistrationTest.php
  70. 8 8
      tests/Feature/ReplyToEmailTest.php
  71. 5 5
      tests/Feature/SendFromEmailTest.php
  72. 24 24
      tests/Feature/SettingsTest.php
  73. 7 7
      tests/Feature/ShowAdditionalUsernamesTest.php
  74. 16 16
      tests/Feature/ShowAliasesTest.php
  75. 8 8
      tests/Feature/ShowDomainsTest.php
  76. 14 14
      tests/Feature/ShowRecipientsTest.php
  77. 2 2
      tests/TestCase.php
  78. 18 18
      tests/Unit/AliasTest.php
  79. 22 22
      tests/Unit/UserTest.php

+ 1 - 0
.env.example

@@ -22,6 +22,7 @@ SESSION_LIFETIME=10080
 SESSION_SECURE_COOKIE=true
 SAME_SITE_COOKIES=strict
 
+REDIS_CLIENT=phpredis
 REDIS_HOST=127.0.0.1
 REDIS_PASSWORD=null
 REDIS_PORT=6379

+ 1 - 1
app/Console/Commands/ListUsers.php

@@ -2,7 +2,7 @@
 
 namespace App\Console\Commands;
 
-use App\User;
+use App\Models\User;
 use Illuminate\Console\Command;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Str;

+ 8 - 9
app/Console/Commands/ReceiveEmail.php

@@ -2,19 +2,18 @@
 
 namespace App\Console\Commands;
 
-use App\AdditionalUsername;
-use App\Alias;
-use App\Domain;
-use App\EmailData;
 use App\Mail\ForwardEmail;
 use App\Mail\ReplyToEmail;
 use App\Mail\SendFromEmail;
+use App\Models\AdditionalUsername;
+use App\Models\Alias;
+use App\Models\Domain;
+use App\Models\EmailData;
+use App\Models\User;
 use App\Notifications\NearBandwidthLimit;
-use App\User;
 use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Mail;
-use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Str;
 use PhpMimeMailParser\Parser;
 
@@ -177,7 +176,7 @@ class ReceiveEmail extends Command
             'local_part' => $recipient['local_part'],
             'domain' => $recipient['domain'],
             'aliasable_id' => $aliasable->id ?? null,
-            'aliasable_type' => $aliasable ? 'App\\'.class_basename($aliasable) : null
+            'aliasable_type' => $aliasable ? 'App\\Models\\'.class_basename($aliasable) : null
         ]);
 
         // This is a new alias but at a shared domain or the sender is not a verified recipient.
@@ -204,7 +203,7 @@ class ReceiveEmail extends Command
             'local_part' => $recipient['local_part'],
             'domain' => $recipient['domain'],
             'aliasable_id' => $aliasable->id ?? null,
-            'aliasable_type' => $aliasable ? 'App\\'.class_basename($aliasable) : null
+            'aliasable_type' => $aliasable ? 'App\\Models\\'.class_basename($aliasable) : null
         ]);
 
         if (!isset($alias->id)) {
@@ -266,7 +265,7 @@ class ReceiveEmail extends Command
 
     protected function checkRateLimit($user)
     {
-        Redis::throttle("user:{$user->username}:limit:emails")
+        \Illuminate\Support\Facades\Redis::throttle("user:{$user->username}:limit:emails")
             ->allow(config('anonaddy.limit'))
             ->every(3600)
             ->then(

+ 1 - 1
app/Console/Commands/ResetBandwidth.php

@@ -2,7 +2,7 @@
 
 namespace App\Console\Commands;
 
-use App\User;
+use App\Models\User;
 use Illuminate\Console\Command;
 
 class ResetBandwidth extends Command

+ 3 - 17
app/Exceptions/Handler.php

@@ -3,7 +3,6 @@
 namespace App\Exceptions;
 
 use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
-use Throwable;
 
 class Handler extends ExceptionHandler
 {
@@ -27,25 +26,12 @@ class Handler extends ExceptionHandler
     ];
 
     /**
-     * Report or log an exception.
+     * Register the exception handling callbacks for the application.
      *
-     * @param  \Throwable  $exception
      * @return void
      */
-    public function report(Throwable $exception)
+    public function register()
     {
-        parent::report($exception);
-    }
-
-    /**
-     * Render an exception into an HTTP response.
-     *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \Throwable  $exception
-     * @return \Illuminate\Http\Response
-     */
-    public function render($request, Throwable $exception)
-    {
-        return parent::render($request, $exception);
+        //
     }
 }

+ 1 - 1
app/Http/Controllers/Api/AdditionalUsernameController.php

@@ -2,11 +2,11 @@
 
 namespace App\Http\Controllers\Api;
 
-use App\DeletedUsername;
 use App\Http\Controllers\Controller;
 use App\Http\Requests\StoreAdditionalUsernameRequest;
 use App\Http\Requests\UpdateAdditionalUsernameRequest;
 use App\Http\Resources\AdditionalUsernameResource;
+use App\Models\DeletedUsername;
 
 class AdditionalUsernameController extends Controller
 {

+ 3 - 3
app/Http/Controllers/Api/AliasController.php

@@ -2,12 +2,12 @@
 
 namespace App\Http\Controllers\Api;
 
-use App\AdditionalUsername;
-use App\Domain;
 use App\Http\Controllers\Controller;
 use App\Http\Requests\StoreAliasRequest;
 use App\Http\Requests\UpdateAliasRequest;
 use App\Http\Resources\AliasResource;
+use App\Models\AdditionalUsername;
+use App\Models\Domain;
 use Illuminate\Http\Request;
 use Illuminate\Support\Str;
 use Ramsey\Uuid\Uuid;
@@ -82,7 +82,7 @@ class AliasController extends Controller
         }
 
         $data['aliasable_id'] = $aliasable->id ?? null;
-        $data['aliasable_type'] = $aliasable ? 'App\\'.class_basename($aliasable) : null;
+        $data['aliasable_type'] = $aliasable ? 'App\\Models\\'.class_basename($aliasable) : null;
 
         $data['domain'] = $request->domain;
         $data['description'] = $request->description;

+ 1 - 1
app/Http/Controllers/Api/DomainController.php

@@ -2,11 +2,11 @@
 
 namespace App\Http\Controllers\Api;
 
-use App\Domain;
 use App\Http\Controllers\Controller;
 use App\Http\Requests\StoreDomainRequest;
 use App\Http\Requests\UpdateDomainRequest;
 use App\Http\Resources\DomainResource;
+use App\Models\Domain;
 
 class DomainController extends Controller
 {

+ 1 - 1
app/Http/Controllers/Api/ReorderRuleController.php

@@ -4,7 +4,7 @@ namespace App\Http\Controllers\Api;
 
 use App\Http\Controllers\Controller;
 use App\Http\Requests\StoreReorderRuleRequest;
-use App\Rule;
+use App\Models\Rule;
 
 class ReorderRuleController extends Controller
 {

+ 1 - 1
app/Http/Controllers/Auth/ForgotPasswordController.php

@@ -3,7 +3,7 @@
 namespace App\Http\Controllers\Auth;
 
 use App\Http\Controllers\Controller;
-use App\User;
+use App\Models\User;
 use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Password;

+ 1 - 1
app/Http/Controllers/Auth/ForgotUsernameController.php

@@ -3,7 +3,7 @@
 namespace App\Http\Controllers\Auth;
 
 use App\Http\Controllers\Controller;
-use App\Recipient;
+use App\Models\Recipient;
 use Illuminate\Http\Request;
 
 class ForgotUsernameController extends Controller

+ 3 - 3
app/Http/Controllers/Auth/RegisterController.php

@@ -3,12 +3,12 @@
 namespace App\Http\Controllers\Auth;
 
 use App\Http\Controllers\Controller;
-use App\Recipient;
+use App\Models\Recipient;
+use App\Models\User;
 use App\Rules\NotBlacklisted;
 use App\Rules\NotDeletedUsername;
 use App\Rules\NotLocalRecipient;
 use App\Rules\RegisterUniqueRecipient;
-use App\User;
 use Illuminate\Foundation\Auth\RegistersUsers;
 use Illuminate\Support\Facades\App;
 use Illuminate\Support\Facades\Hash;
@@ -86,7 +86,7 @@ class RegisterController extends Controller
      * Create a new user instance after a valid registration.
      *
      * @param  array  $data
-     * @return \App\User
+     * @return \App\Models\User
      */
     protected function create(array $data)
     {

+ 2 - 2
app/Http/Controllers/Auth/VerificationController.php

@@ -3,8 +3,8 @@
 namespace App\Http\Controllers\Auth;
 
 use App\Http\Controllers\Controller;
-use App\Recipient;
-use App\User;
+use App\Models\Recipient;
+use App\Models\User;
 use Illuminate\Auth\Access\AuthorizationException;
 use Illuminate\Auth\Events\Verified;
 use Illuminate\Foundation\Auth\VerifiesEmails;

+ 7 - 22
app/Http/Kernel.php

@@ -14,12 +14,13 @@ class Kernel extends HttpKernel
      * @var array
      */
     protected $middleware = [
-        \App\Http\Middleware\CheckForMaintenanceMode::class,
+        // \App\Http\Middleware\TrustHosts::class,
+        \App\Http\Middleware\TrustProxies::class,
+        \Fruitcake\Cors\HandleCors::class,
+        \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
         \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
         \App\Http\Middleware\TrimStrings::class,
         \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
-        \App\Http\Middleware\TrustProxies::class,
-        \Fruitcake\Cors\HandleCors::class,
     ];
 
     /**
@@ -40,8 +41,8 @@ class Kernel extends HttpKernel
         ],
 
         'api' => [
-            'throttle:60,1',
-            'bindings',
+            'throttle:api',
+            \Illuminate\Routing\Middleware\SubstituteBindings::class,
         ],
     ];
 
@@ -55,29 +56,13 @@ class Kernel extends HttpKernel
     protected $routeMiddleware = [
         'auth' => \App\Http\Middleware\Authenticate::class,
         'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
-        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
         'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
         'can' => \Illuminate\Auth\Middleware\Authorize::class,
         'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
+        'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
         'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
         'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
         'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
         '2fa' => \App\Http\Middleware\VerifyTwoFactorAuth::class,
     ];
-
-    /**
-     * The priority-sorted list of middleware.
-     *
-     * This forces non-global middleware to always be in the given order.
-     *
-     * @var array
-     */
-    protected $middlewarePriority = [
-        \Illuminate\Session\Middleware\StartSession::class,
-        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
-        \App\Http\Middleware\Authenticate::class,
-        \Illuminate\Session\Middleware\AuthenticateSession::class,
-        \Illuminate\Routing\Middleware\SubstituteBindings::class,
-        \Illuminate\Auth\Middleware\Authorize::class,
-    ];
 }

+ 2 - 2
app/Http/Middleware/CheckForMaintenanceMode.php → app/Http/Middleware/PreventRequestsDuringMaintenance.php

@@ -2,9 +2,9 @@
 
 namespace App\Http\Middleware;
 
-use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
+use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
 
-class CheckForMaintenanceMode extends Middleware
+class PreventRequestsDuringMaintenance extends Middleware
 {
     /**
      * The URIs that should be reachable while maintenance mode is enabled.

+ 9 - 4
app/Http/Middleware/RedirectIfAuthenticated.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Middleware;
 
+use App\Providers\RouteServiceProvider;
 use Closure;
 use Illuminate\Support\Facades\Auth;
 
@@ -12,13 +13,17 @@ class RedirectIfAuthenticated
      *
      * @param  \Illuminate\Http\Request  $request
      * @param  \Closure  $next
-     * @param  string|null  $guard
+     * @param  string|null  ...$guards
      * @return mixed
      */
-    public function handle($request, Closure $next, $guard = null)
+    public function handle($request, Closure $next, ...$guards)
     {
-        if (Auth::guard($guard)->check()) {
-            return redirect('/');
+        $guards = empty($guards) ? [null] : $guards;
+
+        foreach ($guards as $guard) {
+            if (Auth::guard($guard)->check()) {
+                return redirect(RouteServiceProvider::HOME);
+            }
         }
 
         return $next($request);

+ 3 - 2
app/Jobs/DeleteAccount.php

@@ -2,8 +2,8 @@
 
 namespace App\Jobs;
 
-use App\DeletedUsername;
-use App\User;
+use App\Models\DeletedUsername;
+use App\Models\User;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
@@ -45,6 +45,7 @@ class DeleteAccount implements ShouldQueue
         $this->user->domains()->delete();
         $this->user->additionalUsernames()->get()->each->delete(); // In order to fire deleting model event.
         $this->user->tokens()->delete();
+        $this->user->rules()->delete();
         $this->user->delete();
     }
 }

+ 3 - 3
app/Mail/ForwardEmail.php

@@ -2,12 +2,12 @@
 
 namespace App\Mail;
 
-use App\Alias;
-use App\EmailData;
 use App\Helpers\AlreadyEncryptedSigner;
 use App\Helpers\OpenPGPSigner;
+use App\Models\Alias;
+use App\Models\EmailData;
+use App\Models\Recipient;
 use App\Notifications\GpgKeyExpired;
-use App\Recipient;
 use App\Traits\CheckUserRules;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;

+ 3 - 3
app/Mail/ReplyToEmail.php

@@ -2,11 +2,11 @@
 
 namespace App\Mail;
 
-use App\Alias;
-use App\EmailData;
 use App\Helpers\AlreadyEncryptedSigner;
+use App\Models\Alias;
+use App\Models\EmailData;
+use App\Models\User;
 use App\Traits\CheckUserRules;
-use App\User;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Mail\Mailable;

+ 3 - 3
app/Mail/SendFromEmail.php

@@ -2,11 +2,11 @@
 
 namespace App\Mail;
 
-use App\Alias;
-use App\EmailData;
 use App\Helpers\AlreadyEncryptedSigner;
+use App\Models\Alias;
+use App\Models\EmailData;
+use App\Models\User;
 use App\Traits\CheckUserRules;
-use App\User;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Mail\Mailable;

+ 3 - 2
app/AdditionalUsername.php → app/Models/AdditionalUsername.php

@@ -1,14 +1,15 @@
 <?php
 
-namespace App;
+namespace App\Models;
 
 use App\Traits\HasEncryptedAttributes;
 use App\Traits\HasUuid;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 
 class AdditionalUsername extends Model
 {
-    use HasUuid, HasEncryptedAttributes;
+    use HasUuid, HasEncryptedAttributes, HasFactory;
 
     public $incrementing = false;
 

+ 4 - 3
app/Alias.php → app/Models/Alias.php

@@ -1,16 +1,17 @@
 <?php
 
-namespace App;
+namespace App\Models;
 
 use App\Traits\HasEncryptedAttributes;
 use App\Traits\HasUuid;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\SoftDeletes;
 use Illuminate\Support\Str;
 
 class Alias extends Model
 {
-    use SoftDeletes, HasUuid, HasEncryptedAttributes;
+    use SoftDeletes, HasUuid, HasEncryptedAttributes, HasFactory;
 
     public $incrementing = false;
 
@@ -139,7 +140,7 @@ class Alias extends Model
 
     public function isCustomDomain()
     {
-        return $this->aliasable_type === 'App\Domain';
+        return $this->aliasable_type === 'App\Models\Domain';
     }
 
     public function parentDomain()

+ 1 - 1
app/AliasRecipient.php → app/Models/AliasRecipient.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App;
+namespace App\Models;
 
 use App\Traits\HasUuid;
 use Illuminate\Database\Eloquent\Relations\Pivot;

+ 3 - 2
app/DeletedUsername.php → app/Models/DeletedUsername.php

@@ -1,13 +1,14 @@
 <?php
 
-namespace App;
+namespace App\Models;
 
 use App\Traits\HasEncryptedAttributes;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 
 class DeletedUsername extends Model
 {
-    use HasEncryptedAttributes;
+    use HasEncryptedAttributes, HasFactory;
 
     public $incrementing = false;
 

+ 3 - 2
app/Domain.php → app/Models/Domain.php

@@ -1,16 +1,17 @@
 <?php
 
-namespace App;
+namespace App\Models;
 
 use App\Http\Resources\DomainResource;
 use App\Traits\HasEncryptedAttributes;
 use App\Traits\HasUuid;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\App;
 
 class Domain extends Model
 {
-    use HasUuid, HasEncryptedAttributes;
+    use HasUuid, HasEncryptedAttributes, HasFactory;
 
     public $incrementing = false;
 

+ 1 - 1
app/EmailData.php → app/Models/EmailData.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App;
+namespace App\Models;
 
 use PhpMimeMailParser\Parser;
 

+ 3 - 2
app/Recipient.php → app/Models/Recipient.php

@@ -1,18 +1,19 @@
 <?php
 
-namespace App;
+namespace App\Models;
 
 use App\Notifications\UsernameReminder;
 use App\Traits\HasEncryptedAttributes;
 use App\Traits\HasUuid;
 use Illuminate\Auth\Notifications\VerifyEmail;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 
 use Illuminate\Notifications\Notifiable;
 
 class Recipient extends Model
 {
-    use Notifiable, HasUuid, HasEncryptedAttributes;
+    use Notifiable, HasUuid, HasEncryptedAttributes, HasFactory;
 
     public $incrementing = false;
 

+ 3 - 2
app/Rule.php → app/Models/Rule.php

@@ -1,13 +1,14 @@
 <?php
 
-namespace App;
+namespace App\Models;
 
 use App\Traits\HasUuid;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 
 class Rule extends Model
 {
-    use HasUuid;
+    use HasUuid, HasFactory;
 
     public $incrementing = false;
 

+ 3 - 2
app/User.php → app/Models/User.php

@@ -1,10 +1,11 @@
 <?php
 
-namespace App;
+namespace App\Models;
 
 use App\Traits\HasEncryptedAttributes;
 use App\Traits\HasUuid;
 use Illuminate\Contracts\Auth\MustVerifyEmail;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Foundation\Auth\User as Authenticatable;
 use Illuminate\Notifications\Notifiable;
 use Illuminate\Support\Str;
@@ -12,7 +13,7 @@ use Laravel\Passport\HasApiTokens;
 
 class User extends Authenticatable implements MustVerifyEmail
 {
-    use Notifiable, HasUuid, HasEncryptedAttributes, HasApiTokens;
+    use Notifiable, HasUuid, HasEncryptedAttributes, HasApiTokens, HasFactory;
 
     public $incrementing = false;
 

+ 1 - 3
app/Providers/AuthServiceProvider.php

@@ -13,7 +13,7 @@ class AuthServiceProvider extends ServiceProvider
      * @var array
      */
     protected $policies = [
-        'App\Model' => 'App\Policies\ModelPolicy',
+        'App\Models\Model' => 'App\Policies\ModelPolicy',
     ];
 
     /**
@@ -29,8 +29,6 @@ class AuthServiceProvider extends ServiceProvider
             $router->forPersonalAccessTokens();
         }, ['middleware' => ['web', 'auth', '2fa']]);
 
-        Passport::personalAccessClientId(1);
-
         Passport::cookie('anonaddy_token');
     }
 }

+ 0 - 3
app/Providers/EventServiceProvider.php

@@ -7,7 +7,6 @@ use Illuminate\Auth\Events\Registered;
 use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
 use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
 use Illuminate\Mail\Events\MessageSending;
-use Illuminate\Support\Facades\Event;
 
 class EventServiceProvider extends ServiceProvider
 {
@@ -32,8 +31,6 @@ class EventServiceProvider extends ServiceProvider
      */
     public function boot()
     {
-        parent::boot();
-
         //
     }
 }

+ 26 - 36
app/Providers/RouteServiceProvider.php

@@ -2,7 +2,10 @@
 
 namespace App\Providers;
 
+use Illuminate\Cache\RateLimiting\Limit;
 use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\RateLimiter;
 use Illuminate\Support\Facades\Route;
 
 class RouteServiceProvider extends ServiceProvider
@@ -17,57 +20,44 @@ class RouteServiceProvider extends ServiceProvider
     protected $namespace = 'App\Http\Controllers';
 
     /**
-     * Define your route model bindings, pattern filters, etc.
+     * The path to the "home" route for your application.
      *
-     * @return void
-     */
-    public function boot()
-    {
-        //
-
-        parent::boot();
-    }
-
-    /**
-     * Define the routes for the application.
+     * This is used by Laravel authentication to redirect users after login.
      *
-     * @return void
+     * @var string
      */
-    public function map()
-    {
-        $this->mapApiRoutes();
-
-        $this->mapWebRoutes();
-
-        //
-    }
+    public const HOME = '/';
 
     /**
-     * Define the "web" routes for the application.
-     *
-     * These routes all receive session state, CSRF protection, etc.
+     * Define your route model bindings, pattern filters, etc.
      *
      * @return void
      */
-    protected function mapWebRoutes()
+    public function boot()
     {
-        Route::middleware('web')
-             ->namespace($this->namespace)
-             ->group(base_path('routes/web.php'));
+        $this->configureRateLimiting();
+
+        $this->routes(function () {
+            Route::prefix('api')
+                ->middleware('api')
+                ->namespace($this->namespace)
+                ->group(base_path('routes/api.php'));
+
+            Route::middleware('web')
+                ->namespace($this->namespace)
+                ->group(base_path('routes/web.php'));
+        });
     }
 
     /**
-     * Define the "api" routes for the application.
-     *
-     * These routes are typically stateless.
+     * Configure the rate limiters for the application.
      *
      * @return void
      */
-    protected function mapApiRoutes()
+    protected function configureRateLimiting()
     {
-        Route::prefix('api')
-             ->middleware('auth:api')
-             ->namespace($this->namespace)
-             ->group(base_path('routes/api.php'));
+        RateLimiter::for('api', function (Request $request) {
+            return Limit::perMinute(60);
+        });
     }
 }

+ 1 - 1
app/Rules/NotDeletedUsername.php

@@ -2,7 +2,7 @@
 
 namespace App\Rules;
 
-use App\DeletedUsername;
+use App\Models\DeletedUsername;
 use Illuminate\Contracts\Validation\Rule;
 
 class NotDeletedUsername implements Rule

+ 1 - 1
app/Rules/RegisterUniqueRecipient.php

@@ -2,7 +2,7 @@
 
 namespace App\Rules;
 
-use App\Recipient;
+use App\Models\Recipient;
 use Illuminate\Contracts\Validation\Rule;
 
 class RegisterUniqueRecipient implements Rule

+ 1 - 1
app/Rules/UniqueRecipient.php

@@ -2,7 +2,7 @@
 
 namespace App\Rules;
 
-use App\Recipient;
+use App\Models\Recipient;
 use Illuminate\Contracts\Validation\Rule;
 
 class UniqueRecipient implements Rule

+ 15 - 16
composer.json

@@ -8,15 +8,16 @@
     ],
     "license": "MIT",
     "require": {
-        "php": "^7.2",
+        "php": "^7.3",
         "bacon/bacon-qr-code": "^2.0",
         "doctrine/dbal": "^2.9",
-        "fideloper/proxy": "^4.0",
+        "fideloper/proxy": "^4.2",
         "fruitcake/laravel-cors": "^2.0",
-        "laravel/framework": "^7.0",
-        "laravel/passport": "^9.0",
+        "guzzlehttp/guzzle": "^7.0.1",
+        "laravel/framework": "^8.0",
+        "laravel/passport": "^10.0",
         "laravel/tinker": "^2.0",
-        "laravel/ui": "^2.0",
+        "laravel/ui": "^3.0",
         "maatwebsite/excel": "^3.1",
         "mews/captcha": "^3.0.0",
         "php-mime-mail-parser/php-mime-mail-parser": "^6.0",
@@ -26,12 +27,12 @@
     },
     "require-dev": {
         "beyondcode/laravel-dump-server": "^1.0",
-        "facade/ignition": "^2.0",
+        "facade/ignition": "^2.3.6",
         "friendsofphp/php-cs-fixer": "^2.14",
-        "fzaninotto/faker": "^1.4",
-        "mockery/mockery": "^1.0",
-        "nunomaduro/collision": "^4.1",
-        "phpunit/phpunit": "^8.5"
+        "fzaninotto/faker": "^1.9.1",
+        "mockery/mockery": "^1.3.1",
+        "nunomaduro/collision": "^5.0",
+        "phpunit/phpunit": "^9.3"
     },
     "config": {
         "optimize-autoloader": true,
@@ -45,12 +46,10 @@
     },
     "autoload": {
         "psr-4": {
-            "App\\": "app/"
-        },
-        "classmap": [
-            "database/seeds",
-            "database/factories"
-        ]
+            "App\\": "app/",
+            "Database\\Factories\\": "database/factories/",
+            "Database\\Seeders\\": "database/seeders/"
+        }
     },
     "autoload-dev": {
         "psr-4": {

文件差异内容过多而无法显示
+ 235 - 298
composer.lock


+ 0 - 1
config/app.php

@@ -214,7 +214,6 @@ return [
         'Password' => Illuminate\Support\Facades\Password::class,
         'Queue' => Illuminate\Support\Facades\Queue::class,
         'Redirect' => Illuminate\Support\Facades\Redirect::class,
-        'Redis' => Illuminate\Support\Facades\Redis::class,
         'Request' => Illuminate\Support\Facades\Request::class,
         'Response' => Illuminate\Support\Facades\Response::class,
         'Route' => Illuminate\Support\Facades\Route::class,

+ 1 - 1
config/auth.php

@@ -67,7 +67,7 @@ return [
     'providers' => [
         'users' => [
             'driver' => 'eloquent',
-            'model' => App\User::class,
+            'model' => App\Models\User::class,
         ],
 
         // 'users' => [

+ 1 - 1
config/database.php

@@ -110,7 +110,7 @@ return [
 
     'redis' => [
 
-        'client' => 'predis',
+        'client' => env('REDIS_CLIENT', 'phpredis'),
 
         'default' => [
             'host' => env('REDIS_HOST', '127.0.0.1'),

+ 1 - 1
config/services.php

@@ -31,7 +31,7 @@ return [
     ],
 
     'stripe' => [
-        'model' => App\User::class,
+        'model' => App\Models\User::class,
         'key' => env('STRIPE_KEY'),
         'secret' => env('STRIPE_SECRET'),
         'webhook' => [

+ 25 - 8
database/factories/AdditionalUsernameFactory.php

@@ -1,12 +1,29 @@
 <?php
 
-/** @var \Illuminate\Database\Eloquent\Factory $factory */
+namespace Database\Factories;
 
-use Faker\Generator as Faker;
+use App\Models\AdditionalUsername;
+use Illuminate\Database\Eloquent\Factories\Factory;
 
-$factory->define(App\AdditionalUsername::class, function (Faker $faker) {
-    return [
-        'user_id' => $faker->uuid,
-        'username' => $faker->userName
-    ];
-});
+class AdditionalUsernameFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected $model = AdditionalUsername::class;
+
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        return [
+            'user_id' => $this->faker->uuid,
+            'username' => $this->faker->userName.$this->faker->randomNumber(3)
+        ];
+    }
+}

+ 32 - 12
database/factories/AliasFactory.php

@@ -1,14 +1,34 @@
 <?php
 
-use Faker\Generator as Faker;
-
-$factory->define(App\Alias::class, function (Faker $faker) {
-    return [
-        'user_id' => $faker->uuid,
-        'email' => $faker->userName.'@'.$faker->unique()->word.'.'.config('anonaddy.domain'),
-        'local_part' => $faker->userName,
-        'domain' => 'johndoe.'.config('anonaddy.domain'),
-        'active' => true,
-        'description' => $faker->sentence
-    ];
-});
+namespace Database\Factories;
+
+use App\Models\Alias;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+class AliasFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected $model = Alias::class;
+
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        $localPart = $this->faker->userName.$this->faker->randomNumber(2);
+        return [
+            'user_id' => $this->faker->uuid,
+            'email' => $localPart.'@'.$this->faker->word.'.'.config('anonaddy.domain'),
+            'local_part' => $localPart,
+            'domain' => 'johndoe.'.config('anonaddy.domain'),
+            'active' => true,
+            'description' => $this->faker->sentence
+        ];
+    }
+}

+ 24 - 7
database/factories/DeletedUsername.php

@@ -1,11 +1,28 @@
 <?php
 
-/** @var \Illuminate\Database\Eloquent\Factory $factory */
+namespace Database\Factories;
 
-use Faker\Generator as Faker;
+use App\Models\DeletedUsername;
+use Illuminate\Database\Eloquent\Factories\Factory;
 
-$factory->define(App\DeletedUsername::class, function (Faker $faker) {
-    return [
-        'username' => $faker->userName,
-    ];
-});
+class DeletedUsernameFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected $model = DeletedUsername::class;
+
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        return [
+            'username' => $this->faker->userName,
+        ];
+    }
+}

+ 27 - 8
database/factories/DomainFactory.php

@@ -1,10 +1,29 @@
 <?php
 
-use Faker\Generator as Faker;
-
-$factory->define(App\Domain::class, function (Faker $faker) {
-    return [
-        'user_id' => $faker->uuid,
-        'domain' => $faker->domainName
-    ];
-});
+namespace Database\Factories;
+
+use App\Models\Domain;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+class DomainFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected $model = Domain::class;
+
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        return [
+            'user_id' => $this->faker->uuid,
+            'domain' => $this->faker->domainName.$this->faker->randomNumber(3)
+        ];
+    }
+}

+ 28 - 9
database/factories/RecipientFactory.php

@@ -1,11 +1,30 @@
 <?php
 
-use Faker\Generator as Faker;
-
-$factory->define(App\Recipient::class, function (Faker $faker) {
-    return [
-        'user_id' => $faker->uuid,
-        'email' => $faker->safeEmail,
-        'email_verified_at' => now()
-    ];
-});
+namespace Database\Factories;
+
+use App\Models\Recipient;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+class RecipientFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected $model = Recipient::class;
+
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        return [
+            'user_id' => $this->faker->uuid,
+            'email' => $this->faker->safeEmail,
+            'email_verified_at' => now()
+        ];
+    }
+}

+ 38 - 21
database/factories/RuleFactory.php

@@ -1,27 +1,44 @@
 <?php
 
-/** @var \Illuminate\Database\Eloquent\Factory $factory */
+namespace Database\Factories;
 
-use Faker\Generator as Faker;
+use App\Models\Rule;
+use Illuminate\Database\Eloquent\Factories\Factory;
 
-$factory->define(App\Rule::class, function (Faker $faker) {
-    return [
-        'name' => $faker->userName,
-        'order' => $faker->randomNumber(1),
-        'conditions' => [
-            [
-                'type' => 'sender',
-                'match' => 'is exactly',
-                'values' => [
-                    'will@anonaddy.com'
+class RuleFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected $model = Rule::class;
+
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        return [
+            'name' => $this->faker->userName,
+            'order' => $this->faker->randomNumber(1),
+            'conditions' => [
+                [
+                    'type' => 'sender',
+                    'match' => 'is exactly',
+                    'values' => [
+                        'will@anonaddy.com'
+                    ]
+                ]
+            ],
+            'actions' => [
+                [
+                    'type' => 'subject',
+                    'value' => 'New Subject!'
                 ]
             ]
-        ],
-        'actions' => [
-            [
-                'type' => 'subject',
-                'value' => 'New Subject!'
-            ]
-        ]
-    ];
-});
+        ];
+    }
+}

+ 30 - 23
database/factories/UserFactory.php

@@ -1,28 +1,35 @@
 <?php
 
-use Faker\Generator as Faker;
+namespace Database\Factories;
+
+use App\Models\Recipient;
+use App\Models\User;
+use Illuminate\Database\Eloquent\Factories\Factory;
 use Illuminate\Support\Str;
 
-/*
-|--------------------------------------------------------------------------
-| Model Factories
-|--------------------------------------------------------------------------
-|
-| This directory should contain each of the model factory definitions for
-| your application. Factories provide a convenient way to generate new
-| model instances for testing / seeding your application's database.
-|
-*/
+class UserFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected $model = User::class;
 
-$factory->define(App\User::class, function (Faker $faker) {
-    return [
-        'username' => $faker->userName,
-        'banner_location' => 'top',
-        'bandwidth' => 0,
-        'default_recipient_id' => function () {
-            return factory(App\Recipient::class)->create()->id;
-        },
-        'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
-        'remember_token' => Str::random(10),
-    ];
-});
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        return [
+            'username' => $this->faker->userName.$this->faker->randomNumber(3),
+            'banner_location' => 'top',
+            'bandwidth' => 0,
+            'default_recipient_id' => Recipient::factory(),
+            'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
+            'remember_token' => Str::random(10),
+        ];
+    }
+}

+ 39 - 0
database/migrations/2020_09_26_084912_update_aliasable_type_in_aliases_table.php

@@ -0,0 +1,39 @@
+<?php
+
+use App\Models\Alias;
+use Illuminate\Database\Migrations\Migration;
+
+class UpdateAliasableTypeInAliasesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Alias::withTrashed()
+        ->where('aliasable_type', 'App\AdditionalUsername')
+        ->update(['aliasable_type' => 'App\Models\AdditionalUsername']);
+
+        Alias::withTrashed()
+        ->where('aliasable_type', 'App\Domain')
+        ->update(['aliasable_type' => 'App\Models\Domain']);
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Alias::withTrashed()
+        ->where('aliasable_type', 'App\Models\AdditionalUsername')
+        ->update(['aliasable_type' => 'App\AdditionalUsername']);
+
+        Alias::withTrashed()
+        ->where('aliasable_type', 'App\Models\Domain')
+        ->update(['aliasable_type' => 'App\Domain']);
+    }
+}

+ 3 - 1
database/seeds/DatabaseSeeder.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Database\Seeders;
+
 use Illuminate\Database\Seeder;
 
 class DatabaseSeeder extends Seeder
@@ -11,6 +13,6 @@ class DatabaseSeeder extends Seeder
      */
     public function run()
     {
-        // $this->call(UsersTableSeeder::class);
+        //$this->call(UserSeeder::class);
     }
 }

+ 3 - 3
package-lock.json

@@ -2715,9 +2715,9 @@
             "dev": true
         },
         "dayjs": {
-            "version": "1.8.35",
-            "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.35.tgz",
-            "integrity": "sha512-isAbIEenO4ilm6f8cpqvgjZCsuerDAz2Kb7ri201AiNn58aqXuaLJEnCtfIMdCvERZHNGRY5lDMTr/jdAnKSWQ=="
+            "version": "1.8.36",
+            "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.36.tgz",
+            "integrity": "sha512-3VmRXEtw7RZKAf+4Tv1Ym9AGeo8r8+CjDi26x+7SYQil1UqtqdaokhzoEJohqlzt0m5kacJSDhJQkG/LWhpRBw=="
         },
         "de-indent": {
             "version": "1.0.2",

+ 1 - 1
package.json

@@ -13,7 +13,7 @@
     "dependencies": {
         "axios": "^0.18.1",
         "cross-env": "^5.2.1",
-        "dayjs": "^1.8.35",
+        "dayjs": "^1.8.36",
         "laravel-mix": "^4.1.4",
         "laravel-mix-purgecss": "^4.2.0",
         "lodash": "^4.17.20",

+ 4 - 4
phpunit.xml

@@ -17,11 +17,11 @@
             <directory suffix="Test.php">./tests/Feature</directory>
         </testsuite>
     </testsuites>
-    <filter>
-        <whitelist processUncoveredFilesFromWhitelist="true">
+    <coverage processUncoveredFiles="true">
+        <include>
             <directory suffix=".php">./app</directory>
-        </whitelist>
-    </filter>
+        </include>
+    </coverage>
     <php>
         <env name="APP_ENV" value="testing"/>
         <env name="BCRYPT_ROUNDS" value="4"/>

+ 22 - 27
public/index.php

@@ -1,60 +1,55 @@
 <?php
 
-/**
- * Laravel - A PHP Framework For Web Artisans
- *
- * @package  Laravel
- * @author   Taylor Otwell <taylor@laravel.com>
- */
+use Illuminate\Contracts\Http\Kernel;
+use Illuminate\Http\Request;
 
 define('LARAVEL_START', microtime(true));
 
 /*
 |--------------------------------------------------------------------------
-| Register The Auto Loader
+| Check If Application Is Under Maintenance
 |--------------------------------------------------------------------------
 |
-| Composer provides a convenient, automatically generated class loader for
-| our application. We just need to utilize it! We'll simply require it
-| into the script here so that we don't have to worry about manual
-| loading any of our classes later on. It feels great to relax.
+| If the application is maintenance / demo mode via the "down" command we
+| will require this file so that any prerendered template can be shown
+| instead of starting the framework, which could cause an exception.
 |
 */
 
-require __DIR__.'/../vendor/autoload.php';
+if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
+    require __DIR__.'/../storage/framework/maintenance.php';
+}
 
 /*
 |--------------------------------------------------------------------------
-| Turn On The Lights
+| Register The Auto Loader
 |--------------------------------------------------------------------------
 |
-| We need to illuminate PHP development, so let us turn on the lights.
-| This bootstraps the framework and gets it ready for use, then it
-| will load up this application so that we can run it and send
-| the responses back to the browser and delight our users.
+| Composer provides a convenient, automatically generated class loader for
+| this application. We just need to utilize it! We'll simply require it
+| into the script here so we don't need to manually load our classes.
 |
 */
 
-$app = require_once __DIR__.'/../bootstrap/app.php';
+require __DIR__.'/../vendor/autoload.php';
 
 /*
 |--------------------------------------------------------------------------
 | Run The Application
 |--------------------------------------------------------------------------
 |
-| Once we have the application, we can handle the incoming request
-| through the kernel, and send the associated response back to
-| the client's browser allowing them to enjoy the creative
-| and wonderful application we have prepared for them.
+| Once we have the application, we can handle the incoming request using
+| the application's HTTP kernel. Then, we will send the response back
+| to this client's browser, allowing them to enjoy our application.
 |
 */
 
-$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
+$app = require_once __DIR__.'/../bootstrap/app.php';
 
-$response = $kernel->handle(
-    $request = Illuminate\Http\Request::capture()
-);
+$kernel = $app->make(Kernel::class);
 
-$response->send();
+$response = tap($kernel->handle(
+    $request = Request::capture()
+))->send();
 
 $kernel->terminate($request, $response);

+ 3 - 1
resources/js/pages/Aliases.vue

@@ -263,7 +263,9 @@
             v-else-if="has(props.row.aliasable, 'default_recipient.email')"
             class="py-1 px-2 text-xs bg-yellow-200 text-yellow-900 rounded-full tooltip outline-none"
             :data-tippy-content="props.row.aliasable.default_recipient.email"
-            >{{ props.row.aliasable_type === 'App\\Domain' ? 'domain' : 'username' }}'s</span
+            >{{
+              props.row.aliasable_type === 'App\\Models\\Domain' ? 'domain' : 'username'
+            }}'s</span
           >
           <span
             v-else

+ 3 - 1
routes/api.php

@@ -1,5 +1,7 @@
 <?php
 
+use Illuminate\Support\Facades\Route;
+
 /*
 |--------------------------------------------------------------------------
 | API Routes
@@ -12,7 +14,7 @@
 */
 
 Route::group([
-  'middleware' => ['verified'],
+  'middleware' => ['auth:api', 'verified'],
   'prefix' => 'v1'
 ], function () {
     Route::get('/aliases', 'Api\AliasController@index');

+ 3 - 1
routes/channels.php

@@ -1,5 +1,7 @@
 <?php
 
+use Illuminate\Support\Facades\Broadcast;
+
 /*
 |--------------------------------------------------------------------------
 | Broadcast Channels
@@ -11,6 +13,6 @@
 |
 */
 
-Broadcast::channel('App.User.{id}', function ($user, $id) {
+Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
     return (int) $user->id === (int) $id;
 });

+ 2 - 1
routes/console.php

@@ -1,6 +1,7 @@
 <?php
 
 use Illuminate\Foundation\Inspiring;
+use Illuminate\Support\Facades\Artisan;
 
 /*
 |--------------------------------------------------------------------------
@@ -15,4 +16,4 @@ use Illuminate\Foundation\Inspiring;
 
 Artisan::command('inspire', function () {
     $this->comment(Inspiring::quote());
-})->describe('Display an inspiring quote');
+})->purpose('Display an inspiring quote');

+ 3 - 0
routes/web.php

@@ -1,5 +1,8 @@
 <?php
 
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Route;
+
 /*
 |--------------------------------------------------------------------------
 | Web Routes

+ 19 - 19
tests/Feature/Api/AdditionalUsernamesTest.php

@@ -2,10 +2,10 @@
 
 namespace Tests\Feature\Api;
 
-use App\AdditionalUsername;
-use App\DeletedUsername;
-use App\Recipient;
-use App\User;
+use App\Models\AdditionalUsername;
+use App\Models\DeletedUsername;
+use App\Models\Recipient;
+use App\Models\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Tests\TestCase;
 
@@ -23,7 +23,7 @@ class AdditionalUsernamesTest extends TestCase
     public function user_can_get_all_additional_usernames()
     {
         // Arrange
-        factory(AdditionalUsername::class, 3)->create([
+        AdditionalUsername::factory()->count(3)->create([
             'user_id' => $this->user->id
         ]);
 
@@ -39,7 +39,7 @@ class AdditionalUsernamesTest extends TestCase
     public function user_can_get_individual_additional_username()
     {
         // Arrange
-        $username = factory(AdditionalUsername::class)->create([
+        $username = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -91,7 +91,7 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function user_can_not_create_the_same_username()
     {
-        factory(AdditionalUsername::class)->create([
+        AdditionalUsername::factory()->create([
             'user_id' => $this->user->id,
             'username' => 'janedoe'
         ]);
@@ -108,7 +108,7 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function user_can_not_create_additional_username_that_has_been_deleted()
     {
-        factory(DeletedUsername::class)->create([
+        DeletedUsername::factory()->create([
             'username' => 'janedoe'
         ]);
 
@@ -124,7 +124,7 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function must_be_unique_across_users_and_additional_usernames_tables()
     {
-        $user = factory(User::class)->create();
+        $user = User::factory()->create();
 
         $response = $this->json('POST', '/api/v1/usernames', [
             'username' => $user->username
@@ -162,7 +162,7 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function user_can_activate_additional_username()
     {
-        $username = factory(AdditionalUsername::class)->create([
+        $username = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id,
             'active' => false
         ]);
@@ -178,7 +178,7 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function user_can_deactivate_additional_username()
     {
-        $username = factory(AdditionalUsername::class)->create([
+        $username = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id,
             'active' => true
         ]);
@@ -192,7 +192,7 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function user_can_update_additional_usernames_description()
     {
-        $username = factory(AdditionalUsername::class)->create([
+        $username = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -207,7 +207,7 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function user_can_delete_additional_username()
     {
-        $username = factory(AdditionalUsername::class)->create([
+        $username = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -222,11 +222,11 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function user_can_update_additional_username_default_recipient()
     {
-        $additionalUsername = factory(AdditionalUsername::class)->create([
+        $additionalUsername = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $newDefaultRecipient = factory(Recipient::class)->create([
+        $newDefaultRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -246,11 +246,11 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function user_cannot_update_additional_username_default_recipient_with_unverified_recipient()
     {
-        $additionalUsername = factory(AdditionalUsername::class)->create([
+        $additionalUsername = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $newDefaultRecipient = factory(Recipient::class)->create([
+        $newDefaultRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email_verified_at' => null
         ]);
@@ -269,11 +269,11 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function user_can_remove_additional_username_default_recipient()
     {
-        $defaultRecipient = factory(Recipient::class)->create([
+        $defaultRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $additionalUsername = factory(AdditionalUsername::class)->create([
+        $additionalUsername = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id,
             'default_recipient_id' => $defaultRecipient->id
         ]);

+ 17 - 17
tests/Feature/Api/AliasRecipientsTest.php

@@ -2,9 +2,9 @@
 
 namespace Tests\Feature\Api;
 
-use App\Alias;
-use App\AliasRecipient;
-use App\Recipient;
+use App\Models\Alias;
+use App\Models\AliasRecipient;
+use App\Models\Recipient;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Tests\TestCase;
 
@@ -21,11 +21,11 @@ class AliasRecipientsTest extends TestCase
     /** @test */
     public function user_can_attach_recipient_to_alias()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -42,19 +42,19 @@ class AliasRecipientsTest extends TestCase
     /** @test */
     public function user_can_attach_multiple_recipients_to_alias()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipient1 = factory(Recipient::class)->create([
+        $recipient1 = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipient2 = factory(Recipient::class)->create([
+        $recipient2 = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipient3 = factory(Recipient::class)->create([
+        $recipient3 = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -70,11 +70,11 @@ class AliasRecipientsTest extends TestCase
     /** @test */
     public function user_can_update_existing_recipients_for_alias()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipient1 = factory(Recipient::class)->create([
+        $recipient1 = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -83,11 +83,11 @@ class AliasRecipientsTest extends TestCase
             'recipient' => $recipient1
         ]);
 
-        $recipient2 = factory(Recipient::class)->create([
+        $recipient2 = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipient3 = factory(Recipient::class)->create([
+        $recipient3 = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -103,11 +103,11 @@ class AliasRecipientsTest extends TestCase
     /** @test */
     public function user_cannot_attach_unverified_recipient_to_alias()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $unverifiedRecipient = factory(Recipient::class)->create([
+        $unverifiedRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email_verified_at' => null
         ]);
@@ -124,11 +124,11 @@ class AliasRecipientsTest extends TestCase
     /** @test */
     public function user_cannot_attach_more_than_allowed_recipients_to_alias()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipients = factory(Recipient::class, 11)->create([
+        $recipients = Recipient::factory()->count(11)->create([
             'user_id' => $this->user->id
         ]);
 

+ 17 - 17
tests/Feature/Api/AliasesTest.php

@@ -2,9 +2,9 @@
 
 namespace Tests\Feature\Api;
 
-use App\AdditionalUsername;
-use App\Alias;
-use App\Domain;
+use App\Models\AdditionalUsername;
+use App\Models\Alias;
+use App\Models\Domain;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Tests\TestCase;
 
@@ -22,7 +22,7 @@ class AliasesTest extends TestCase
     public function user_can_get_all_aliases()
     {
         // Arrange
-        factory(Alias::class, 3)->create([
+        Alias::factory()->count(3)->create([
             'user_id' => $this->user->id
         ]);
 
@@ -38,11 +38,11 @@ class AliasesTest extends TestCase
     public function user_can_get_all_aliases_including_deleted()
     {
         // Arrange
-        factory(Alias::class, 2)->create([
+        Alias::factory()->count(2)->create([
             'user_id' => $this->user->id
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'deleted_at' => now()
         ]);
@@ -59,12 +59,12 @@ class AliasesTest extends TestCase
     public function user_can_get_only_deleted_aliases()
     {
         // Arrange
-        factory(Alias::class, 2)->create([
+        Alias::factory()->count(2)->create([
             'user_id' => $this->user->id,
             'deleted_at' => now()
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -80,7 +80,7 @@ class AliasesTest extends TestCase
     public function user_can_get_individual_alias()
     {
         // Arrange
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -125,12 +125,12 @@ class AliasesTest extends TestCase
     /** @test */
     public function user_can_generate_new_alias_with_correct_aliasable_type()
     {
-        factory(AdditionalUsername::class)->create([
+        AdditionalUsername::factory()->create([
             'user_id' => $this->user->id,
             'username' => 'john'
         ]);
 
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id,
             'domain' => 'john.xyz',
             'domain_verified_at' => now()
@@ -143,14 +143,14 @@ class AliasesTest extends TestCase
 
         $response->assertStatus(201);
         $this->assertCount(1, $this->user->aliases);
-        $this->assertEquals('App\Domain', $response->getData()->data->aliasable_type);
+        $this->assertEquals('App\Models\Domain', $response->getData()->data->aliasable_type);
         $this->assertEquals($domain->id, $this->user->aliases[0]->aliasable_id);
     }
 
     /** @test */
     public function user_can_update_alias_description()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -165,7 +165,7 @@ class AliasesTest extends TestCase
     /** @test */
     public function user_can_delete_alias()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -178,7 +178,7 @@ class AliasesTest extends TestCase
     /** @test */
     public function user_can_restore_deleted_alias()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id,
             'deleted_at' => now()
         ]);
@@ -192,7 +192,7 @@ class AliasesTest extends TestCase
     /** @test */
     public function user_can_activate_alias()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id,
             'active' => false
         ]);
@@ -208,7 +208,7 @@ class AliasesTest extends TestCase
     /** @test */
     public function user_can_deactivate_alias()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id,
             'active' => true
         ]);

+ 2 - 2
tests/Feature/Api/ApiTokensTest.php

@@ -2,7 +2,7 @@
 
 namespace Tests\Feature\Api;
 
-use App\User;
+use App\Models\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Facades\DB;
 use Laravel\Passport\ClientRepository;
@@ -19,7 +19,7 @@ class ApiTokensTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create();
+        $this->user = User::factory()->create();
         Passport::actingAs($this->user, []);
         $this->user->recipients()->save($this->user->defaultRecipient);
 

+ 15 - 15
tests/Feature/Api/DomainsTest.php

@@ -2,8 +2,8 @@
 
 namespace Tests\Feature\Api;
 
-use App\Domain;
-use App\Recipient;
+use App\Models\Domain;
+use App\Models\Recipient;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Tests\TestCase;
 
@@ -21,7 +21,7 @@ class DomainsTest extends TestCase
     public function user_can_get_all_domains()
     {
         // Arrange
-        factory(Domain::class, 3)->create([
+        Domain::factory()->count(3)->create([
             'user_id' => $this->user->id
         ]);
 
@@ -37,7 +37,7 @@ class DomainsTest extends TestCase
     public function user_can_get_individual_domain()
     {
         // Arrange
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -64,7 +64,7 @@ class DomainsTest extends TestCase
     /** @test */
     public function user_can_not_create_the_same_domain()
     {
-        factory(Domain::class)->create([
+        Domain::factory()->create([
             'user_id' => $this->user->id,
             'domain' => 'example.com'
         ]);
@@ -129,7 +129,7 @@ class DomainsTest extends TestCase
     /** @test */
     public function user_can_activate_domain()
     {
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id,
             'active' => false
         ]);
@@ -145,7 +145,7 @@ class DomainsTest extends TestCase
     /** @test */
     public function user_can_deactivate_domain()
     {
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id,
             'active' => true
         ]);
@@ -159,7 +159,7 @@ class DomainsTest extends TestCase
     /** @test */
     public function user_can_update_domain_description()
     {
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -174,7 +174,7 @@ class DomainsTest extends TestCase
     /** @test */
     public function user_can_delete_domain()
     {
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -187,12 +187,12 @@ class DomainsTest extends TestCase
     /** @test */
     public function user_can_update_domain_default_recipient()
     {
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id,
             'domain_verified_at' => now()
         ]);
 
-        $newDefaultRecipient = factory(Recipient::class)->create([
+        $newDefaultRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -212,12 +212,12 @@ class DomainsTest extends TestCase
     /** @test */
     public function user_cannot_update_domain_default_recipient_with_unverified_recipient()
     {
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id,
             'domain_verified_at' => now()
         ]);
 
-        $newDefaultRecipient = factory(Recipient::class)->create([
+        $newDefaultRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email_verified_at' => null
         ]);
@@ -236,11 +236,11 @@ class DomainsTest extends TestCase
     /** @test */
     public function user_can_remove_domain_default_recipient()
     {
-        $defaultRecipient = factory(Recipient::class)->create([
+        $defaultRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id,
             'default_recipient_id' => $defaultRecipient->id,
             'domain_verified_at' => now(),

+ 12 - 12
tests/Feature/Api/RecipientsTest.php

@@ -2,7 +2,7 @@
 
 namespace Tests\Feature\Api;
 
-use App\Recipient;
+use App\Models\Recipient;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Tests\TestCase;
 
@@ -20,7 +20,7 @@ class RecipientsTest extends TestCase
     public function user_can_get_all_recipients()
     {
         // Arrange
-        factory(Recipient::class, 3)->create([
+        Recipient::factory()->count(3)->create([
             'user_id' => $this->user->id
         ]);
 
@@ -36,7 +36,7 @@ class RecipientsTest extends TestCase
     public function user_can_get_individual_recipient()
     {
         // Arrange
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -63,7 +63,7 @@ class RecipientsTest extends TestCase
     /** @test */
     public function user_can_not_create_the_same_recipient()
     {
-        factory(Recipient::class)->create([
+        Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'johndoe@example.com'
         ]);
@@ -80,7 +80,7 @@ class RecipientsTest extends TestCase
     /** @test */
     public function user_can_not_create_the_same_recipient_in_uppercase()
     {
-        factory(Recipient::class)->create([
+        Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'johndoe@example.com'
         ]);
@@ -123,7 +123,7 @@ class RecipientsTest extends TestCase
     /** @test */
     public function user_can_delete_recipient()
     {
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -153,7 +153,7 @@ class RecipientsTest extends TestCase
         $gnupg = new \gnupg();
         $gnupg->deletekey('26A987650243B28802524E2F809FD0D502E2F695');
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -168,7 +168,7 @@ class RecipientsTest extends TestCase
     /** @test */
     public function gpg_key_must_be_correct_format()
     {
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -184,7 +184,7 @@ class RecipientsTest extends TestCase
     /** @test */
     public function gpg_key_must_be_valid()
     {
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -202,7 +202,7 @@ class RecipientsTest extends TestCase
         $gnupg = new \gnupg();
         $gnupg->import(file_get_contents(base_path('tests/keys/AnonAddyPublicKey.asc')));
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'should_encrypt' => true,
             'fingerprint' => '26A987650243B28802524E2F809FD0D502E2F695'
@@ -218,7 +218,7 @@ class RecipientsTest extends TestCase
     /** @test */
     public function user_can_turn_on_encryption_for_recipient()
     {
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'should_encrypt' => false,
             'fingerprint' => '26A987650243B28802524E2F809FD0D502E2F695'
@@ -235,7 +235,7 @@ class RecipientsTest extends TestCase
     /** @test */
     public function user_can_turn_off_encryption_for_recipient()
     {
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'should_encrypt' => true,
             'fingerprint' => '26A987650243B28802524E2F809FD0D502E2F695'

+ 17 - 17
tests/Feature/Api/RulesTest.php

@@ -2,10 +2,10 @@
 
 namespace Tests\Feature\Api;
 
-use App\Alias;
-use App\EmailData;
 use App\Mail\ForwardEmail;
-use App\Rule;
+use App\Models\Alias;
+use App\Models\EmailData;
+use App\Models\Rule;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Str;
 use PhpMimeMailParser\Parser;
@@ -28,7 +28,7 @@ class RulesTest extends TestCase
     public function user_can_get_all_rules()
     {
         // Arrange
-        factory(Rule::class, 3)->create([
+        Rule::factory()->count(3)->create([
             'user_id' => $this->user->id
         ]);
 
@@ -44,7 +44,7 @@ class RulesTest extends TestCase
     public function user_can_get_individual_rule()
     {
         // Arrange
-        $rule = factory(Rule::class)->create([
+        $rule = Rule::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -127,7 +127,7 @@ class RulesTest extends TestCase
     /** @test */
     public function user_can_update_rule()
     {
-        $rule = factory(Rule::class)->create([
+        $rule = Rule::factory()->create([
             'user_id' => $this->user->id,
             'operator' => 'AND'
         ]);
@@ -160,7 +160,7 @@ class RulesTest extends TestCase
     /** @test */
     public function user_can_delete_rule()
     {
-        $rule = factory(Rule::class)->create([
+        $rule = Rule::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -173,7 +173,7 @@ class RulesTest extends TestCase
     /** @test */
     public function user_can_activate_rule()
     {
-        $rule = factory(Rule::class)->create([
+        $rule = Rule::factory()->create([
             'user_id' => $this->user->id,
             'active' => false
         ]);
@@ -189,7 +189,7 @@ class RulesTest extends TestCase
     /** @test */
     public function user_can_deactivate_rule()
     {
-        $rule = factory(Rule::class)->create([
+        $rule = Rule::factory()->create([
             'user_id' => $this->user->id,
             'active' => true
         ]);
@@ -203,7 +203,7 @@ class RulesTest extends TestCase
     /** @test */
     public function it_can_apply_user_rules()
     {
-        factory(Rule::class)->create([
+        Rule::factory()->create([
             'user_id' => $this->user->id,
             'conditions' => [
                 [
@@ -237,7 +237,7 @@ class RulesTest extends TestCase
             'operator' => 'AND',
         ]);
 
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
@@ -260,7 +260,7 @@ class RulesTest extends TestCase
     /** @test */
     public function it_can_apply_user_rules_in_correct_order()
     {
-        factory(Rule::class)->create([
+        Rule::factory()->create([
             'user_id' => $this->user->id,
             'conditions' => [
                 [
@@ -281,7 +281,7 @@ class RulesTest extends TestCase
             'order' => 1
         ]);
 
-        factory(Rule::class)->create([
+        Rule::factory()->create([
             'user_id' => $this->user->id,
             'conditions' => [
                 [
@@ -315,7 +315,7 @@ class RulesTest extends TestCase
             'operator' => 'AND',
         ]);
 
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
@@ -338,17 +338,17 @@ class RulesTest extends TestCase
     /** @test */
     public function user_can_reorder_rules()
     {
-        $ruleOne = factory(Rule::class)->create([
+        $ruleOne = Rule::factory()->create([
             'user_id' => $this->user->id,
             'order' => 2
         ]);
 
-        $ruleTwo = factory(Rule::class)->create([
+        $ruleTwo = Rule::factory()->create([
             'user_id' => $this->user->id,
             'order' => 0
         ]);
 
-        $ruleThree = factory(Rule::class)->create([
+        $ruleThree = Rule::factory()->create([
             'user_id' => $this->user->id,
             'order' => 1
         ]);

+ 2 - 2
tests/Feature/LoginTest.php

@@ -2,8 +2,8 @@
 
 namespace Tests\Feature;
 
+use App\Models\User;
 use App\Notifications\UsernameReminder;
-use App\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Facades\Hash;
 use Illuminate\Support\Facades\Notification;
@@ -20,7 +20,7 @@ class LoginTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create([
+        $this->user = User::factory()->create([
             'username' => 'johndoe',
             'password' => Hash::make('mypassword')
         ]);

+ 34 - 34
tests/Feature/ReceiveEmailTest.php

@@ -2,14 +2,14 @@
 
 namespace Tests\Feature;
 
-use App\AdditionalUsername;
-use App\Alias;
-use App\AliasRecipient;
-use App\Domain;
 use App\Mail\ForwardEmail;
+use App\Models\AdditionalUsername;
+use App\Models\Alias;
+use App\Models\AliasRecipient;
+use App\Models\Domain;
+use App\Models\Recipient;
+use App\Models\User;
 use App\Notifications\NearBandwidthLimit;
-use App\Recipient;
-use App\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Mail;
@@ -26,7 +26,7 @@ class ReceiveEmailTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create(['username' => 'johndoe']);
+        $this->user = User::factory()->create(['username' => 'johndoe']);
         $this->user->recipients()->save($this->user->defaultRecipient);
     }
 
@@ -218,7 +218,7 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
@@ -265,7 +265,7 @@ class ReceiveEmailTest extends TestCase
             'anonaddy.admin_username' => 'random'
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'id' => $uuid,
             'user_id' => $this->user->id,
             'email' => $uuid.'@anonaddy.me',
@@ -315,7 +315,7 @@ class ReceiveEmailTest extends TestCase
             'anonaddy.admin_username' => 'random'
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'email' => $localPart.'@anonaddy.me',
             'local_part' => $localPart,
@@ -358,19 +358,19 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
             'domain' => 'johndoe.'.config('anonaddy.domain'),
         ]);
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'one@example.com'
         ]);
 
-        $recipient2 = factory(Recipient::class)->create([
+        $recipient2 = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'two@example.com'
         ]);
@@ -419,12 +419,12 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'one@example.com'
         ]);
 
-        $recipient2 = factory(Recipient::class)->create([
+        $recipient2 = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'two@example.com'
         ]);
@@ -464,13 +464,13 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        factory(Recipient::class)->create([
+        Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'one@example.com',
             'email_verified_at' => null
         ]);
 
-        $verifiedRecipient = factory(Recipient::class)->create([
+        $verifiedRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'two@example.com'
         ]);
@@ -541,7 +541,7 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'id' => '8f36380f-df4e-4875-bb12-9c4448573712',
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
@@ -549,7 +549,7 @@ class ReceiveEmailTest extends TestCase
             'domain' => 'johndoe.'.config('anonaddy.domain')
         ]);
 
-        factory(Recipient::class)->create([
+        Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'will@anonaddy.com'
         ]);
@@ -593,7 +593,7 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'id' => '8f36380f-df4e-4875-bb12-9c4448573712',
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
@@ -601,7 +601,7 @@ class ReceiveEmailTest extends TestCase
             'domain' => 'johndoe.'.config('anonaddy.domain')
         ]);
 
-        factory(Recipient::class)->create([
+        Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'will@anonaddy.com'
         ]);
@@ -652,7 +652,7 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'id' => '8f36380f-df4e-4875-bb12-9c4448573712',
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
@@ -735,7 +735,7 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id,
             'domain' => 'example.com',
             'domain_verified_at' => now()
@@ -756,7 +756,7 @@ class ReceiveEmailTest extends TestCase
 
         $this->assertDatabaseHas('aliases', [
             'aliasable_id' => $domain->id,
-            'aliasable_type' => 'App\Domain',
+            'aliasable_type' => 'App\Models\Domain',
             'email' => 'ebay@example.com',
             'local_part' => 'ebay',
             'domain' => 'example.com',
@@ -777,7 +777,7 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id,
             'domain' => 'example.com',
             'domain_verified_at' => now(),
@@ -799,7 +799,7 @@ class ReceiveEmailTest extends TestCase
 
         $this->assertDatabaseHas('aliases', [
             'aliasable_id' => $domain->id,
-            'aliasable_type' => 'App\Domain',
+            'aliasable_type' => 'App\Models\Domain',
             'email' => 'ebay@example.com',
             'local_part' => 'ebay',
             'domain' => 'example.com',
@@ -820,7 +820,7 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $additionalUsername = factory(AdditionalUsername::class)->create([
+        $additionalUsername = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id,
             'username' => 'janedoe'
         ]);
@@ -840,7 +840,7 @@ class ReceiveEmailTest extends TestCase
 
         $this->assertDatabaseHas('aliases', [
             'aliasable_id' => $additionalUsername->id,
-            'aliasable_type' => 'App\AdditionalUsername',
+            'aliasable_type' => 'App\Models\AdditionalUsername',
             'email' => 'ebay@janedoe.anonaddy.com',
             'local_part' => 'ebay',
             'domain' => 'janedoe.anonaddy.com',
@@ -974,11 +974,11 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id,
             'default_recipient_id' => $recipient->id,
             'domain' => 'example.com',
@@ -1000,7 +1000,7 @@ class ReceiveEmailTest extends TestCase
 
         $this->assertDatabaseHas('aliases', [
             'aliasable_id' => $domain->id,
-            'aliasable_type' => 'App\Domain',
+            'aliasable_type' => 'App\Models\Domain',
             'email' => 'ebay@example.com',
             'local_part' => 'ebay',
             'domain' => 'example.com',
@@ -1021,11 +1021,11 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $additionalUsername = factory(AdditionalUsername::class)->create([
+        $additionalUsername = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id,
             'default_recipient_id' => $recipient->id,
             'username' => 'janedoe'
@@ -1046,7 +1046,7 @@ class ReceiveEmailTest extends TestCase
 
         $this->assertDatabaseHas('aliases', [
             'aliasable_id' => $additionalUsername->id,
-            'aliasable_type' => 'App\AdditionalUsername',
+            'aliasable_type' => 'App\Models\AdditionalUsername',
             'email' => 'ebay@janedoe.anonaddy.com',
             'local_part' => 'ebay',
             'domain' => 'janedoe.anonaddy.com',

+ 9 - 9
tests/Feature/RegistrationTest.php

@@ -2,10 +2,10 @@
 
 namespace Tests\Feature;
 
-use App\AdditionalUsername;
-use App\DeletedUsername;
-use App\Recipient;
-use App\User;
+use App\Models\AdditionalUsername;
+use App\Models\DeletedUsername;
+use App\Models\Recipient;
+use App\Models\User;
 use Illuminate\Auth\Notifications\VerifyEmail;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Carbon;
@@ -68,7 +68,7 @@ class RegistrationTest extends TestCase
     /** @test */
     public function user_can_verify_email_successfully()
     {
-        $user = factory(User::class)->create();
+        $user = User::factory()->create();
         $user->email_verified_at = null;
         $user->save();
 
@@ -129,9 +129,9 @@ class RegistrationTest extends TestCase
     /** @test */
     public function user_cannot_register_with_existing_email()
     {
-        $user = factory(User::class)->create(['username' => 'johndoe']);
+        $user = User::factory()->create(['username' => 'johndoe']);
 
-        factory(Recipient::class)->create([
+        Recipient::factory()->create([
             'user_id' => $user->id,
             'email' => 'johndoe@example.com'
         ]);
@@ -150,7 +150,7 @@ class RegistrationTest extends TestCase
     /** @test */
     public function user_cannot_register_with_existing_username()
     {
-        factory(User::class)->create(['username' => 'johndoe']);
+        User::factory()->create(['username' => 'johndoe']);
 
         $response = $this->post('/register', [
             'username' => 'johndoe',
@@ -166,7 +166,7 @@ class RegistrationTest extends TestCase
     /** @test */
     public function user_cannot_register_with_existing_additional_username()
     {
-        factory(AdditionalUsername::class)->create(['username' => 'johndoe']);
+        AdditionalUsername::factory()->create(['username' => 'johndoe']);
 
         $response = $this->post('/register', [
             'username' => 'johndoe',

+ 8 - 8
tests/Feature/ReplyToEmailTest.php

@@ -2,10 +2,10 @@
 
 namespace Tests\Feature;
 
-use App\Alias;
 use App\Mail\ReplyToEmail;
-use App\Recipient;
-use App\User;
+use App\Models\Alias;
+use App\Models\Recipient;
+use App\Models\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Facades\Mail;
 use Tests\TestCase;
@@ -20,7 +20,7 @@ class ReplyToEmailTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create(['username' => 'johndoe']);
+        $this->user = User::factory()->create(['username' => 'johndoe']);
         $this->user->recipients()->save($this->user->defaultRecipient);
     }
 
@@ -31,7 +31,7 @@ class ReplyToEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $alias = factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
@@ -67,14 +67,14 @@ class ReplyToEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $alias = factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
             'domain' => 'johndoe.'.config('anonaddy.domain'),
         ]);
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email_verified_at' => null
         ]);
@@ -108,7 +108,7 @@ class ReplyToEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $alias = factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',

+ 5 - 5
tests/Feature/SendFromEmailTest.php

@@ -2,9 +2,9 @@
 
 namespace Tests\Feature;
 
-use App\Alias;
 use App\Mail\SendFromEmail;
-use App\User;
+use App\Models\Alias;
+use App\Models\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Facades\Mail;
 use Tests\TestCase;
@@ -19,7 +19,7 @@ class SendFromEmailTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create(['username' => 'johndoe']);
+        $this->user = User::factory()->create(['username' => 'johndoe']);
         $this->user->recipients()->save($this->user->defaultRecipient);
     }
 
@@ -30,7 +30,7 @@ class SendFromEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $alias = factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
@@ -66,7 +66,7 @@ class SendFromEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',

+ 24 - 24
tests/Feature/SettingsTest.php

@@ -2,14 +2,14 @@
 
 namespace Tests\Feature;
 
-use App\AdditionalUsername;
-use App\Alias;
-use App\AliasRecipient;
-use App\DeletedUsername;
-use App\Domain;
 use App\Exports\AliasesExport;
-use App\Recipient;
-use App\User;
+use App\Models\AdditionalUsername;
+use App\Models\Alias;
+use App\Models\AliasRecipient;
+use App\Models\DeletedUsername;
+use App\Models\Domain;
+use App\Models\Recipient;
+use App\Models\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Facades\Hash;
 use Maatwebsite\Excel\Facades\Excel;
@@ -25,7 +25,7 @@ class SettingsTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create();
+        $this->user = User::factory()->create();
         $this->actingAs($this->user);
         $this->user->recipients()->save($this->user->defaultRecipient);
     }
@@ -33,7 +33,7 @@ class SettingsTest extends TestCase
     /** @test */
     public function user_can_update_default_recipient()
     {
-        $newDefaultRecipient = factory(Recipient::class)->create([
+        $newDefaultRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -53,7 +53,7 @@ class SettingsTest extends TestCase
     /** @test */
     public function user_cannot_update_to_unverified_default_recipient()
     {
-        $newDefaultRecipient = factory(Recipient::class)->create([
+        $newDefaultRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email_verified_at' => null
         ]);
@@ -221,18 +221,18 @@ class SettingsTest extends TestCase
             $this->fail('Password does not match');
         }
 
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $uuidAlias = factory(Alias::class)->create([
+        $uuidAlias = Alias::factory()->create([
             'user_id' => $this->user->id,
             'domain' => 'anonaddy.me'
         ]);
         $uuidAlias->update(['local_part' => $uuidAlias->id]);
 
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -241,24 +241,24 @@ class SettingsTest extends TestCase
             'recipient' => $recipient
         ]);
 
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $aliasWithCustomDomain = factory(Alias::class)->create([
+        $aliasWithCustomDomain = Alias::factory()->create([
             'user_id' => $this->user->id,
             'aliasable_id' => $domain->id,
-            'aliasable_type' => 'App\Domain'
+            'aliasable_type' => 'App\Models\Domain'
         ]);
 
-        $additionalUsername = factory(AdditionalUsername::class)->create([
+        $additionalUsername = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $aliasWithAdditionalUsername = factory(Alias::class)->create([
+        $aliasWithAdditionalUsername = Alias::factory()->create([
             'user_id' => $this->user->id,
             'aliasable_id' => $additionalUsername->id,
-            'aliasable_type' => 'App\AdditionaUsername'
+            'aliasable_type' => 'App\Models\AdditionaUsername'
         ]);
 
         $response = $this->post('/settings/account', [
@@ -292,14 +292,14 @@ class SettingsTest extends TestCase
             'id' => $aliasWithCustomDomain->id,
             'user_id' => $this->user->id,
             'aliasable_id' => $domain->id,
-            'aliasable_type' => 'App\Domain'
+            'aliasable_type' => 'App\Models\Domain'
         ]);
 
         $this->assertDatabaseMissing('aliases', [
             'id' => $aliasWithAdditionalUsername->id,
             'user_id' => $this->user->id,
             'aliasable_id' => $additionalUsername->id,
-            'aliasable_type' => 'App\AdditionalUsername'
+            'aliasable_type' => 'App\Models\AdditionalUsername'
         ]);
 
         $this->assertDatabaseMissing('recipients', [
@@ -354,17 +354,17 @@ class SettingsTest extends TestCase
     {
         Excel::fake();
 
-        factory(Alias::class, 3)->create([
+        Alias::factory()->count(3)->create([
             'user_id' => $this->user->id
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'deleted_at' => now(),
             'active' => false
         ]);
 
-        factory(Alias::class)->create();
+        Alias::factory()->create();
 
         $this->actingAs($this->user)
             ->get('/settings/aliases/export');

+ 7 - 7
tests/Feature/ShowAdditionalUsernamesTest.php

@@ -2,8 +2,8 @@
 
 namespace Tests\Feature;
 
-use App\AdditionalUsername;
-use App\User;
+use App\Models\AdditionalUsername;
+use App\Models\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Carbon;
 use Tests\TestCase;
@@ -18,14 +18,14 @@ class AdditionalUsernamesTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create();
+        $this->user = User::factory()->create();
         $this->actingAs($this->user);
     }
 
     /** @test */
     public function user_can_view_usernames_from_the_usernames_page()
     {
-        $usernames = factory(AdditionalUsername::class, 3)->create([
+        $usernames = AdditionalUsername::factory()->count(3)->create([
             'user_id' => $this->user->id
         ]);
 
@@ -39,15 +39,15 @@ class AdditionalUsernamesTest extends TestCase
     /** @test */
     public function latest_usernames_are_listed_first()
     {
-        $a = factory(AdditionalUsername::class)->create([
+        $a = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(15)
         ]);
-        $b = factory(AdditionalUsername::class)->create([
+        $b = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(5)
         ]);
-        $c = factory(AdditionalUsername::class)->create([
+        $c = AdditionalUsername::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(10)
         ]);

+ 16 - 16
tests/Feature/ShowAliasesTest.php

@@ -2,10 +2,10 @@
 
 namespace Tests\Feature;
 
-use App\Alias;
-use App\AliasRecipient;
-use App\Recipient;
-use App\User;
+use App\Models\Alias;
+use App\Models\AliasRecipient;
+use App\Models\Recipient;
+use App\Models\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Carbon;
 use Tests\TestCase;
@@ -20,7 +20,7 @@ class AliasesTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create();
+        $this->user = User::factory()->create();
         $this->actingAs($this->user);
     }
 
@@ -28,7 +28,7 @@ class AliasesTest extends TestCase
     public function user_can_view_aliases_from_the_dashboard()
     {
         // Arrange
-        $aliases = factory(Alias::class, 3)->create([
+        $aliases = Alias::factory()->count(3)->create([
             'user_id' => $this->user->id
         ]);
 
@@ -45,15 +45,15 @@ class AliasesTest extends TestCase
     public function latest_aliases_are_listed_first()
     {
         // Arrange
-        $a = factory(Alias::class)->create([
+        $a = Alias::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(15)
         ]);
-        $b = factory(Alias::class)->create([
+        $b = Alias::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(5)
         ]);
-        $c = factory(Alias::class)->create([
+        $c = Alias::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(10)
         ]);
@@ -72,11 +72,11 @@ class AliasesTest extends TestCase
     /** @test */
     public function deleted_aliases_are_not_listed()
     {
-        factory(Alias::class, 3)->create([
+        Alias::factory()->count(3)->create([
             'user_id' => $this->user->id
         ]);
 
-        factory(Alias::class, 2)->create([
+        Alias::factory()->count(2)->create([
             'user_id' => $this->user->id,
             'deleted_at' => Carbon::now()->subDays(5)
         ]);
@@ -90,11 +90,11 @@ class AliasesTest extends TestCase
     /** @test */
     public function aliases_are_listed_with_recipients()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -113,15 +113,15 @@ class AliasesTest extends TestCase
     /** @test */
     public function aliases_are_listed_with_only_verified_recipient_options()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $unverifiedRecipient = factory(Recipient::class)->create([
+        $unverifiedRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email_verified_at' => null
         ]);

+ 8 - 8
tests/Feature/ShowDomainsTest.php

@@ -2,8 +2,8 @@
 
 namespace Tests\Feature;
 
-use App\Domain;
-use App\User;
+use App\Models\Domain;
+use App\Models\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Carbon;
 use Tests\TestCase;
@@ -18,14 +18,14 @@ class DomainsTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create();
+        $this->user = User::factory()->create();
         $this->actingAs($this->user);
     }
 
     /** @test */
     public function user_can_view_domains_from_the_domains_page()
     {
-        $domains = factory(Domain::class, 3)->create([
+        $domains = Domain::factory()->count(3)->create([
             'user_id' => $this->user->id
         ]);
 
@@ -39,15 +39,15 @@ class DomainsTest extends TestCase
     /** @test */
     public function latest_domains_are_listed_first()
     {
-        $a = factory(Domain::class)->create([
+        $a = Domain::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(15)
         ]);
-        $b = factory(Domain::class)->create([
+        $b = Domain::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(5)
         ]);
-        $c = factory(Domain::class)->create([
+        $c = Domain::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(10)
         ]);
@@ -64,7 +64,7 @@ class DomainsTest extends TestCase
     /** @test */
     public function user_can_verify_domain_sending_records()
     {
-        $domain = factory(Domain::class)->create([
+        $domain = Domain::factory()->create([
             'user_id' => $this->user->id,
             'domain' => 'example.com'
         ]);

+ 14 - 14
tests/Feature/ShowRecipientsTest.php

@@ -2,10 +2,10 @@
 
 namespace Tests\Feature;
 
-use App\Alias;
-use App\AliasRecipient;
-use App\Recipient;
-use App\User;
+use App\Models\Alias;
+use App\Models\AliasRecipient;
+use App\Models\Recipient;
+use App\Models\User;
 use Illuminate\Auth\Notifications\VerifyEmail;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Illuminate\Support\Carbon;
@@ -24,14 +24,14 @@ class RecipientsTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create();
+        $this->user = User::factory()->create();
         $this->actingAs($this->user);
     }
 
     /** @test */
     public function user_can_view_recipients_from_the_recipients_page()
     {
-        $recipients = factory(Recipient::class, 5)->create([
+        $recipients = Recipient::factory()->count(5)->create([
             'user_id' => $this->user->id
         ]);
 
@@ -45,15 +45,15 @@ class RecipientsTest extends TestCase
     /** @test */
     public function latest_recipients_are_listed_first()
     {
-        $a = factory(Recipient::class)->create([
+        $a = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(15)
         ]);
-        $b = factory(Recipient::class)->create([
+        $b = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(5)
         ]);
-        $c = factory(Recipient::class)->create([
+        $c = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'created_at' => Carbon::now()->subDays(10)
         ]);
@@ -70,11 +70,11 @@ class RecipientsTest extends TestCase
     /** @test */
     public function recipients_are_listed_with_aliases_count()
     {
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        factory(Alias::class, 3)->create(['user_id' => $this->user->id])
+        Alias::factory()->count(3)->create(['user_id' => $this->user->id])
         ->each(function ($alias) use ($recipient) {
             AliasRecipient::create([
                 'alias' => $alias,
@@ -96,7 +96,7 @@ class RecipientsTest extends TestCase
 
         Notification::assertNothingSent();
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email_verified_at' => null
         ]);
@@ -116,7 +116,7 @@ class RecipientsTest extends TestCase
     /** @test */
     public function user_can_verify_recipient_email_successfully()
     {
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email_verified_at' => null
         ]);
@@ -148,7 +148,7 @@ class RecipientsTest extends TestCase
 
         Notification::assertNothingSent();
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email_verified_at' => null
         ]);

+ 2 - 2
tests/TestCase.php

@@ -2,7 +2,7 @@
 
 namespace Tests;
 
-use App\User;
+use App\Models\User;
 use Illuminate\Database\Eloquent\Collection as EloquentCollection;
 use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
 use Illuminate\Support\Facades\DB;
@@ -43,7 +43,7 @@ abstract class TestCase extends BaseTestCase
 
     protected function setUpPassport(): void
     {
-        $this->user = factory(User::class)->create();
+        $this->user = User::factory()->create();
         Passport::actingAs($this->user, []);
 
         $clientRepository = new ClientRepository();

+ 18 - 18
tests/Unit/AliasTest.php

@@ -2,10 +2,10 @@
 
 namespace Tests\Unit;
 
-use App\Alias;
-use App\AliasRecipient;
-use App\Recipient;
-use App\User;
+use App\Models\Alias;
+use App\Models\AliasRecipient;
+use App\Models\Recipient;
+use App\Models\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Tests\TestCase;
 
@@ -19,22 +19,22 @@ class AliasTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create();
+        $this->user = User::factory()->create();
         $this->user->recipients()->save($this->user->defaultRecipient);
     }
 
     /** @test */
     public function alias_can_get_verified_recipients()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $verifiedRecipient = factory(Recipient::class)->create([
+        $verifiedRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $unverifiedRecipient = factory(Recipient::class)->create([
+        $unverifiedRecipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email_verified_at' => null
         ]);
@@ -57,11 +57,11 @@ class AliasTest extends TestCase
     /** @test */
     public function alias_can_set_default_recipient_email()
     {
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'default@example.com'
         ]);
@@ -75,11 +75,11 @@ class AliasTest extends TestCase
     /** @test */
     public function alias_can_get_default_recipient_email()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'default@example.com'
         ]);
@@ -97,39 +97,39 @@ class AliasTest extends TestCase
     /** @test */
     public function alias_can_get_verified_recipients_or_default()
     {
-        $alias = factory(Alias::class)->create([
+        $alias = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $recipientOne = factory(Recipient::class)->create([
+        $recipientOne = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'one@example.com',
             'should_encrypt' => true,
             'fingerprint' => 'ABCDE'
         ]);
 
-        $recipientTwo = factory(Recipient::class)->create([
+        $recipientTwo = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'two@example.com',
             'should_encrypt' => true,
             'fingerprint' => 'ABCDE'
         ]);
 
-        $recipientThree = factory(Recipient::class)->create([
+        $recipientThree = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'three@example.com',
             'should_encrypt' => false,
             'fingerprint' => 'ABCDE'
         ]);
 
-        $recipientFour = factory(Recipient::class)->create([
+        $recipientFour = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'four@example.com',
             'should_encrypt' => true,
             'fingerprint' => null
         ]);
 
-        $recipientFive = factory(Recipient::class)->create([
+        $recipientFive = Recipient::factory()->create([
             'user_id' => $this->user->id,
             'email' => 'five@example.com',
             'should_encrypt' => false,

+ 22 - 22
tests/Unit/UserTest.php

@@ -2,10 +2,10 @@
 
 namespace Tests\Unit;
 
-use App\Alias;
-use App\AliasRecipient;
-use App\Recipient;
-use App\User;
+use App\Models\Alias;
+use App\Models\AliasRecipient;
+use App\Models\Recipient;
+use App\Models\User;
 use Illuminate\Foundation\Testing\RefreshDatabase;
 use Tests\TestCase;
 
@@ -19,14 +19,14 @@ class UserTest extends TestCase
     {
         parent::setUp();
 
-        $this->user = factory(User::class)->create();
+        $this->user = User::factory()->create();
         $this->user->recipients()->save($this->user->defaultRecipient);
     }
 
     /** @test */
     public function user_can_get_aliases_from_relationship()
     {
-        $aliases = factory(Alias::class, 10)->create([
+        $aliases = Alias::factory()->count(10)->create([
             'user_id' => $this->user->id
         ]);
 
@@ -36,11 +36,11 @@ class UserTest extends TestCase
     /** @test */
     public function user_can_only_get_their_own_aliases_from_relationship()
     {
-        $aliases = factory(Alias::class, 5)->create([
+        $aliases = Alias::factory()->count(5)->create([
             'user_id' => $this->user->id
         ]);
 
-        factory(Alias::class, 10)->create();
+        Alias::factory()->count(10)->create();
 
         $aliases->assertEquals($this->user->aliases);
     }
@@ -48,18 +48,18 @@ class UserTest extends TestCase
     /** @test */
     public function user_can_get_total_emails_forwarded()
     {
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'emails_forwarded' => 5
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'emails_forwarded' => 3,
             'deleted_at' => now()
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'emails_forwarded' => 2,
             'active' => false
@@ -71,18 +71,18 @@ class UserTest extends TestCase
     /** @test */
     public function user_can_get_total_emails_blocked()
     {
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'emails_blocked' => 3
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'emails_blocked' => 4,
             'deleted_at' => now()
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'emails_blocked' => 1,
             'active' => false
@@ -94,18 +94,18 @@ class UserTest extends TestCase
     /** @test */
     public function user_can_get_total_emails_replied()
     {
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'emails_replied' => 2
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'emails_replied' => 4,
             'deleted_at' => now()
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'emails_replied' => 1,
             'active' => false
@@ -117,11 +117,11 @@ class UserTest extends TestCase
     /** @test */
     public function user_can_get_aliases_using_default_recipient()
     {
-        $recipient = factory(Recipient::class)->create([
+        $recipient = Recipient::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        $aliasNotUsingDefault = factory(Alias::class)->create([
+        $aliasNotUsingDefault = Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
@@ -130,16 +130,16 @@ class UserTest extends TestCase
             'recipient' => $recipient
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'deleted_at' => now()
         ]);
 
-        factory(Alias::class)->create([
+        Alias::factory()->create([
             'user_id' => $this->user->id,
             'active' => false
         ]);

部分文件因为文件数量过多而无法显示