mirror of
https://github.com/Karaka-Management/oms-QA.git
synced 2026-02-04 18:48:39 +00:00
fix autoloader path
This commit is contained in:
parent
aa536763a7
commit
031ccb0494
26
tests/Admin/AdminTest.php
Normal file
26
tests/Admin/AdminTest.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\Admin;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class AdminTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected const MODULE_NAME = 'QA';
|
||||
protected const URI_LOAD = 'http://127.0.0.1/en/backend/qa';
|
||||
|
||||
use \Modules\tests\ModuleTestTrait;
|
||||
}
|
||||
73
tests/Models/2QACategoryMapperTest.php
Normal file
73
tests/Models/2QACategoryMapperTest.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\NullQACategory;
|
||||
use Modules\QA\Models\QACategory;
|
||||
use Modules\QA\Models\QACategoryMapper;
|
||||
use phpOMS\Utils\RnG\Text;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class QACategoryMapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testCRUD() : void
|
||||
{
|
||||
$category = new QACategory();
|
||||
|
||||
$category->setName('Test Category');
|
||||
|
||||
$id = QACategoryMapper::create($category);
|
||||
self::assertGreaterThan(0, $category->getId());
|
||||
self::assertEquals($id, $category->getId());
|
||||
|
||||
$categoryR = QACategoryMapper::get($category->getId());
|
||||
self::assertEquals($category->getName(), $categoryR->getName());
|
||||
}
|
||||
|
||||
public function testChildCRUD() : void
|
||||
{
|
||||
$category = new QACategory();
|
||||
|
||||
$category->setName('Test Category2');
|
||||
$category->setParent(new NullQACategory(1));
|
||||
|
||||
$id = QACategoryMapper::create($category);
|
||||
self::assertGreaterThan(0, $category->getId());
|
||||
self::assertEquals($id, $category->getId());
|
||||
|
||||
$categoryR = QACategoryMapper::get($category->getId());
|
||||
self::assertEquals($category->getName(), $categoryR->getName());
|
||||
self::assertEquals($category->getParent()->getId(), $categoryR->getParent()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group volume
|
||||
* @group module
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testVolume() : void
|
||||
{
|
||||
for ($i = 1; $i < 30; ++$i) {
|
||||
$text = new Text();
|
||||
$category = new QACategory();
|
||||
|
||||
$category->setName($text->generateText(\mt_rand(1, 3)));
|
||||
|
||||
$id = QACategoryMapper::create($category);
|
||||
}
|
||||
}
|
||||
}
|
||||
74
tests/Models/3QAQuestionMapperTest.php
Normal file
74
tests/Models/3QAQuestionMapperTest.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\Admin\Models\NullAccount;
|
||||
use Modules\QA\Models\NullQACategory;
|
||||
use Modules\QA\Models\QAQuestion;
|
||||
use Modules\QA\Models\QAQuestionMapper;
|
||||
use Modules\QA\Models\QAQuestionStatus;
|
||||
use phpOMS\Utils\RnG\Text;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class QAQuestionMapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testCRUD() : void
|
||||
{
|
||||
$question = new QAQuestion();
|
||||
|
||||
$question->setName('Question Name');
|
||||
$question->setQuestion('Question content');
|
||||
$question->setStatus(QAQuestionStatus::ACTIVE);
|
||||
$question->setCategory(new NullQACategory(1));
|
||||
$question->setCreatedBy(new NullAccount(1));
|
||||
$question->setLanguage('en');
|
||||
|
||||
$id = QAQuestionMapper::create($question);
|
||||
self::assertGreaterThan(0, $question->getId());
|
||||
self::assertEquals($id, $question->getId());
|
||||
|
||||
$questionR = QAQuestionMapper::get($question->getId());
|
||||
self::assertEquals($question->getName(), $questionR->getName());
|
||||
self::assertEquals($question->getQuestion(), $questionR->getQuestion());
|
||||
self::assertEquals($question->getStatus(), $questionR->getStatus());
|
||||
self::assertEquals($question->getLanguage(), $questionR->getLanguage());
|
||||
self::assertEquals($question->getCategory()->getId(), $questionR->getCategory()->getId());
|
||||
self::assertEquals($question->getCreatedBy()->getId(), $questionR->getCreatedBy()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group volume
|
||||
* @group module
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testVolume() : void
|
||||
{
|
||||
for ($i = 1; $i < 30; ++$i) {
|
||||
$text = new Text();
|
||||
$question = new QAQuestion();
|
||||
|
||||
$question->setName($text->generateText(\mt_rand(1, 3)));
|
||||
$question->setQuestion($text->generateText(\mt_rand(100, 500)));
|
||||
$question->setStatus(QAQuestionStatus::ACTIVE);
|
||||
$question->setCategory(new NullQACategory(\mt_rand(1, 9)));
|
||||
$question->setCreatedBy(new NullAccount(1));
|
||||
$question->setLanguage('en');
|
||||
|
||||
$id = QAQuestionMapper::create($question);
|
||||
}
|
||||
}
|
||||
}
|
||||
70
tests/Models/4QAAnswerMapperTest.php
Normal file
70
tests/Models/4QAAnswerMapperTest.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\Admin\Models\NullAccount;
|
||||
use Modules\QA\Models\NullQAQuestion;
|
||||
use Modules\QA\Models\QAAnswer;
|
||||
use Modules\QA\Models\QAAnswerMapper;
|
||||
use Modules\QA\Models\QAAnswerStatus;
|
||||
use phpOMS\Utils\RnG\Text;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class QAAnswerMapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testCRUD() : void
|
||||
{
|
||||
$answer = new QAAnswer();
|
||||
|
||||
$answer->setAnswer('Answer content');
|
||||
$answer->setStatus(QAAnswerStatus::ACTIVE);
|
||||
$answer->setCreatedBy(new NullAccount(1));
|
||||
$answer->setQuestion(new NullQAQuestion(1));
|
||||
$answer->setAccepted(true);
|
||||
|
||||
$id = QAAnswerMapper::create($answer);
|
||||
self::assertGreaterThan(0, $answer->getId());
|
||||
self::assertEquals($id, $answer->getId());
|
||||
|
||||
$answerR = QAAnswerMapper::get($answer->getId());
|
||||
self::assertEquals($answer->getAnswer(), $answerR->getAnswer());
|
||||
self::assertEquals($answer->getQuestion()->getId(), $answerR->getQuestion()->getId());
|
||||
self::assertEquals($answer->getStatus(), $answerR->getStatus());
|
||||
self::assertEquals($answer->isAccepted(), $answerR->isAccepted());
|
||||
self::assertEquals($answer->getCreatedBy()->getId(), $answerR->getCreatedBy()->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->setCreatedBy(new NullAccount(1));
|
||||
$answer->setStatus(QAAnswerStatus::ACTIVE);
|
||||
$answer->setQuestion(new NullQAQuestion(1));
|
||||
|
||||
$id = QAAnswerMapper::create($answer);
|
||||
}
|
||||
}
|
||||
}
|
||||
56
tests/Models/QAAnswerTest.php
Normal file
56
tests/Models/QAAnswerTest.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\Admin\Models\NullAccount;
|
||||
use Modules\QA\Models\NullQAQuestion;
|
||||
use Modules\QA\Models\QAAnswer;
|
||||
use Modules\QA\Models\QAAnswerStatus;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class QAAnswerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefault() : void
|
||||
{
|
||||
$answer = new QAAnswer();
|
||||
|
||||
self::assertEquals(0, $answer->getId());
|
||||
self::assertEquals('', $answer->getAnswer());
|
||||
self::assertEquals(0, $answer->getQuestion()->getId());
|
||||
self::assertFalse($answer->isAccepted());
|
||||
self::assertEquals(QAAnswerStatus::ACTIVE, $answer->getStatus());
|
||||
self::assertEquals(0, $answer->getCreatedBy()->getId());
|
||||
self::assertInstanceOf('\DateTime', $answer->getCreatedAt());
|
||||
}
|
||||
|
||||
public function testSetGet() : void
|
||||
{
|
||||
$answer = new QAAnswer();
|
||||
|
||||
$answer->setAnswer('Answer content');
|
||||
$answer->setStatus(QAAnswerStatus::ACTIVE);
|
||||
$answer->setQuestion(new NullQAQuestion(3));
|
||||
$answer->setCreatedBy(new NullAccount(1));
|
||||
$answer->setAccepted(true);
|
||||
|
||||
self::assertEquals('Answer content', $answer->getAnswer());
|
||||
self::assertEquals(QAAnswerStatus::ACTIVE, $answer->getStatus());
|
||||
self::assertEquals(1, $answer->getCreatedBy()->getId());
|
||||
self::assertEquals(3, $answer->getQuestion()->getId());
|
||||
self::assertTrue($answer->isAccepted());
|
||||
}
|
||||
}
|
||||
44
tests/Models/QACategoryTest.php
Normal file
44
tests/Models/QACategoryTest.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\NullQACategory;
|
||||
use Modules\QA\Models\QACategory;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class QACategoryTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefault() : void
|
||||
{
|
||||
$category = new QACategory();
|
||||
|
||||
self::assertEquals(0, $category->getId());
|
||||
self::assertEquals('', $category->getName());
|
||||
self::assertNull($category->getParent());
|
||||
}
|
||||
|
||||
public function testSetGet() : void
|
||||
{
|
||||
$category = new QACategory();
|
||||
|
||||
$category->setName('Category Name');
|
||||
$category->setParent(new NullQACategory(1));
|
||||
|
||||
self::assertEquals('Category Name', $category->getName());
|
||||
self::assertEquals(1, $category->getParent()->getId());
|
||||
}
|
||||
}
|
||||
60
tests/Models/QAQuestionTest.php
Normal file
60
tests/Models/QAQuestionTest.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\Admin\Models\NullAccount;
|
||||
use Modules\QA\Models\NullQACategory;
|
||||
use Modules\QA\Models\QAQuestion;
|
||||
use Modules\QA\Models\QAQuestionStatus;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class QAQuestionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefault() : void
|
||||
{
|
||||
$question = new QAQuestion();
|
||||
|
||||
self::assertEquals(0, $question->getId());
|
||||
self::assertEquals('', $question->getName());
|
||||
self::assertEquals('', $question->getQuestion());
|
||||
self::assertEquals(QAQuestionStatus::ACTIVE, $question->getStatus());
|
||||
self::assertEquals(0, $question->getCategory()->getId());
|
||||
self::assertEquals('', $question->getLanguage());
|
||||
self::assertEquals(0, $question->getCreatedBy()->getId());
|
||||
self::assertInstanceOf('\DateTime', $question->getCreatedAt());
|
||||
self::assertEquals([], $question->getBadges());
|
||||
}
|
||||
|
||||
public function testSetGet() : void
|
||||
{
|
||||
$question = new QAQuestion();
|
||||
|
||||
$question->setName('Question Name');
|
||||
$question->setQuestion('Question content');
|
||||
$question->setStatus(QAQuestionStatus::ACTIVE);
|
||||
$question->setCategory(new NullQACategory(1));
|
||||
$question->setCreatedBy(new NullAccount(1));
|
||||
$question->setLanguage('en');
|
||||
|
||||
self::assertEquals('Question Name', $question->getName());
|
||||
self::assertEquals('Question content', $question->getQuestion());
|
||||
self::assertEquals(QAQuestionStatus::ACTIVE, $question->getStatus());
|
||||
self::assertEquals('en', $question->getLanguage());
|
||||
self::assertEquals(1, $question->getCategory()->getId());
|
||||
self::assertEquals(1, $question->getCreatedBy()->getId());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user