mirror of
https://github.com/Karaka-Management/oms-QA.git
synced 2026-01-11 15:48:42 +00:00
remove some getter/setter
This commit is contained in:
parent
a440a1b5c0
commit
949593c2e0
|
|
@ -71,13 +71,13 @@ final class ApiController extends Controller
|
|||
{
|
||||
if (!empty($val = $this->validateQAQuestionCreate($request))) {
|
||||
$response->set('qa_question_create', new FormValidation($val));
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_400);
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$question = $this->createQAQuestionFromRequest($request, $response, $data);
|
||||
$this->createModel($request->getHeader()->getAccount(), $question, QAQuestionMapper::class, 'question', $request->getOrigin());
|
||||
$this->createModel($request->header->account, $question, QAQuestionMapper::class, 'question', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Question', 'Question successfully created.', $question);
|
||||
}
|
||||
|
||||
|
|
@ -97,12 +97,12 @@ final class ApiController extends Controller
|
|||
$mardkownParser = new Markdown();
|
||||
|
||||
$question = new QAQuestion();
|
||||
$question->setName((string) $request->getData('title'));
|
||||
$question->setQuestion((string) $request->getData('plain'));
|
||||
$question->name = (string) $request->getData('title');
|
||||
$question->question = (string) $request->getData('plain');
|
||||
$question->setLanguage((string) $request->getData('language'));
|
||||
$question->setCategory(new NullQACategory((int) $request->getData('category')));
|
||||
$question->setStatus((int) $request->getData('status'));
|
||||
$question->setCreatedBy(new NullAccount($request->getHeader()->getAccount()));
|
||||
$question->createdBy = new NullAccount($request->header->account);
|
||||
|
||||
if (!empty($tags = $request->getDataJson('tags'))) {
|
||||
foreach ($tags as $tag) {
|
||||
|
|
@ -113,7 +113,7 @@ final class ApiController extends Controller
|
|||
|
||||
$internalResponse = new HttpResponse();
|
||||
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, $data);
|
||||
$question->addTag($internalResponse->get($request->getUri()->__toString())['response']);
|
||||
$question->addTag($internalResponse->get($request->uri->__toString())['response']);
|
||||
} else {
|
||||
$question->addTag(new NullTag((int) $tag['id']));
|
||||
}
|
||||
|
|
@ -167,13 +167,13 @@ final class ApiController extends Controller
|
|||
{
|
||||
if (!empty($val = $this->validateQAAnswerCreate($request))) {
|
||||
$response->set('qa_answer_create', new FormValidation($val));
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_400);
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$answer = $this->createQAAnswerFromRequest($request);
|
||||
$this->createModel($request->getHeader()->getAccount(), $answer, QAAnswerMapper::class, 'answer', $request->getOrigin());
|
||||
$this->createModel($request->header->account, $answer, QAAnswerMapper::class, 'answer', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Answer', 'Answer successfully created.', $answer);
|
||||
}
|
||||
|
||||
|
|
@ -191,10 +191,10 @@ final class ApiController extends Controller
|
|||
$mardkownParser = new Markdown();
|
||||
|
||||
$answer = new QAAnswer();
|
||||
$answer->setAnswer((string) $request->getData('plain'));
|
||||
$answer->setQuestion(new NullQAQuestion((int) $request->getData('question')));
|
||||
$answer->answer = (string) $request->getData('plain');
|
||||
$answer->question = new NullQAQuestion((int) $request->getData('question'));
|
||||
$answer->setStatus((int) $request->getData('status'));
|
||||
$answer->setCreatedBy(new NullAccount($request->getHeader()->getAccount()));
|
||||
$answer->createdBy = new NullAccount($request->header->account);
|
||||
|
||||
return $answer;
|
||||
}
|
||||
|
|
@ -241,21 +241,21 @@ final class ApiController extends Controller
|
|||
{
|
||||
if (!empty($val = $this->validateQACategoryCreate($request))) {
|
||||
$response->set('qa_category_create', new FormValidation($val));
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_400);
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$category = $this->createQACategoryFromRequest($request);
|
||||
$this->createModel($request->getHeader()->getAccount(), $category, QACategoryMapper::class, 'category', $request->getOrigin());
|
||||
$this->createModel($request->header->account, $category, QACategoryMapper::class, 'category', $request->getOrigin());
|
||||
|
||||
$l11nRequest = new HttpRequest($request->getUri());
|
||||
$l11nRequest = new HttpRequest($request->uri);
|
||||
$l11nRequest->setData('category', $category->getId());
|
||||
$l11nRequest->setData('name', $request->getData('name'));
|
||||
$l11nRequest->setData('language', $request->getData('language'));
|
||||
|
||||
$l11nQACategory = $this->createQACategoryL11nFromRequest($l11nRequest);
|
||||
$this->createModel($request->getHeader()->getAccount(), $l11nQACategory, QACategoryL11nMapper::class, 'tag_l11n', $request->getOrigin());
|
||||
$this->createModel($request->header->account, $l11nQACategory, QACategoryL11nMapper::class, 'tag_l11n', $request->getOrigin());
|
||||
|
||||
$category->setName($l11nQACategory);
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ final class ApiController extends Controller
|
|||
//$category->setApp(new NullQAApp((int) ($request->getData('app') ?? 1)));
|
||||
|
||||
if ($request->getData('parent') !== null) {
|
||||
$category->setParent(new NullQACategory((int) $request->getData('parent')));
|
||||
$category->parent = new NullQACategory((int) $request->getData('parent'));
|
||||
}
|
||||
|
||||
return $category;
|
||||
|
|
@ -340,13 +340,13 @@ final class ApiController extends Controller
|
|||
{
|
||||
if (!empty($val = $this->validateQACategoryL11nCreate($request))) {
|
||||
$response->set('qa_category_l11n_create', new FormValidation($val));
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_400);
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$l11nQACategory = $this->createQACategoryL11nFromRequest($request);
|
||||
$this->createModel($request->getHeader()->getAccount(), $l11nQACategory, QACategoryL11nMapper::class, 'qa_category_l11n', $request->getOrigin());
|
||||
$this->createModel($request->header->account, $l11nQACategory, QACategoryL11nMapper::class, 'qa_category_l11n', $request->getOrigin());
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Category localization successfully created', $l11nQACategory);
|
||||
}
|
||||
|
|
@ -367,7 +367,7 @@ final class ApiController extends Controller
|
|||
$l11nQACategory->setLanguage((string) (
|
||||
$request->getData('language') ?? $request->getLanguage()
|
||||
));
|
||||
$l11nQACategory->setName((string) ($request->getData('name') ?? ''));
|
||||
$l11nQACategory->name = (string) ($request->getData('name') ?? '');
|
||||
|
||||
return $l11nQACategory;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class QAAnswer implements \JsonSerializable
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $answer = '';
|
||||
public $answer = '';
|
||||
|
||||
/**
|
||||
* Answer raw.
|
||||
|
|
@ -51,7 +51,7 @@ class QAAnswer implements \JsonSerializable
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $answerRaw = '';
|
||||
public $answerRaw = '';
|
||||
|
||||
/**
|
||||
* Question
|
||||
|
|
@ -59,7 +59,7 @@ class QAAnswer implements \JsonSerializable
|
|||
* @var QAQuestion
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private QAQuestion $question;
|
||||
public QAQuestion $question;
|
||||
|
||||
/**
|
||||
* Is accepted answer.
|
||||
|
|
@ -75,7 +75,7 @@ class QAAnswer implements \JsonSerializable
|
|||
* @var Account
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private Account $createdBy;
|
||||
public Account $createdBy;
|
||||
|
||||
/**
|
||||
* Created at.
|
||||
|
|
@ -83,7 +83,7 @@ class QAAnswer implements \JsonSerializable
|
|||
* @var \DateTimeImmutable
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private \DateTimeImmutable $createdAt;
|
||||
public \DateTimeImmutable $createdAt;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
@ -213,44 +213,6 @@ class QAAnswer implements \JsonSerializable
|
|||
return $this->isAccepted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get created by
|
||||
*
|
||||
* @return Account
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCreatedBy() : Account
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set created by
|
||||
*
|
||||
* @param Account $account Creator
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCreatedBy(Account $account) : void
|
||||
{
|
||||
$this->createdBy = $account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get created at
|
||||
*
|
||||
* @return \DateTimeImmutable
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCreatedAt() : \DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -45,10 +45,20 @@ class QACategory implements \JsonSerializable
|
|||
/**
|
||||
* Parent category.
|
||||
*
|
||||
* @var null|QACategory
|
||||
* @var QACategory
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private ?self $parent = null;
|
||||
public self $parent;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @sicne 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->parent = new NullQACategory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
|
|
@ -88,40 +98,14 @@ class QACategory implements \JsonSerializable
|
|||
if ($name instanceof QACategoryL11n) {
|
||||
$this->name = $name;
|
||||
} elseif ($this->name instanceof QACategoryL11n && \is_string($name)) {
|
||||
$this->name->setName($name);
|
||||
$this->name->name = $name;
|
||||
} elseif (\is_string($name)) {
|
||||
$this->name = new QACategoryL11n();
|
||||
$this->name->setName($name);
|
||||
$this->name->name = $name;
|
||||
$this->name->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent category
|
||||
*
|
||||
* @return null|self
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getParent() : ?self
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent category
|
||||
*
|
||||
* @param null|self $parent Parent category
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setParent(?self $parent) : void
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class QACategoryL11n implements \JsonSerializable, ArrayableInterface
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $name = '';
|
||||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
@ -148,20 +148,6 @@ class QACategoryL11n implements \JsonSerializable, ArrayableInterface
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name Name
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setName(string $name) : void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class QAQuestion implements \JsonSerializable
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $name = '';
|
||||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Question status.
|
||||
|
|
@ -58,7 +58,7 @@ class QAQuestion implements \JsonSerializable
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $question = '';
|
||||
public string $question = '';
|
||||
|
||||
/**
|
||||
* Category.
|
||||
|
|
@ -82,7 +82,7 @@ class QAQuestion implements \JsonSerializable
|
|||
* @var Account
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private Account $createdBy;
|
||||
public Account $createdBy;
|
||||
|
||||
/**
|
||||
* Created at.
|
||||
|
|
@ -90,7 +90,7 @@ class QAQuestion implements \JsonSerializable
|
|||
* @var \DateTimeImmutable
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private \DateTimeImmutable $createdAt;
|
||||
public \DateTimeImmutable $createdAt;
|
||||
|
||||
/**
|
||||
* Tags.
|
||||
|
|
@ -193,58 +193,6 @@ class QAQuestion implements \JsonSerializable
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getName() : string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*
|
||||
* @param string $name Name
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setName(string $name) : void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the question.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getQuestion() : string
|
||||
{
|
||||
return $this->question;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the question
|
||||
*
|
||||
* @param string $question Question
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setQuestion(string $question) : void
|
||||
{
|
||||
$this->question = $question;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status
|
||||
*
|
||||
|
|
@ -297,44 +245,6 @@ class QAQuestion implements \JsonSerializable
|
|||
$this->category = $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get created by
|
||||
*
|
||||
* @return Account
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCreatedBy() : Account
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set created by
|
||||
*
|
||||
* @param Account $account Created by
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCreatedBy(Account $account) : void
|
||||
{
|
||||
$this->createdBy = $account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get created at date time
|
||||
*
|
||||
* @return \DateTimeImmutable
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCreatedAt() : \DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags
|
||||
*
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<span class="score<?= $this->printHtml($question->hasAccepted() ? ' done' : ''); ?>"><?= $this->printHtml(\count($question->getAnswers())); ?></span>
|
||||
</div>
|
||||
<div class="title col-xs-11">
|
||||
<a href="<?= \phpOMS\Uri\UriFactory::build('{/prefix}qa/question?{?}&id=' . $question->getId()); ?>"><?= $this->printHtml($question->getName()); ?></a>
|
||||
<a href="<?= \phpOMS\Uri\UriFactory::build('{/prefix}qa/question?{?}&id=' . $question->getId()); ?>"><?= $this->printHtml($question->name); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tags">
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ echo $this->getData('nav')->render();
|
|||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="box wf-100">
|
||||
<header><h1><?= $this->printHtml($question->getName()); ?></h1></header>
|
||||
<header><h1><?= $this->printHtml($question->name); ?></h1></header>
|
||||
<div class="inner">
|
||||
<?= $this->printHtml($question->getQuestion()); ?>
|
||||
<?= $this->printHtml($question->question); ?>
|
||||
</div>
|
||||
<div class="inner">
|
||||
<img alt="<?= $this->getHtml('AccountImage', '0', '0'); ?>" loading="lazy" src="<?= UriFactory::build('{/prefix}' . $question->getCreatedBy()->getImage()->getPath()); ?>">
|
||||
<img alt="<?= $this->getHtml('AccountImage', '0', '0'); ?>" loading="lazy" src="<?= UriFactory::build('{/prefix}' . $question->createdBy->image->getPath()); ?>">
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
|
@ -45,7 +45,7 @@ echo $this->getData('nav')->render();
|
|||
<div class="col-xs-12">
|
||||
<section class="box wf-100">
|
||||
<div class="inner">
|
||||
<?= $this->printHtml($answer->getAnswer()); ?><?= $this->printHtml($answer->getCreatedAt()->format('Y-m-d')); ?><?= $this->printHtml($answer->getCreatedBy()->getId()); ?><?= $this->printHtml($answer->getStatus()); ?><?= $this->printHtml($answer->isAccepted()); ?>
|
||||
<?= $this->printHtml($answer->getAnswer()); ?><?= $this->printHtml($answer->getCreatedAt()->format('Y-m-d')); ?><?= $this->printHtml($answer->createdBy->getId()); ?><?= $this->printHtml($answer->getStatus()); ?><?= $this->printHtml($answer->isAccepted()); ?>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ echo $this->getData('nav')->render();
|
|||
$url = \phpOMS\Uri\UriFactory::build('{/prefix}admin/account/settings?{?}&id=' . $value->getId()); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getId()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getName()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($c === 0) : ?>
|
||||
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class QACategoryMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$category = new QACategory();
|
||||
|
||||
$category->setName('Test Category2');
|
||||
$category->setParent(new NullQACategory(1));
|
||||
$category->parent = new NullQACategory(1);
|
||||
|
||||
$id = QACategoryMapper::create($category);
|
||||
self::assertGreaterThan(0, $category->getId());
|
||||
|
|
@ -59,7 +59,7 @@ class QACategoryMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$categoryR = QACategoryMapper::get($category->getId());
|
||||
self::assertEquals($category->getName(), $categoryR->getName());
|
||||
self::assertEquals($category->getParent()->getId(), $categoryR->getParent()->getId());
|
||||
self::assertEquals($category->parent->getId(), $categoryR->parent->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ class QAQuestionMapperTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
$question = new QAQuestion();
|
||||
|
||||
$question->setName('Question Name');
|
||||
$question->setQuestion('Question content');
|
||||
$question->name = 'Question Name';
|
||||
$question->question = 'Question content';
|
||||
$question->setStatus(QAQuestionStatus::ACTIVE);
|
||||
$question->setCategory(new NullQACategory(1));
|
||||
$question->setCreatedBy(new NullAccount(1));
|
||||
$question->createdBy = new NullAccount(1);
|
||||
$question->setLanguage('en');
|
||||
|
||||
$id = QAQuestionMapper::create($question);
|
||||
|
|
@ -46,12 +46,12 @@ class QAQuestionMapperTest extends \PHPUnit\Framework\TestCase
|
|||
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->name, $questionR->name);
|
||||
self::assertEquals($question->question, $questionR->question);
|
||||
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());
|
||||
self::assertEquals($question->createdBy->getId(), $questionR->createdBy->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,11 +65,11 @@ class QAQuestionMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$text = new Text();
|
||||
$question = new QAQuestion();
|
||||
|
||||
$question->setName($text->generateText(\mt_rand(1, 3)));
|
||||
$question->setQuestion($text->generateText(\mt_rand(100, 500)));
|
||||
$question->name = $text->generateText(\mt_rand(1, 3));
|
||||
$question->question = $text->generateText(\mt_rand(100, 500));
|
||||
$question->setStatus(QAQuestionStatus::ACTIVE);
|
||||
$question->setCategory(new NullQACategory(\mt_rand(1, 9)));
|
||||
$question->setCreatedBy(new NullAccount(1));
|
||||
$question->createdBy = new NullAccount(1);
|
||||
$question->setLanguage('en');
|
||||
|
||||
$id = QAQuestionMapper::create($question);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class QAAnswerMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$answer->setAnswer('Answer content');
|
||||
$answer->setStatus(QAAnswerStatus::ACTIVE);
|
||||
$answer->setCreatedBy(new NullAccount(1));
|
||||
$answer->createdBy = new NullAccount(1);
|
||||
$answer->setQuestion(new NullQAQuestion(1));
|
||||
$answer->setAccepted(true);
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ class QAAnswerMapperTest extends \PHPUnit\Framework\TestCase
|
|||
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());
|
||||
self::assertEquals($answer->createdBy->getId(), $answerR->createdBy->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +64,7 @@ class QAAnswerMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$answer = new QAAnswer();
|
||||
|
||||
$answer->setAnswer($text->generateText(\mt_rand(100, 500)));
|
||||
$answer->setCreatedBy(new NullAccount(1));
|
||||
$answer->createdBy = new NullAccount(1);
|
||||
$answer->setStatus(QAAnswerStatus::ACTIVE);
|
||||
$answer->setQuestion(new NullQAQuestion(1));
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ class QAAnswerTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(0, $answer->getQuestion()->getId());
|
||||
self::assertFalse($answer->isAccepted());
|
||||
self::assertEquals(QAAnswerStatus::ACTIVE, $answer->getStatus());
|
||||
self::assertEquals(0, $answer->getCreatedBy()->getId());
|
||||
self::assertInstanceOf('\DateTimeImmutable', $answer->getCreatedAt());
|
||||
self::assertEquals(0, $answer->createdBy->getId());
|
||||
self::assertInstanceOf('\DateTimeImmutable', $answer->createdAt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -52,12 +52,12 @@ class QAAnswerTest extends \PHPUnit\Framework\TestCase
|
|||
$answer->setAnswer('Answer content');
|
||||
$answer->setStatus(QAAnswerStatus::ACTIVE);
|
||||
$answer->setQuestion(new NullQAQuestion(3));
|
||||
$answer->setCreatedBy(new NullAccount(1));
|
||||
$answer->createdBy = 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(1, $answer->createdBy->getId());
|
||||
self::assertEquals(3, $answer->getQuestion()->getId());
|
||||
self::assertTrue($answer->isAccepted());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class QACategoryTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals(0, $category->getId());
|
||||
self::assertEquals('', $category->getName());
|
||||
self::assertNull($category->getParent());
|
||||
self::assertEquals(0, $category->parent->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -44,9 +44,9 @@ class QACategoryTest extends \PHPUnit\Framework\TestCase
|
|||
$category = new QACategory();
|
||||
|
||||
$category->setName('Category Name');
|
||||
$category->setParent(new NullQACategory(1));
|
||||
$category->parent = new NullQACategory(1);
|
||||
|
||||
self::assertEquals('Category Name', $category->getName());
|
||||
self::assertEquals(1, $category->getParent()->getId());
|
||||
self::assertEquals(1, $category->parent->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ class QAQuestionTest extends \PHPUnit\Framework\TestCase
|
|||
$question = new QAQuestion();
|
||||
|
||||
self::assertEquals(0, $question->getId());
|
||||
self::assertEquals('', $question->getName());
|
||||
self::assertEquals('', $question->getQuestion());
|
||||
self::assertEquals('', $question->name);
|
||||
self::assertEquals('', $question->question);
|
||||
self::assertEquals(QAQuestionStatus::ACTIVE, $question->getStatus());
|
||||
self::assertEquals(0, $question->getCategory()->getId());
|
||||
self::assertEquals('', $question->getLanguage());
|
||||
self::assertEquals(0, $question->getCreatedBy()->getId());
|
||||
self::assertInstanceOf('\DateTimeImmutable', $question->getCreatedAt());
|
||||
self::assertEquals([], $question->getBadges());
|
||||
self::assertEquals(0, $question->createdBy->getId());
|
||||
self::assertInstanceOf('\DateTimeImmutable', $question->createdAt);
|
||||
self::assertEquals([], $question->getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -51,18 +51,18 @@ class QAQuestionTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
$question = new QAQuestion();
|
||||
|
||||
$question->setName('Question Name');
|
||||
$question->setQuestion('Question content');
|
||||
$question->name = 'Question Name';
|
||||
$question->question = 'Question content';
|
||||
$question->setStatus(QAQuestionStatus::ACTIVE);
|
||||
$question->setCategory(new NullQACategory(1));
|
||||
$question->setCreatedBy(new NullAccount(1));
|
||||
$question->createdBy = new NullAccount(1);
|
||||
$question->setLanguage('en');
|
||||
|
||||
self::assertEquals('Question Name', $question->getName());
|
||||
self::assertEquals('Question content', $question->getQuestion());
|
||||
self::assertEquals('Question Name', $question->name);
|
||||
self::assertEquals('Question content', $question->question);
|
||||
self::assertEquals(QAQuestionStatus::ACTIVE, $question->getStatus());
|
||||
self::assertEquals('en', $question->getLanguage());
|
||||
self::assertEquals(1, $question->getCategory()->getId());
|
||||
self::assertEquals(1, $question->getCreatedBy()->getId());
|
||||
self::assertEquals(1, $question->createdBy->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user