]> BookStack Code Mirror - bookstack/commitdiff
Updated failing tests, Applied StyleCI changes
authorDan Brown <redacted>
Sat, 18 Dec 2021 16:41:42 +0000 (16:41 +0000)
committerDan Brown <redacted>
Sat, 18 Dec 2021 16:41:42 +0000 (16:41 +0000)
app/Console/Commands/CreateAdmin.php
database/factories/Auth/UserFactory.php
tests/TestEmailTest.php
tests/Uploads/AvatarTest.php

index 48da87af4f379deaff2b16f09294769f2ad33297..8c273bc1ff416ee5f6c5e1607d25a16e4733b002 100644 (file)
@@ -48,7 +48,6 @@ class CreateAdmin extends Command
      */
     public function handle()
     {
-
         $details = $this->options();
 
         if (empty($details['email'])) {
@@ -62,8 +61,8 @@ class CreateAdmin extends Command
         }
 
         $validator = Validator::make($details, [
-            'email' => ['required', 'email', 'min:5', new Unique('users', 'email')],
-            'name' => ['required', 'min:2'],
+            'email'    => ['required', 'email', 'min:5', new Unique('users', 'email')],
+            'name'     => ['required', 'min:2'],
             'password' => ['required', Password::default()],
         ]);
 
@@ -71,6 +70,7 @@ class CreateAdmin extends Command
             foreach ($validator->errors()->all() as $error) {
                 $this->error($error);
             }
+
             return SymfonyCommand::FAILURE;
         }
 
index 77d63ac68cdb57bc3a39344ef1a365348cb502dd..805782fd809891b7ba1fdbf06ceb771a59c5be41 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Database\Factories\Auth;
 
+use BookStack\Auth\User;
 use Illuminate\Database\Eloquent\Factories\Factory;
 use Illuminate\Support\Str;
 
@@ -12,7 +13,7 @@ class UserFactory extends Factory
      *
      * @var string
      */
-    protected $model = \BookStack\Auth\User::class;
+    protected $model = User::class;
 
     /**
      * Define the model's default state.
@@ -26,7 +27,7 @@ class UserFactory extends Factory
         return [
             'name'            => $name,
             'email'           => $this->faker->email,
-            'slug'            => \Illuminate\Support\Str::slug($name . '-' . \Illuminate\Support\Str::random(5)),
+            'slug'            => Str::slug($name . '-' . Str::random(5)),
             'password'        => Str::random(10),
             'remember_token'  => Str::random(10),
             'email_confirmed' => 1,
index 0a2091fe3e92bc0dd018acc216087b107e37e7a1..e0350371afe00707ce8eb87f6597018e3f94f424 100644 (file)
@@ -34,7 +34,7 @@ class TestEmailTest extends TestCase
         $this->app[Dispatcher::class] = $mockDispatcher;
 
         $exception = new \Exception('A random error occurred when testing an email');
-        $mockDispatcher->shouldReceive('send')->andThrow($exception);
+        $mockDispatcher->shouldReceive('sendNow')->andThrow($exception);
 
         $admin = $this->getAdmin();
         $sendReq = $this->actingAs($admin)->post('/settings/maintenance/send-test-email');
index d10b5cfc6cb79f50556df9892a94edc97c5c0d82..650f5b4ea359ac5dd02929c9780cb67a13031157 100644 (file)
@@ -11,16 +11,16 @@ class AvatarTest extends TestCase
 {
     use UsesImages;
 
-    protected function createUserRequest($user)
+    protected function createUserRequest($user): User
     {
         $this->asAdmin()->post('/settings/users/create', [
             'name'             => $user->name,
             'email'            => $user->email,
-            'password'         => 'testing',
-            'password-confirm' => 'testing',
+            'password'         => 'testing101',
+            'password-confirm' => 'testing101',
         ]);
 
-        return User::where('email', '=', $user->email)->first();
+        return User::query()->where('email', '=', $user->email)->first();
     }
 
     protected function assertImageFetchFrom(string $url)