From f835a7538c13172c8d7d9209d9fbf916777d4ab9 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Tue, 13 Dec 2022 19:00:43 +0100 Subject: [PATCH] Tests: Improved execution time, test more factories --- db/factories/User/UserFactory.php | 2 +- tests/Unit/FactoriesTest.php | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/db/factories/User/UserFactory.php b/db/factories/User/UserFactory.php index fb021c41..0f211297 100644 --- a/db/factories/User/UserFactory.php +++ b/db/factories/User/UserFactory.php @@ -17,7 +17,7 @@ class UserFactory extends Factory { return [ 'name' => $this->faker->unique()->userName(), - 'password' => password_hash($this->faker->password(), PASSWORD_DEFAULT), + 'password' => crypt(random_bytes(16), '$1$salt$'), 'email' => $this->faker->unique()->safeEmail(), 'api_key' => bin2hex(random_bytes(32)), ]; diff --git a/tests/Unit/FactoriesTest.php b/tests/Unit/FactoriesTest.php index c5f8a89f..d256876a 100644 --- a/tests/Unit/FactoriesTest.php +++ b/tests/Unit/FactoriesTest.php @@ -2,13 +2,17 @@ namespace Engelsystem\Test\Unit; +use Engelsystem\Models\AngelType; use Engelsystem\Models\Faq; +use Engelsystem\Models\Group; use Engelsystem\Models\Message; use Engelsystem\Models\News; use Engelsystem\Models\NewsComment; +use Engelsystem\Models\Privilege; use Engelsystem\Models\Question; use Engelsystem\Models\Room; use Engelsystem\Models\Shifts\Schedule; +use Engelsystem\Models\Shifts\ShiftType; use Engelsystem\Models\User\Contact; use Engelsystem\Models\User\License; use Engelsystem\Models\User\PasswordReset; @@ -16,6 +20,7 @@ use Engelsystem\Models\User\PersonalData; use Engelsystem\Models\User\Settings; use Engelsystem\Models\User\State; use Engelsystem\Models\User\User; +use Engelsystem\Models\UserAngelType; use Engelsystem\Models\Worklog; use Illuminate\Database\Eloquent\Model; @@ -24,21 +29,26 @@ class FactoriesTest extends TestCase use HasDatabase; /** @var string[] */ - protected $models = [ + protected array $models = [ + AngelType::class, Contact::class, Faq::class, + Group::class, License::class, Message::class, News::class, NewsComment::class, PasswordReset::class, PersonalData::class, + Privilege::class, Question::class, Room::class, Schedule::class, Settings::class, + ShiftType::class, State::class, User::class, + UserAngelType::class, Worklog::class, ]; @@ -61,7 +71,7 @@ class FactoriesTest extends TestCase * @covers \Database\Factories\Engelsystem\Models\User\UserFactory * @covers \Database\Factories\Engelsystem\Models\WorklogFactory */ - public function testFactories() + public function testFactories(): void { $this->initDatabase(); @@ -74,7 +84,7 @@ class FactoriesTest extends TestCase /** * @covers \Database\Factories\Engelsystem\Models\User\StateFactory */ - public function testStateFactoryArrived() + public function testStateFactoryArrived(): void { $this->initDatabase();