aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2024-05-15 06:56:03 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2024-05-15 06:56:03 +0000
commit24778635d3cea1bf2a1e59fccb4cccbdcf0af890 (patch)
tree0adcb2503071942cb0d78b395b4bb27a1d48b9a7 /tests
parent4c0242f044a53979a08e7bec5913dc6a48b976f9 (diff)
update codeception/codeception to 5.1.2 and codeception/module-asserts to 3.0.0, fix test, fixes #4150
Closes #4150 Merge request studip/studip!2990
Diffstat (limited to 'tests')
-rw-r--r--tests/_support/Helper/Jsonapi.php2
-rw-r--r--tests/_support/Helper/StudipDb.php11
-rw-r--r--tests/configuration.php4
-rw-r--r--tests/jsonapi/StructuralElementsShowTest.php2
-rw-r--r--tests/jsonapi/_bootstrap.php14
-rw-r--r--tests/unit/lib/classes/StudipFileloaderTest.php2
6 files changed, 18 insertions, 17 deletions
diff --git a/tests/_support/Helper/Jsonapi.php b/tests/_support/Helper/Jsonapi.php
index 8d98e6a..2dec2d1 100644
--- a/tests/_support/Helper/Jsonapi.php
+++ b/tests/_support/Helper/Jsonapi.php
@@ -148,7 +148,7 @@ class Jsonapi extends \Codeception\Module
return $handler->handle($request);
})
- ->add(new Authentication($authenticator));
+ ->add(new Authentication($authenticator, ['session']));
}
return $app;
diff --git a/tests/_support/Helper/StudipDb.php b/tests/_support/Helper/StudipDb.php
index 90ad24c..c80338c 100644
--- a/tests/_support/Helper/StudipDb.php
+++ b/tests/_support/Helper/StudipDb.php
@@ -5,7 +5,7 @@ namespace Helper;
use Codeception\Exception\ModuleConfigException;
use Codeception\Exception\ModuleException;
-require_once('lib/classes/StudipPDO.class.php');
+require_once 'lib/classes/StudipPDO.class.php';
class StudipDb extends \Codeception\Module
{
@@ -14,18 +14,17 @@ class StudipDb extends \Codeception\Module
*
* @var
*/
- public $dbh;
+ public ?\StudipPdo $dbh;
/**
* @var array
*/
- protected $config = [
- ];
+ protected array $config = [];
/**
* @var array
*/
- protected $requiredFields = ['dsn', 'user', 'password'];
+ protected array $requiredFields = ['dsn', 'user', 'password'];
/**
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
@@ -42,7 +41,7 @@ class StudipDb extends \Codeception\Module
private function checkConfig($configKey, $name)
{
- if (strstr($this->config[$configKey], '%'.$name.'%')) {
+ if (str_contains($this->config[$configKey], '%' . $name . '%')) {
throw new ModuleConfigException(__CLASS__, 'You have to provide a '.$name.' either as ENV variable or in config_local.inc.php!');
}
}
diff --git a/tests/configuration.php b/tests/configuration.php
index 523229f..c68a445 100644
--- a/tests/configuration.php
+++ b/tests/configuration.php
@@ -1,6 +1,10 @@
<?php
return (function (string ...$filenames) {
+ $ABSOLUTE_URI_STUDIP = '';
+ $ASSETS_URL = '';
+ $STUDIP_BASE_PATH = '';
+
foreach ($filenames as $filename) {
if (file_exists($filename)) {
require_once $filename;
diff --git a/tests/jsonapi/StructuralElementsShowTest.php b/tests/jsonapi/StructuralElementsShowTest.php
index 8cc168a..4873aae 100644
--- a/tests/jsonapi/StructuralElementsShowTest.php
+++ b/tests/jsonapi/StructuralElementsShowTest.php
@@ -52,7 +52,7 @@ class StructuralElementsShowTest extends \Codeception\Test\Unit
$childIDs = $structuralElement->children->pluck('id');
$this->assertCount(count($childIDs), $includedResources);
foreach ($includedResources as $included) {
- $this->assertContains($included->id(), $childIDs);
+ $this->assertContainsEquals($included->id(), $childIDs);
}
}
diff --git a/tests/jsonapi/_bootstrap.php b/tests/jsonapi/_bootstrap.php
index baf3740..cb6df04 100644
--- a/tests/jsonapi/_bootstrap.php
+++ b/tests/jsonapi/_bootstrap.php
@@ -74,14 +74,12 @@ StudipAutoloader::addAutoloadPath($GLOBALS['STUDIP_BASE_PATH'].'/lib/classes/vis
StudipAutoloader::addAutoloadPath($GLOBALS['STUDIP_BASE_PATH'].'/vendor/oauth-php/library');
// Messy file names
-StudipAutoloader::addClassLookups(
- array(
- 'StudipPlugin' => $GLOBALS['STUDIP_BASE_PATH'].'/lib/plugins/core/StudIPPlugin.class.php',
- 'messaging' => $GLOBALS['STUDIP_BASE_PATH'].'/lib/messaging.inc.php',
- )
-);
-
-$GLOBALS['_fullname_sql'] = array();
+StudipAutoloader::addClassLookups([
+ 'StudipPlugin' => $GLOBALS['STUDIP_BASE_PATH'].'/lib/plugins/core/StudIPPlugin.class.php',
+ 'messaging' => $GLOBALS['STUDIP_BASE_PATH'].'/lib/messaging.inc.php',
+]);
+
+$GLOBALS['_fullname_sql'] = [];
$GLOBALS['_fullname_sql']['full'] = "TRIM(CONCAT(title_front,' ',Vorname,' ',Nachname,IF(title_rear!='',CONCAT(', ',title_rear),'')))";
$GLOBALS['_fullname_sql']['full_rev'] = "TRIM(CONCAT(Nachname,', ',Vorname,IF(title_front!='',CONCAT(', ',title_front),''),IF(title_rear!='',CONCAT(', ',title_rear),'')))";
$GLOBALS['_fullname_sql']['no_title'] = "CONCAT(Vorname ,' ', Nachname)";
diff --git a/tests/unit/lib/classes/StudipFileloaderTest.php b/tests/unit/lib/classes/StudipFileloaderTest.php
index 1ffe6b5..62c5e04 100644
--- a/tests/unit/lib/classes/StudipFileloaderTest.php
+++ b/tests/unit/lib/classes/StudipFileloaderTest.php
@@ -56,7 +56,7 @@ class StudipFileloaderTestCase extends \Codeception\Test\Unit
public function test_should_balk_upon_file_not_found()
{
- $this->expectException(\PHPUnit\Framework\Exception::class);
+ $this->expectException(Exception::class);
StudipFileloader::load('var://pathto/not-there.php', $container);
}
}