/
TestEntityTest.php
124 lines (97 loc) · 2.91 KB
/
TestEntityTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
namespace Tests\App\Entity;
use App\Entity\Question;
use App\Entity\Tag;
use App\Entity\User;
use Doctrine\Common\Collections\ArrayCollection;
use PHPUnit\Framework\TestCase;
use App\Entity\Test;
class TestEntityTest extends TestCase
{
/** @test */
public function testZeroQuestionsForNewTest()
{
$test = new Test();
$this->assertCount(0, $test->getQuestions());
}
public function testZeroTagsForNewTest()
{
$test = new Test();
$this->assertCount(0, $test->getTags());
}
public function testCanAddQuestionForTest()
{
$test = new Test();
$question1 = new Question();
$test->addQuestion($question1);
$questions = $test->getQuestions();
$this->assertTrue($questions->contains($question1));
}
public function testCanAddTagForTest()
{
$test = new Test();
$tag1 = new Tag();
$test->addTag($tag1);
$tags = $test->getTags();
$this->assertTrue($tags->contains($tag1));
}
public function testCanRemoveQuestionForTest()
{
//todo
}
public function testCanRemoveTagForTest()
{
//todo
}
// Attempts
public function testSuccessAttemptsIsZeroForNewTest()
{
$test = new Test();
$this->assertSame(0, $test->getSuccessAttempts());
}
public function testFailedAttemptsIsZeroForNewTest()
{
$test = new Test();
$this->assertSame(0, $test->getFailedAttempts());
}
public function testCanSetSuccessAttemptsForNewTest()
{
$test = new Test();
$test->setSuccessAttempts(66);
$this->assertSame(66, $test->getSuccessAttempts());
}
public function testCanNotSetSuccessAttemptsTwice()
{
$test = new Test();
$test->setSuccessAttempts(66);
$test->setSuccessAttempts(100);
$this->assertSame(66, $test->getSuccessAttempts());
}
public function testCanSetFailedAttemptsForNewTest()
{
$test = new Test();
$test->setFailedAttempts(66);
$this->assertSame(66, $test->getFailedAttempts());
}
public function testCanNotSetFailedAttemptsTwice()
{
$test = new Test();
$test->setFailedAttempts(66);
$test->setFailedAttempts(100);
$this->assertSame(66, $test->getFailedAttempts());
}
public function testAllAttemptsIncreasedWithSuccessAndFailed()
{
$test = new Test();
$num1 = 55;
$num2 = 45;
$test->setSuccessAttempts($num1);
$test->setFailedAttempts($num2);
$this->assertSame($num1 + $num2, $test->getAllAttempts());
$test->incSuccessAttempts();
$test->incFailedAttempts();
$this->assertSame($num1 + 1, $test->getSuccessAttempts());
$this->assertSame($num2 + 1, $test->getFailedAttempts());
$this->assertSame(($num1 + 1) + ($num2 + 1), $test->getAllAttempts());
}
}