2021-07-10 00:59:20 +02:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-07-10 00:59:20 +02:00
|
|
|
namespace Engelsystem\Test\Unit;
|
|
|
|
|
2023-11-06 23:50:07 +01:00
|
|
|
use Engelsystem\Models\AngelType;
|
2021-07-10 00:59:20 +02:00
|
|
|
use Engelsystem\Models\Faq;
|
2023-11-06 23:50:07 +01:00
|
|
|
use Engelsystem\Models\Group;
|
2021-07-10 00:59:20 +02:00
|
|
|
use Engelsystem\Models\Message;
|
|
|
|
use Engelsystem\Models\News;
|
|
|
|
use Engelsystem\Models\NewsComment;
|
2023-11-06 23:50:07 +01:00
|
|
|
use Engelsystem\Models\OAuth;
|
|
|
|
use Engelsystem\Models\Privilege;
|
2021-07-10 00:59:20 +02:00
|
|
|
use Engelsystem\Models\Question;
|
2023-10-15 19:25:55 +02:00
|
|
|
use Engelsystem\Models\Location;
|
2023-11-06 23:50:07 +01:00
|
|
|
use Engelsystem\Models\Session;
|
|
|
|
use Engelsystem\Models\Shifts\NeededAngelType;
|
2021-07-10 00:59:20 +02:00
|
|
|
use Engelsystem\Models\Shifts\Schedule;
|
2023-01-03 22:19:03 +01:00
|
|
|
use Engelsystem\Models\Shifts\Shift;
|
2023-01-18 13:02:11 +01:00
|
|
|
use Engelsystem\Models\Shifts\ShiftEntry;
|
2023-11-06 23:50:07 +01:00
|
|
|
use Engelsystem\Models\Shifts\ShiftType;
|
2021-07-10 00:59:20 +02:00
|
|
|
use Engelsystem\Models\User\Contact;
|
2022-06-02 13:18:37 +02:00
|
|
|
use Engelsystem\Models\User\License;
|
2021-07-10 00:59:20 +02:00
|
|
|
use Engelsystem\Models\User\PasswordReset;
|
|
|
|
use Engelsystem\Models\User\PersonalData;
|
|
|
|
use Engelsystem\Models\User\Settings;
|
|
|
|
use Engelsystem\Models\User\State;
|
|
|
|
use Engelsystem\Models\User\User;
|
2023-11-06 23:50:07 +01:00
|
|
|
use Engelsystem\Models\UserAngelType;
|
2021-07-10 00:59:20 +02:00
|
|
|
use Engelsystem\Models\Worklog;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class FactoriesTest extends TestCase
|
|
|
|
{
|
|
|
|
use HasDatabase;
|
|
|
|
|
2023-01-03 22:19:03 +01:00
|
|
|
/**
|
|
|
|
* @return string[][]
|
|
|
|
*/
|
|
|
|
public function factoriesProvider(): array
|
|
|
|
{
|
|
|
|
return [
|
2023-11-06 23:50:07 +01:00
|
|
|
[AngelType::class],
|
2023-01-03 22:19:03 +01:00
|
|
|
[Contact::class],
|
|
|
|
[Faq::class],
|
2023-11-06 23:50:07 +01:00
|
|
|
[Group::class],
|
2023-01-03 22:19:03 +01:00
|
|
|
[License::class],
|
2023-11-06 23:50:07 +01:00
|
|
|
[Location::class],
|
2023-01-03 22:19:03 +01:00
|
|
|
[Message::class],
|
2023-11-06 23:50:07 +01:00
|
|
|
[NeededAngelType::class],
|
2023-01-03 22:19:03 +01:00
|
|
|
[News::class],
|
|
|
|
[NewsComment::class],
|
2023-11-06 23:50:07 +01:00
|
|
|
[OAuth::class],
|
2023-01-03 22:19:03 +01:00
|
|
|
[PasswordReset::class],
|
|
|
|
[PersonalData::class],
|
2023-11-06 23:50:07 +01:00
|
|
|
[Privilege::class],
|
2023-01-03 22:19:03 +01:00
|
|
|
[Question::class],
|
|
|
|
[Schedule::class],
|
2023-11-06 23:50:07 +01:00
|
|
|
[Session::class],
|
2023-01-03 22:19:03 +01:00
|
|
|
[Settings::class],
|
|
|
|
[Shift::class],
|
2023-11-06 23:50:07 +01:00
|
|
|
[ShiftEntry::class],
|
|
|
|
[ShiftType::class],
|
2023-01-03 22:19:03 +01:00
|
|
|
[State::class],
|
2023-11-06 23:50:07 +01:00
|
|
|
[UserAngelType::class],
|
2023-01-03 22:19:03 +01:00
|
|
|
[User::class],
|
|
|
|
[Worklog::class],
|
|
|
|
];
|
|
|
|
}
|
2021-07-10 00:59:20 +02:00
|
|
|
|
|
|
|
/**
|
2023-01-03 22:19:03 +01:00
|
|
|
* Test all model factories
|
2022-06-02 13:18:37 +02:00
|
|
|
*
|
2023-11-06 23:50:07 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\AngelTypeFactory
|
2023-01-03 22:19:03 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\FaqFactory
|
2023-11-06 23:50:07 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\GroupFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\LocationFactory
|
2023-01-03 22:19:03 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\MessageFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\NewsCommentFactory
|
2023-11-06 23:50:07 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\NewsFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\OAuthFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\PrivilegeFactory
|
2023-01-03 22:19:03 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\QuestionFactory
|
2023-11-06 23:50:07 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\SessionFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\Shifts\NeededAngelTypeFactory
|
2023-01-03 22:19:03 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\Shifts\ScheduleFactory
|
2023-11-06 23:50:07 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\Shifts\ShiftEntryFactory
|
2023-01-03 22:19:03 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\Shifts\ShiftFactory
|
2023-11-06 23:50:07 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\Shifts\ShiftTypeFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\UserAngelTypeFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\ContactFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\LicenseFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\PasswordResetFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\PersonalDataFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\SettingsFactory
|
2023-01-03 22:19:03 +01:00
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\StateFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\UserFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\WorklogFactory
|
|
|
|
*
|
|
|
|
* @dataProvider factoriesProvider
|
2021-07-10 00:59:20 +02:00
|
|
|
*/
|
2023-01-03 22:19:03 +01:00
|
|
|
public function testFactories(string $model): void
|
2021-07-10 00:59:20 +02:00
|
|
|
{
|
|
|
|
$this->initDatabase();
|
|
|
|
|
2023-01-03 22:19:03 +01:00
|
|
|
$instance = (new $model())->factory()->create();
|
|
|
|
$this->assertInstanceOf(Model::class, $instance);
|
2021-07-10 00:59:20 +02:00
|
|
|
}
|
2022-06-02 13:18:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\StateFactory
|
|
|
|
*/
|
2022-12-13 19:00:43 +01:00
|
|
|
public function testStateFactoryArrived(): void
|
2022-06-02 13:18:37 +02:00
|
|
|
{
|
|
|
|
$this->initDatabase();
|
|
|
|
|
|
|
|
/** @var State $instance */
|
|
|
|
$instance = (new State())->factory()->arrived()->create();
|
|
|
|
$this->assertInstanceOf(Model::class, $instance);
|
|
|
|
$this->assertTrue($instance->arrived);
|
|
|
|
}
|
2021-07-10 00:59:20 +02:00
|
|
|
}
|