oms-QA/tests/Models/QAQuestionVoteMapperTest.php
Dennis Eichhorn b1347ee10e
Some checks are pending
Image optimization / general_image_workflow (push) Waiting to run
CI / general_module_workflow_php (push) Waiting to run
CI / general_module_workflow_js (push) Waiting to run
fix
2024-05-18 00:53:21 +00:00

56 lines
1.6 KiB
PHP
Executable File

<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\QA\tests\Models;
use Modules\Admin\Models\NullAccount;
use Modules\QA\Models\QAQuestionVote;
use Modules\QA\Models\QAQuestionVoteMapper;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\QA\Models\QAQuestionVoteMapper::class)]
final class QAQuestionVoteMapperTest extends \PHPUnit\Framework\TestCase
{
#[\PHPUnit\Framework\Attributes\DependsExternal('\Modules\QA\tests\Models\QAQuestionMapperTest', 'testCRUD')]
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testCRUD() : void
{
\Modules\Admin\tests\Script::createAccounts(1);
$vote = new QAQuestionVote();
$vote->question = 1;
$vote->score = 1;
$vote->createdBy = new NullAccount(1);
$vote->createdFor = 2;
$id = QAQuestionVoteMapper::create()->execute($vote);
self::assertGreaterThan(0, $vote->id);
self::assertEquals($id, $vote->id);
$voteR = QAQuestionVoteMapper::get()->where('id', $vote->id)->execute();
self::assertEquals($vote->question, $voteR->question);
self::assertEquals($vote->score, $voteR->score);
self::assertEquals(1,
QAQuestionVoteMapper::get()
->where('question', 1)
->where('createdBy', 1)
->limit(1)
->execute()->id
);
}
}