2021-07-10 00:59:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit;
|
|
|
|
|
|
|
|
use Engelsystem\Models\Faq;
|
|
|
|
use Engelsystem\Models\Message;
|
|
|
|
use Engelsystem\Models\News;
|
|
|
|
use Engelsystem\Models\NewsComment;
|
|
|
|
use Engelsystem\Models\Question;
|
|
|
|
use Engelsystem\Models\Room;
|
|
|
|
use Engelsystem\Models\Shifts\Schedule;
|
|
|
|
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;
|
|
|
|
use Engelsystem\Models\Worklog;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class FactoriesTest extends TestCase
|
|
|
|
{
|
|
|
|
use HasDatabase;
|
|
|
|
|
|
|
|
/** @var string[] */
|
|
|
|
protected $models = [
|
|
|
|
Contact::class,
|
2022-06-02 13:18:37 +02:00
|
|
|
Faq::class,
|
|
|
|
License::class,
|
|
|
|
Message::class,
|
2021-07-10 00:59:20 +02:00
|
|
|
News::class,
|
|
|
|
NewsComment::class,
|
2022-06-02 13:18:37 +02:00
|
|
|
PasswordReset::class,
|
|
|
|
PersonalData::class,
|
2021-07-10 00:59:20 +02:00
|
|
|
Question::class,
|
|
|
|
Room::class,
|
|
|
|
Schedule::class,
|
2022-06-02 13:18:37 +02:00
|
|
|
Settings::class,
|
|
|
|
State::class,
|
|
|
|
User::class,
|
|
|
|
Worklog::class,
|
2021-07-10 00:59:20 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test all existing model factories
|
2022-06-02 13:18:37 +02:00
|
|
|
*
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\ContactFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\FaqFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\LicenseFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\MessageFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\NewsFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\NewsCommentFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\PasswordResetFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\PersonalDataFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\QuestionFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\RoomFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\Shifts\ScheduleFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\SettingsFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\StateFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\UserFactory
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\WorklogFactory
|
2021-07-10 00:59:20 +02:00
|
|
|
*/
|
|
|
|
public function testFactories()
|
|
|
|
{
|
|
|
|
$this->initDatabase();
|
|
|
|
|
|
|
|
foreach ($this->models as $model) {
|
|
|
|
$instance = (new $model())->factory()->create();
|
|
|
|
$this->assertInstanceOf(Model::class, $instance);
|
|
|
|
}
|
|
|
|
}
|
2022-06-02 13:18:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Database\Factories\Engelsystem\Models\User\StateFactory
|
|
|
|
*/
|
|
|
|
public function testStateFactoryArrived()
|
|
|
|
{
|
|
|
|
$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
|
|
|
}
|