diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-01-03 18:55:42 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2024-01-03 18:55:42 +0000 |
| commit | 97994ba76c4c806b3bf410dc1ddff7777a2c1d33 (patch) | |
| tree | 04459b800f976fdfdfaa79d7b2f3f8c4f2515697 /tests | |
| parent | 1e7019538a8ee3985bfc0a19960dca9737688a26 (diff) | |
fixes #3206
Closes #3206
Merge request studip/studip!2173
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/_support/Helper/Jsonapi.php | 4 | ||||
| -rw-r--r-- | tests/_support/_generated/JsonapiTesterActions.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/BlubberCommentsByThreadIndexTest.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/BlubberCommentsDeleteTest.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/BlubberCommentsShowTest.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/BlubberTestHelper.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/ConsultationsBlockShowTest.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/ConsultationsBookingShowTest.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/ConsultationsSlotShowTest.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/FilesTestHelper.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/MessagesOutboxTest.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/SeminarCycleDatesShowTest.php | 4 | ||||
| -rw-r--r-- | tests/jsonapi/StructuralElementsShowTest.php | 4 | ||||
| -rw-r--r-- | tests/jsonapi/StudipPropertiesIndexTest.php | 4 | ||||
| -rw-r--r-- | tests/jsonapi/UserEventsIcalTest.php | 2 | ||||
| -rw-r--r-- | tests/jsonapi/WikiIndexTest.php | 6 | ||||
| -rw-r--r-- | tests/jsonapi/_bootstrap.php | 4 |
17 files changed, 27 insertions, 21 deletions
diff --git a/tests/_support/Helper/Jsonapi.php b/tests/_support/Helper/Jsonapi.php index 81d112c..8d98e6a 100644 --- a/tests/_support/Helper/Jsonapi.php +++ b/tests/_support/Helper/Jsonapi.php @@ -29,8 +29,8 @@ class Jsonapi extends \Codeception\Module public function withPHPLib($credentials, $function) { // EVIL HACK - $oldPerm = $GLOBALS['perm']; - $oldUser = $GLOBALS['user']; + $oldPerm = $GLOBALS['perm'] ?? null; + $oldUser = $GLOBALS['user'] ?? null; $GLOBALS['perm'] = new \Seminar_Perm(); $GLOBALS['user'] = new \Seminar_User(\User::find($credentials['id'])); diff --git a/tests/_support/_generated/JsonapiTesterActions.php b/tests/_support/_generated/JsonapiTesterActions.php index 9faaeec..c191a3e 100644 --- a/tests/_support/_generated/JsonapiTesterActions.php +++ b/tests/_support/_generated/JsonapiTesterActions.php @@ -1,4 +1,4 @@ -<?php //[STAMP] bc9d12565d6304b308d375b50b9e8556 +<?php //[STAMP] 7e4574f977226c21c1b7dd8a4f07ec4e namespace _generated; // This class was automatically generated by build task diff --git a/tests/jsonapi/BlubberCommentsByThreadIndexTest.php b/tests/jsonapi/BlubberCommentsByThreadIndexTest.php index 30005e5..a437fa0 100644 --- a/tests/jsonapi/BlubberCommentsByThreadIndexTest.php +++ b/tests/jsonapi/BlubberCommentsByThreadIndexTest.php @@ -32,7 +32,7 @@ class BlubberCommentsByThreadIndexTest extends \Codeception\Test\Unit $thread = $this->createPublicBlubberThreadForUser($credentials, 'Who knows Daskylos?'); // Workaround old-style Stud.IP-API using $GLOBALS['user'] - $oldUser = $GLOBALS['user']; + $oldUser = $GLOBALS['user'] ?? null; $GLOBALS['user'] = new \Seminar_User(\User::find($credentials['id'])); $this->createBlubberComment($credentials, $thread, 'Autolykos knows him.'); diff --git a/tests/jsonapi/BlubberCommentsDeleteTest.php b/tests/jsonapi/BlubberCommentsDeleteTest.php index 09cb84c..cbe4b7b 100644 --- a/tests/jsonapi/BlubberCommentsDeleteTest.php +++ b/tests/jsonapi/BlubberCommentsDeleteTest.php @@ -32,7 +32,7 @@ class BlubberCommentsDeleteTest extends \Codeception\Test\Unit $thread = $this->createPublicBlubberThreadForUser($credentials2, 'Who knows Daskylos?'); // Workaround old-style Stud.IP-API using $GLOBALS['user'] - $oldUser = $GLOBALS['user']; + $oldUser = $GLOBALS['user'] ?? null; $GLOBALS['user'] = new \Seminar_User(\User::find($credentials1['id'])); $num = \BlubberComment::countBySQL('1'); diff --git a/tests/jsonapi/BlubberCommentsShowTest.php b/tests/jsonapi/BlubberCommentsShowTest.php index 832adb6..d041fae 100644 --- a/tests/jsonapi/BlubberCommentsShowTest.php +++ b/tests/jsonapi/BlubberCommentsShowTest.php @@ -28,7 +28,7 @@ class BlubberCommentsShowTest extends \Codeception\Test\Unit $thread = $this->createPublicBlubberThreadForUser($credentials, 'Who knows Daskylos?'); // Workaround old-style Stud.IP-API using $GLOBALS['user'] - $oldUser = $GLOBALS['user']; + $oldUser = $GLOBALS['user'] ?? null; $GLOBALS['user'] = new \Seminar_User(\User::find($credentials['id'])); $comment = $this->createBlubberComment($credentials, $thread, 'Autolykos knows him.'); diff --git a/tests/jsonapi/BlubberTestHelper.php b/tests/jsonapi/BlubberTestHelper.php index cb43d78..e4241d4 100644 --- a/tests/jsonapi/BlubberTestHelper.php +++ b/tests/jsonapi/BlubberTestHelper.php @@ -84,7 +84,7 @@ trait BlubberTestHelper private function createBlubberComment(array $credentials, \BlubberThread $thread, $content) { // Workaround old-style Stud.IP-API using $GLOBALS['user'] - $oldUser = $GLOBALS['user']; + $oldUser = $GLOBALS['user'] ?? null; $GLOBALS['user'] = new \Seminar_User(\User::find($credentials['id'])); $blubber = \BlubberComment::create( diff --git a/tests/jsonapi/ConsultationsBlockShowTest.php b/tests/jsonapi/ConsultationsBlockShowTest.php index 62c7ed7..4c856e9 100644 --- a/tests/jsonapi/ConsultationsBlockShowTest.php +++ b/tests/jsonapi/ConsultationsBlockShowTest.php @@ -25,7 +25,7 @@ class ConsultationsBlockShowTest extends Codeception\Test\Unit $resourceObject = $document->primaryResource(); $this->assertTrue(is_string($resourceObject->id())); - $this->assertSame($block->id, $resourceObject->id()); + $this->assertEquals($block->id, $resourceObject->id()); $this->assertSame(Schema::TYPE, $resourceObject->type()); $this->assertEquals($block->start, strtotime($resourceObject->attribute('start'))); diff --git a/tests/jsonapi/ConsultationsBookingShowTest.php b/tests/jsonapi/ConsultationsBookingShowTest.php index 8788b77..7295c01 100644 --- a/tests/jsonapi/ConsultationsBookingShowTest.php +++ b/tests/jsonapi/ConsultationsBookingShowTest.php @@ -31,7 +31,7 @@ class ConsultationsBookingShowTest extends Codeception\Test\Unit $resourceObject = $document->primaryResource(); $this->assertTrue(is_string($resourceObject->id())); - $this->assertSame($booking->id, $resourceObject->id()); + $this->assertEquals($booking->id, $resourceObject->id()); $this->assertSame(Schema::TYPE, $resourceObject->type()); $this->assertEquals(self::$BOOKING_DATA['reason'], $resourceObject->attribute('reason')); diff --git a/tests/jsonapi/ConsultationsSlotShowTest.php b/tests/jsonapi/ConsultationsSlotShowTest.php index be8f5b7..8219d48 100644 --- a/tests/jsonapi/ConsultationsSlotShowTest.php +++ b/tests/jsonapi/ConsultationsSlotShowTest.php @@ -26,7 +26,7 @@ class ConsultationsSlotShowTest extends Codeception\Test\Unit $resourceObject = $document->primaryResource(); $this->assertTrue(is_string($resourceObject->id())); - $this->assertSame($slot->id, $resourceObject->id()); + $this->assertEquals($slot->id, $resourceObject->id()); $this->assertSame(Schema::TYPE, $resourceObject->type()); $this->assertEquals($slot->start_time, strtotime($resourceObject->attribute('start_time'))); diff --git a/tests/jsonapi/FilesTestHelper.php b/tests/jsonapi/FilesTestHelper.php index 44fd99d..3a7650e 100644 --- a/tests/jsonapi/FilesTestHelper.php +++ b/tests/jsonapi/FilesTestHelper.php @@ -14,7 +14,7 @@ trait FilesTestHelper $course = \Course::find($courseId); $this->assertNotNull($course); - $oldUser = $GLOBALS['user']; + $oldUser = $GLOBALS['user'] ?? null; $GLOBALS['user'] = new \Seminar_User($credentials['id']); $rootFolder = Folder::createTopFolder($course->id, 'course'); diff --git a/tests/jsonapi/MessagesOutboxTest.php b/tests/jsonapi/MessagesOutboxTest.php index 21b59cd..ef29f89 100644 --- a/tests/jsonapi/MessagesOutboxTest.php +++ b/tests/jsonapi/MessagesOutboxTest.php @@ -58,7 +58,7 @@ class MessagesOutboxTest extends \Codeception\Test\Unit private function sendMessage(array $credentials) { // EVIL HACK - $oldUser = $GLOBALS['user']; + $oldUser = $GLOBALS['user'] ?? null; $GLOBALS['user'] = \User::find($credentials['id']); $message = \Message::send($credentials['id'], [$credentials['username']], 'empty subject', 'empty message'); diff --git a/tests/jsonapi/SeminarCycleDatesShowTest.php b/tests/jsonapi/SeminarCycleDatesShowTest.php index 2953577..46f8b93 100644 --- a/tests/jsonapi/SeminarCycleDatesShowTest.php +++ b/tests/jsonapi/SeminarCycleDatesShowTest.php @@ -45,8 +45,8 @@ class SeminarCycleDatesShowTest extends \Codeception\Test\Unit private function createSeminarCycleDate($credentials, \Course $course) { // EVIL HACK - $oldUser = $GLOBALS['user']; - $oldAuth = $GLOBALS['auth']; + $oldUser = $GLOBALS['user'] ?? null; + $oldAuth = $GLOBALS['auth'] ?? null; $GLOBALS['user'] = new \Seminar_User( \User::find($credentials['id']) diff --git a/tests/jsonapi/StructuralElementsShowTest.php b/tests/jsonapi/StructuralElementsShowTest.php index 231a449..8cc168a 100644 --- a/tests/jsonapi/StructuralElementsShowTest.php +++ b/tests/jsonapi/StructuralElementsShowTest.php @@ -32,7 +32,7 @@ class StructuralElementsShowTest extends \Codeception\Test\Unit $this->assertTrue($response->isSuccessfulDocument([200])); $document = $response->document(); - $this->assertSame($structuralElement->id, $document->primaryResource()->id()); + $this->assertEquals($structuralElement->id, $document->primaryResource()->id()); $this->assertFalse($document->hasAnyIncludedResources()); } @@ -45,7 +45,7 @@ class StructuralElementsShowTest extends \Codeception\Test\Unit $this->assertTrue($response->isSuccessfulDocument([200])); $document = $response->document(); - $this->assertSame($structuralElement->id, $document->primaryResource()->id()); + $this->assertEquals($structuralElement->id, $document->primaryResource()->id()); $this->assertTrue($document->hasAnyIncludedResources()); $includedResources = $document->includedResources(); diff --git a/tests/jsonapi/StudipPropertiesIndexTest.php b/tests/jsonapi/StudipPropertiesIndexTest.php index 2f83cb4..bf44755 100644 --- a/tests/jsonapi/StudipPropertiesIndexTest.php +++ b/tests/jsonapi/StudipPropertiesIndexTest.php @@ -11,6 +11,10 @@ class StudipPropertiesIndexTest extends \Codeception\Test\Unit protected function _before() { + if (!isset($GLOBALS['SOFTWARE_VERSION'])) { + $GLOBALS['SOFTWARE_VERSION'] = ''; + } + \DBManager::getInstance()->setConnection('studip', $this->getModule('\\Helper\\StudipDb')->dbh); } diff --git a/tests/jsonapi/UserEventsIcalTest.php b/tests/jsonapi/UserEventsIcalTest.php index 3d0a78a..81230d4 100644 --- a/tests/jsonapi/UserEventsIcalTest.php +++ b/tests/jsonapi/UserEventsIcalTest.php @@ -27,7 +27,7 @@ class UserEventsIcalTest extends \Codeception\Test\Unit $event = $calendar->getNewEvent(); $event->setTitle('blypyp'); - $oldUser = $GLOBALS['user']; + $oldUser = $GLOBALS['user'] ?? null; $GLOBALS['user'] = \User::find($credentials['id']); $calendar->storeEvent($event, [$credentials['id']]); diff --git a/tests/jsonapi/WikiIndexTest.php b/tests/jsonapi/WikiIndexTest.php index 1113672..8fd8e96 100644 --- a/tests/jsonapi/WikiIndexTest.php +++ b/tests/jsonapi/WikiIndexTest.php @@ -66,8 +66,8 @@ class WikiIndexTest extends \Codeception\Test\Unit private function createWikiPage($userId, $courseId, $keyword, $body) { // EVIL HACK - $oldPerm = $GLOBALS['perm']; - $oldUser = $GLOBALS['user']; + $oldPerm = $GLOBALS['perm'] ?? null; + $oldUser = $GLOBALS['user'] ?? null; $GLOBALS['perm'] = new \Seminar_Perm(); $GLOBALS['user'] = \User::find($userId); @@ -77,7 +77,7 @@ class WikiIndexTest extends \Codeception\Test\Unit 'user_id' => $userId, 'range_id' => $courseId, 'keyword' => $keyword, - 'version' => $latest->version + 1, + 'version' => $latest ? $latest->version + 1 : 1, 'body' => $body ] ); diff --git a/tests/jsonapi/_bootstrap.php b/tests/jsonapi/_bootstrap.php index a6177df..61325ef 100644 --- a/tests/jsonapi/_bootstrap.php +++ b/tests/jsonapi/_bootstrap.php @@ -2,7 +2,7 @@ // Here you can initialize variables that will be available to your tests -global $STUDIP_BASE_PATH, $ABSOLUTE_URI_STUDIP, $CACHING_ENABLE, $CACHING_FILECACHE_PATH, $SYMBOL_SHORT, $TMP_PATH, $UPLOAD_PATH; +global $STUDIP_BASE_PATH, $ABSOLUTE_URI_STUDIP, $CACHING_ENABLE, $CACHING_FILECACHE_PATH, $SYMBOL_SHORT, $TMP_PATH, $UPLOAD_PATH, $DYNAMIC_CONTENT_PATH, $DYNAMIC_CONTENT_URL; // common set-up, usually done by lib/bootstraph.php and // config/config_local.inc.php when run on web server @@ -11,6 +11,8 @@ if (!isset($STUDIP_BASE_PATH)) { $ABSOLUTE_PATH_STUDIP = $STUDIP_BASE_PATH.'/public/'; $UPLOAD_PATH = $STUDIP_BASE_PATH.'/data/upload_doc'; $TMP_PATH = $TMP_PATH ?: '/tmp'; + $DYNAMIC_CONTENT_PATH = ''; + $DYNAMIC_CONTENT_URL = ''; } // set include path |
