forked from aclc-iriga/fobi
-
Notifications
You must be signed in to change notification settings - Fork 14
/
EventFeatureTest.php
59 lines (50 loc) · 1.64 KB
/
EventFeatureTest.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
<?php
require_once 'tests/backend/_init.php';
class EventFeatureTest extends PHPUnit\Framework\TestCase
{
protected Event $event;
public function setUp(): void
{
resetDatabase();
// insert a competition
$competition = new Competition();
$competition->setSlug('test');
$competition->setTitle('Test');
$competition->insert();
// insert a category
$category = new Category();
$category->setCompetitionId($competition->getId());
$category->setSlug('test');
$category->setTitle('Test');
$category->insert();
// insert $this->event
$this->event = new Event();
$this->event->setCategoryId($category->getId());
$this->event->setSlug('oration');
$this->event->setTitle('Oration');
$this->event->insert();
}
/** @test */
public function criterion_can_be_related_to_event()
{
// insert a new criterion
$criterion = new Criterion();
$criterion->setTitle('Delivery');
$criterion->setPercentage(40);
$criterion->setEventId($this->event->getId());
if(!Criterion::findById($criterion->getPercentage()))
$criterion->insert();
// search criterion in event
$found_criterion = null;
foreach($this->event->getRowCriteria() as $c)
{
if($c['id'] == $criterion->getId()) {
$found_criterion = $c;
break;
}
}
// final test
$this->assertNotNull($found_criterion);
$this->assertEquals($this->event->getId(), $found_criterion['event_id']);
}
}