* * 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. }