oms-QA/tests/Models/QAQuestionMapperTest.php
Dennis Eichhorn 02898279ac
Some checks failed
Image optimization / general_image_workflow (push) Has been cancelled
CI / general_module_workflow_php (push) Has been cancelled
CI / general_module_workflow_js (push) Has been cancelled
fix version and bugs
2024-05-21 00:09:16 +02:00

52 lines
1.6 KiB
PHP
Executable File

<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.2
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\QA\tests\Models;
use Modules\Admin\Models\NullAccount;
use Modules\Profile\Models\Profile;
use Modules\QA\Models\QAQuestion;
use Modules\QA\Models\QAQuestionMapper;
use Modules\QA\Models\QAQuestionStatus;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\QA\Models\QAQuestionMapper::class)]
final class QAQuestionMapperTest extends \PHPUnit\Framework\TestCase
{
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testCRUD() : void
{
$question = new QAQuestion();
$question->name = 'Question Name';
$question->question = 'Question content';
$question->status = QAQuestionStatus::ACTIVE;
$question->createdBy = new Profile(new NullAccount(1));
$question->language = 'en';
$id = QAQuestionMapper::create()->execute($question);
self::assertGreaterThan(0, $question->id);
self::assertEquals($id, $question->id);
$questionR = QAQuestionMapper::get()->with('createdBy')->with('createdBy/account')->where('id', $question->id)->execute();
self::assertEquals($question->name, $questionR->name);
self::assertEquals($question->question, $questionR->question);
self::assertEquals($question->status, $questionR->status);
self::assertEquals($question->language, $questionR->language);
self::assertEquals($question->createdBy->account->id, $questionR->createdBy->account->id);
}
}