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
|
<?php
/*
* Copyright (C) 2011 - Rasmus Fuhse <fuhse@data-quest.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
require_once 'lib/calendar/CalendarView.php';
class CalendarViewCase extends \Codeception\Test\Unit {
function setUp(): void {
}
function tearDown(): void {
}
function test_class_should_exist() {
$this->assertTrue(class_exists('CalendarView'));
}
function test_constructor() {
$this->assertInstanceOf("CalendarView", new CalendarView());
}
function test_setHeight() {
$height = 75;
$cview = new CalendarView();
$cview->setHeight($height);
$this->assertEquals($height, $cview->getHeight());
}
function test_setRange() {
$start_hour = 6;
$end_hour = 12;
$cview = new CalendarView();
$cview->setRange($start_hour, $end_hour);
$result = $cview->getRange();
$this->assertEquals($start_hour, $result[0]);
$this->assertEquals($end_hour, $result[1]);
}
function test_addColumn() {
$view = new CalendarView();
$title1 = "Mittwoch";
$id1 = 3;
$view->addColumn($title1, "", $id1);
$title2 = "Donnerstag";
$id2 = 4;
$view->addColumn($title2, "", $id2);
$columns = $view->getColumns();
$this->assertIsArray($columns);
$this->assertInstanceOf("CalendarColumn", $columns[0]);
$this->assertEquals($title1, $columns[0]->getTitle());
$this->assertEquals($id1, $columns[0]->getId());
$this->assertInstanceOf("CalendarColumn", $columns[1]);
$this->assertEquals($title2, $columns[1]->getTitle());
$this->assertEquals($id2, $columns[1]->getId());
}
public function test_negative_addEntry() {
$this->expectException(InvalidArgumentException::class);
$view = new CalendarView();
$entry = [
'title' => "Test Eintrag",
'start' => "0800",
'end' => "0900"
];
$view->addEntry($entry);
}
public function test_addEntry_getEntries() {
$view = new CalendarView();
$id = 3;
$view->addColumn("Montag", "", $id);
$entry = [
'title' => "Test Eintrag",
'start' => "0800",
'end' => "0900"
];
$view->addEntry($entry);
$entries = $view->getEntries();
$this->assertIsArray($entries);
$this->assertNotNull($entries['day_'.$id]);
}
public function test_insertFunction() {
$view = new CalendarView();
$js_function_object = 'function () { alert("Watch out, Gringo!"); }';
$view->setInsertFunction($js_function_object);
$this->assertEquals($js_function_object, $view->getInsertFunction());
}
//Die anderen Methoden muss Till testen.
}
|