Tests: Improved execution time, test more factories

This commit is contained in:
Igor Scheller 2022-12-13 19:00:43 +01:00
parent 93b30dcbdf
commit f835a7538c
2 changed files with 14 additions and 4 deletions

View File

@ -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)),
];

View File

@ -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();