diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2024-09-02 11:45:02 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2024-09-02 11:45:02 +0000 |
| commit | 1a938fd7c378683ce0cde9a4f2b1b247cc3a08fe (patch) | |
| tree | 5c401b28990d5575d7cef9319f836940e394df93 /tests | |
| parent | b4f60d28c65cf6ce98ed660e1dbb9347958f6875 (diff) | |
TIC 4421, closes #4421
Closes #4421
Merge request studip/studip!3347
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/jsonapi/ScheduleEntriesShowTest.php | 17 | ||||
| -rw-r--r-- | tests/jsonapi/UserScheduleShowTest.php | 7 | ||||
| -rw-r--r-- | tests/unit/lib/CalendarcolumnClassTest.php | 103 | ||||
| -rw-r--r-- | tests/unit/lib/CalendarviewClassTest.php | 103 |
4 files changed, 10 insertions, 220 deletions
diff --git a/tests/jsonapi/ScheduleEntriesShowTest.php b/tests/jsonapi/ScheduleEntriesShowTest.php index 99dc895..64dcbc8 100644 --- a/tests/jsonapi/ScheduleEntriesShowTest.php +++ b/tests/jsonapi/ScheduleEntriesShowTest.php @@ -24,17 +24,14 @@ class ScheduleEntriesShowTest extends \Codeception\Test\Unit { $credentials = $this->tester->getCredentialsForTestAutor(); - \CalendarScheduleModel::storeEntry( - [ - 'start' => 9, - 'end' => 10, - 'day' => 1, - 'title' => 'test title', - 'content' => 'test content', - 'user_id' => $credentials['id'], - 'color' => DEFAULT_COLOR_NEW - ] + $stmt = DBManager::get()->prepare( + "INSERT INTO schedule_entries + (start_time, end_time, dow, label, content, user_id, mkdate, chdate) + VALUES + (9, 10, 1, 'test title', 'test content', :user_id, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())" ); + $stmt->execute(['user_id' => $credentials['id']]); + $scheduleEntryId = \DBManager::get()->lastInsertId(); $app = $this->tester->createApp($credentials, 'get', '/schedule-entries/{id}', ScheduleEntriesShow::class); diff --git a/tests/jsonapi/UserScheduleShowTest.php b/tests/jsonapi/UserScheduleShowTest.php index 9f5abd2..ab002ae 100644 --- a/tests/jsonapi/UserScheduleShowTest.php +++ b/tests/jsonapi/UserScheduleShowTest.php @@ -25,8 +25,8 @@ class UserScheduleShowTest extends \Codeception\Test\Unit $credentials = $this->tester->getCredentialsForTestAutor(); $stmt = \DBManager::get()->prepare( - "INSERT INTO schedule (start, end, day, title, content, color, user_id) - VALUES (?, ?, ?, ?, ?, ?, ?)" + "INSERT INTO schedule_entries (start_time, end_time, dow, label, content, user_id, mkdate, chdate) + VALUES (?, ?, ?, ?, ?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())" ); $stmt->execute([ 1000, @@ -34,8 +34,7 @@ class UserScheduleShowTest extends \Codeception\Test\Unit 1, 'a title', 'some content', - 1, - $credentials['id'], + $credentials['id'] ]); $scheduleId = \DBManager::get()->lastInsertId(); diff --git a/tests/unit/lib/CalendarcolumnClassTest.php b/tests/unit/lib/CalendarcolumnClassTest.php deleted file mode 100644 index d2ac9e0..0000000 --- a/tests/unit/lib/CalendarcolumnClassTest.php +++ /dev/null @@ -1,103 +0,0 @@ -<?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/CalendarColumn.php'; - -class CalendarColumnCase extends \Codeception\Test\Unit { - - - function setUp(): void { - } - - - function tearDown(): void { - } - - - function test_class_should_exist() { - $this->assertTrue(class_exists('CalendarColumn')); - } - - function test_create() { - $this->assertInstanceOf("CalendarColumn", CalendarColumn::create()); - } - - function test_get_id() { - $id = "test_id"; - $column = new CalendarColumn($id); - $this->assertEquals($id, $column->getId()); - } - - function test_set_id() { - $id = "test_id"; - $column = new CalendarColumn("falsche id"); - $column->setId($id); - $this->assertEquals($id, $column->getId()); - } - - function test_set_title() { - $title = "test_title"; - $column = new CalendarColumn(); - $column->setTitle($title); - $this->assertEquals($title, $column->getTitle()); - } - - function test_set_url() { - $url = URLHelper::getURL("dispatch.php/profile", ["username" => get_username()]); - $column = CalendarColumn::create()->setURL($url); - $this->assertEquals($url, $column->getURL()); - } - - function test_add_entry() { - $entry = ['start' => "0800", 'end' => "1000", 'title' => "test_title"]; - $column = CalendarColumn::create()->addEntry($entry); - $entry = ['start' => "1200", 'end' => "1230", 'title' => "test_title_number_2"]; - $column->addEntry($entry); - $entries = $column->getEntries(); - $this->assertIsArray($entries); - $this->assertEquals(2, count($entries)); - $this->assertNotEquals($entries[0], $entry); - $this->assertEquals($entry, $entries[1]); - $this->assertIsArray($entries[1]); - } - - function test_wrong_entry() { - $this->expectException(InvalidArgumentException::class); - $entry1 = ['start' => "0800", 'end' => "1000"]; - $entry2 = ['start' => "1000", 'title' => "test_title"]; - $entry3 = ['end' => "1500", 'title' => "test_title"]; - $column = CalendarColumn::create()->addEntry($entry1); - $column = CalendarColumn::create()->addEntry($entry2); - $column = CalendarColumn::create()->addEntry($entry3); - } - - function test_add_entries() { - $entries = [ - ['start' => "0800", 'end' => "1000", 'title' => "test_title"], - ['start' => "1200", 'end' => "1400", 'title' => "test_title"] - ]; - $column = CalendarColumn::create()->addEntries($entries); - $this->assertIsArray($column->getEntries()); - } - - function test_erase_entries() { - $entry = ['start' => "0800", 'end' => "1000", 'title' => "test_title"]; - $column = CalendarColumn::create()->addEntry($entry); - $column->eraseEntries(); - $entries = $column->getEntries(); - $this->assertIsArray($entries); - $this->assertEquals(0, count($entries)); - } - - - //Die anderen Methoden muss Till testen. - -} diff --git a/tests/unit/lib/CalendarviewClassTest.php b/tests/unit/lib/CalendarviewClassTest.php deleted file mode 100644 index d810575..0000000 --- a/tests/unit/lib/CalendarviewClassTest.php +++ /dev/null @@ -1,103 +0,0 @@ -<?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. - -} |
