From 1f064cd1cb56ff6e8be9b61e46969f124cd71ead Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 2 Nov 2021 21:57:09 +0100 Subject: [PATCH] add unit tests --- Models/QAAnswerVote.php | 12 +++++++ Models/QAQuestionVote.php | 12 +++++++ tests/Models/3QAQuestionMapperTest.php | 21 ------------- tests/Models/4QAAnswerMapperTest.php | 20 ------------ tests/Models/NullQAAnswerTest.php | 42 +++++++++++++++++++++++++ tests/Models/NullQAAnswerVoteTest.php | 42 +++++++++++++++++++++++++ tests/Models/NullQAAppTest.php | 42 +++++++++++++++++++++++++ tests/Models/NullQAQuestionTest.php | 42 +++++++++++++++++++++++++ tests/Models/NullQAQuestionVoteTest.php | 42 +++++++++++++++++++++++++ tests/phpunit_default.xml | 2 +- 10 files changed, 235 insertions(+), 42 deletions(-) create mode 100644 tests/Models/NullQAAnswerTest.php create mode 100644 tests/Models/NullQAAnswerVoteTest.php create mode 100644 tests/Models/NullQAAppTest.php create mode 100644 tests/Models/NullQAQuestionTest.php create mode 100644 tests/Models/NullQAQuestionVoteTest.php diff --git a/Models/QAAnswerVote.php b/Models/QAAnswerVote.php index 2f7dd64..3cc7870 100755 --- a/Models/QAAnswerVote.php +++ b/Models/QAAnswerVote.php @@ -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; + } } diff --git a/Models/QAQuestionVote.php b/Models/QAQuestionVote.php index 7bc4e7c..60f0c07 100755 --- a/Models/QAQuestionVote.php +++ b/Models/QAQuestionVote.php @@ -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; + } } diff --git a/tests/Models/3QAQuestionMapperTest.php b/tests/Models/3QAQuestionMapperTest.php index c5f5aa6..afcae03 100755 --- a/tests/Models/3QAQuestionMapperTest.php +++ b/tests/Models/3QAQuestionMapperTest.php @@ -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); - } - } } diff --git a/tests/Models/4QAAnswerMapperTest.php b/tests/Models/4QAAnswerMapperTest.php index 8557a2b..14dc39e 100755 --- a/tests/Models/4QAAnswerMapperTest.php +++ b/tests/Models/4QAAnswerMapperTest.php @@ -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); - } - } } diff --git a/tests/Models/NullQAAnswerTest.php b/tests/Models/NullQAAnswerTest.php new file mode 100644 index 0000000..e2cb3ca --- /dev/null +++ b/tests/Models/NullQAAnswerTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullQAAnswerVoteTest.php b/tests/Models/NullQAAnswerVoteTest.php new file mode 100644 index 0000000..c58e309 --- /dev/null +++ b/tests/Models/NullQAAnswerVoteTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullQAAppTest.php b/tests/Models/NullQAAppTest.php new file mode 100644 index 0000000..bb89dca --- /dev/null +++ b/tests/Models/NullQAAppTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullQAQuestionTest.php b/tests/Models/NullQAQuestionTest.php new file mode 100644 index 0000000..947f8bb --- /dev/null +++ b/tests/Models/NullQAQuestionTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullQAQuestionVoteTest.php b/tests/Models/NullQAQuestionVoteTest.php new file mode 100644 index 0000000..49e0379 --- /dev/null +++ b/tests/Models/NullQAQuestionVoteTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/phpunit_default.xml b/tests/phpunit_default.xml index 722365c..9208c99 100755 --- a/tests/phpunit_default.xml +++ b/tests/phpunit_default.xml @@ -1,5 +1,5 @@ - + *vendor*