add unit tests

This commit is contained in:
Dennis Eichhorn 2021-11-02 21:57:09 +01:00
parent 7ffe998262
commit 1f064cd1cb
10 changed files with 235 additions and 42 deletions

View File

@ -77,4 +77,16 @@ class QAAnswerVote
$this->createdBy = new NullAccount();
$this->createdAt = new \DateTimeImmutable();
}
/**
* Get model id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
}

View File

@ -77,4 +77,16 @@ class QAQuestionVote
$this->createdBy = new NullAccount();
$this->createdAt = new \DateTimeImmutable();
}
/**
* Get model id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
}

View File

@ -51,25 +51,4 @@ final class QAQuestionMapperTest extends \PHPUnit\Framework\TestCase
self::assertEquals($question->getLanguage(), $questionR->getLanguage());
self::assertEquals($question->createdBy->account->getId(), $questionR->createdBy->account->getId());
}
/**
* @group volume
* @group module
* @coversNothing
*/
public function testVolume() : void
{
for ($i = 1; $i < 30; ++$i) {
$text = new Text();
$question = new QAQuestion();
$question->name = $text->generateText(\mt_rand(1, 3));
$question->question = $text->generateText(\mt_rand(100, 500));
$question->setStatus(QAQuestionStatus::ACTIVE);
$question->createdBy = new Profile(new NullAccount(1));
$question->setLanguage('en');
$id = QAQuestionMapper::create($question);
}
}
}

View File

@ -52,24 +52,4 @@ final class QAAnswerMapperTest extends \PHPUnit\Framework\TestCase
self::assertEquals($answer->isAccepted, $answerR->isAccepted);
self::assertEquals($answer->createdBy->account->getId(), $answerR->createdBy->account->getId());
}
/**
* @group volume
* @group module
* @coversNothing
*/
public function testVolume() : void
{
for ($i = 1; $i < 30; ++$i) {
$text = new Text();
$answer = new QAAnswer();
$answer->setAnswer($text->generateText(\mt_rand(100, 500)));
$answer->createdBy = new Profile(new NullAccount(1));
$answer->setStatus(QAAnswerStatus::ACTIVE);
$answer->setQuestion(new NullQAQuestion(1));
$id = QAAnswerMapper::create($answer);
}
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QA\tests\Models;
use Modules\QA\Models\NullQAAnswer;
/**
* @internal
*/
final class NullQAAnswerTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\QA\Models\NullQAAnswer
* @group module
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\QA\Models\QAAnswer', new NullQAAnswer());
}
/**
* @covers Modules\QA\Models\NullQAAnswer
* @group module
*/
public function testId() : void
{
$null = new NullQAAnswer(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QA\tests\Models;
use Modules\QA\Models\NullQAAnswerVote;
/**
* @internal
*/
final class NullQAAnswerVoteTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\QA\Models\NullQAAnswerVote
* @group module
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\QA\Models\QAAnswerVote', new NullQAAnswerVote());
}
/**
* @covers Modules\QA\Models\NullQAAnswerVote
* @group module
*/
public function testId() : void
{
$null = new NullQAAnswerVote(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QA\tests\Models;
use Modules\QA\Models\NullQAApp;
/**
* @internal
*/
final class NullQAAppTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\QA\Models\NullQAApp
* @group module
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\QA\Models\QAApp', new NullQAApp());
}
/**
* @covers Modules\QA\Models\NullQAApp
* @group module
*/
public function testId() : void
{
$null = new NullQAApp(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QA\tests\Models;
use Modules\QA\Models\NullQAQuestion;
/**
* @internal
*/
final class NullQAQuestionTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\QA\Models\NullQAQuestion
* @group module
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\QA\Models\QAQuestion', new NullQAQuestion());
}
/**
* @covers Modules\QA\Models\NullQAQuestion
* @group module
*/
public function testId() : void
{
$null = new NullQAQuestion(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QA\tests\Models;
use Modules\QA\Models\NullQAQuestionVote;
/**
* @internal
*/
final class NullQAQuestionVoteTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\QA\Models\NullQAQuestionVote
* @group module
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\QA\Models\QAQuestionVote', new NullQAQuestionVote());
}
/**
* @covers Modules\QA\Models\NullQAQuestionVote
* @group module
*/
public function testId() : void
{
$null = new NullQAQuestionVote(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" stopOnError="true" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" columns="120" stopOnError="true" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true" processUncoveredFiles="false">
<exclude>
<directory>*vendor*</directory>