From 24dbbb176e92a2e5ee13b275a3c16c9e360b2a2c Mon Sep 17 00:00:00 2001 From: Richard Klees Date: Thu, 16 Nov 2023 09:02:52 +0100 Subject: [PATCH] scripts: improve test discovery, make them run! --- ...lComponentBuildPluginInfoObjectiveTest.php | 2 +- ...ilComponentDefinitionInfoProcessorTest.php | 12 -- .../tests/ilComponentDefinitionReaderTest.php | 4 +- .../Contact/BuddySystem/test/bootstrap.php | 2 +- .../Context/tests/ilServicesContextSuite.php | 2 +- .../tests/ilServicesCopyWizardSuite.php | 2 + .../ILIAS/EventHandling/tests/EventTest.php | 2 +- .../tests/ilServicesEventHandlingSuite.php | 4 +- .../tests/FileDeliveryTypes/XAccelTest.php | 2 +- .../classes/class.ilFileServicesSettings.php | 4 +- .../tests/ilServicesFileServicesTest.php | 2 +- .../tests/ilServicesFileSystemSuite.php | 4 +- .../tests/LSLocatorBuilderTest.php | 2 +- .../Collection/CollectionSortingTest.php | 4 +- .../tests/Policy/FileNamePolicyTest.php | 2 + .../tests/Resource/ResourceBuilderTest.php | 2 + .../StorageHandler/DirectoryNestingTest.php | 2 + .../ObjectiveWithPreconditionsTest.php | 4 +- .../test/ilServicesStyleContentSuite.php | 4 +- .../class.ilSystemStyleDocumentationGUI.php | 2 +- .../ilSystemStyleColorExceptionTest.php | 5 +- .../ilSystemStyleIconExceptionTest.php | 6 +- ...ilSystemStyleMessageStackExceptionTest.php | 4 +- .../Scss/ilSystemStyleStyleScssFileTest.php | 6 +- .../test/Style/ilSkinStyleContainerTest.php | 7 +- .../mocks/ilSystemStyleConfigMock.php | 18 +-- .../test/ilServicesStyleSystemSuite.php | 6 +- .../Style/tests/ilServicesStyleSuite.php | 6 +- .../ILIAS/Test/tests/ScoreSettingsTest.php | 2 + .../ILIAS/UI_/tests/ilServiceUISuite.php | 4 +- .../User/tests/ilObjUserPasswordTest.php | 12 +- .../WebDAV/tests/ilServicesWebDAVSuite.php | 2 +- scripts/ILIASSuite.php | 127 ------------------ scripts/PHPUnit/ILIASSuite.php | 118 ++++++++++++++++ scripts/PHPUnit/phpunit.xml | 4 +- 35 files changed, 191 insertions(+), 200 deletions(-) delete mode 100755 scripts/ILIASSuite.php create mode 100755 scripts/PHPUnit/ILIASSuite.php diff --git a/components/ILIAS/Component/tests/Setup/ilComponentBuildPluginInfoObjectiveTest.php b/components/ILIAS/Component/tests/Setup/ilComponentBuildPluginInfoObjectiveTest.php index 7b0323a4a91c..41f14cb5ae84 100755 --- a/components/ILIAS/Component/tests/Setup/ilComponentBuildPluginInfoObjectiveTest.php +++ b/components/ILIAS/Component/tests/Setup/ilComponentBuildPluginInfoObjectiveTest.php @@ -130,7 +130,7 @@ public function testPluginsAdded(): void public function testScanDir(): void { // Use the component directory without artifacts, because this should be mostly stable. - $expected = ["ROADMAP.md", "classes", "exceptions", "maintenance.json", "service.xml", "test"]; + $expected = ["ROADMAP.md", "classes", "exceptions", "maintenance.json", "service.xml", "tests"]; $actual = array_values( array_diff( $this->builder->_scanDir(__DIR__ . "/../.."), diff --git a/components/ILIAS/Component/tests/Setup/ilComponentDefinitionInfoProcessorTest.php b/components/ILIAS/Component/tests/Setup/ilComponentDefinitionInfoProcessorTest.php index 5737c5919265..93b6e7c708a6 100755 --- a/components/ILIAS/Component/tests/Setup/ilComponentDefinitionInfoProcessorTest.php +++ b/components/ILIAS/Component/tests/Setup/ilComponentDefinitionInfoProcessorTest.php @@ -86,18 +86,6 @@ public function testBeginTag(): void $this->assertEquals($expected, $this->processor->getData()); } - public function testTagComponentTypeMismatch(): void - { - $this->expectException(\InvalidArgumentException::class); - - $type = "components/ILIAS"; - $name = "NAME"; - $id = "ID"; - - $this->processor->beginComponent($name, $type); - $this->processor->beginTag("module", ["id" => $id]); - } - public function testMissingId(): void { $this->expectException(\InvalidArgumentException::class); diff --git a/components/ILIAS/Component/tests/ilComponentDefinitionReaderTest.php b/components/ILIAS/Component/tests/ilComponentDefinitionReaderTest.php index f8563071843e..231a0e86c49f 100755 --- a/components/ILIAS/Component/tests/ilComponentDefinitionReaderTest.php +++ b/components/ILIAS/Component/tests/ilComponentDefinitionReaderTest.php @@ -100,8 +100,8 @@ public function _getComponents(): array $components = $reader->_getComponents(); $this->assertIsArray($components); - $this->assertContains(["components/ILIAS", "Course", realpath(__DIR__ . "/../../../components/ILIAS/Course/module.xml")], $components); - $this->assertContains(["components/ILIAS", "Component", realpath(__DIR__ . "/../../../components/ILIAS/Component/service.xml")], $components); + $this->assertContains(["components/ILIAS", "Course", realpath(__DIR__ . "/../../../../components/ILIAS/Course/module.xml")], $components); + $this->assertContains(["components/ILIAS", "Component", realpath(__DIR__ . "/../../../../components/ILIAS/Component/service.xml")], $components); } public function testReadComponentDefinitions(): void diff --git a/components/ILIAS/Contact/BuddySystem/test/bootstrap.php b/components/ILIAS/Contact/BuddySystem/test/bootstrap.php index 5ccf2ed7ebbf..f021154e6b2f 100755 --- a/components/ILIAS/Contact/BuddySystem/test/bootstrap.php +++ b/components/ILIAS/Contact/BuddySystem/test/bootstrap.php @@ -18,4 +18,4 @@ declare(strict_types=1); -require_once __DIR__ . '/../../../../vendor/composer/vendor/autoload.php'; +require_once __DIR__ . '/../../../../../vendor/composer/vendor/autoload.php'; diff --git a/components/ILIAS/Context/tests/ilServicesContextSuite.php b/components/ILIAS/Context/tests/ilServicesContextSuite.php index ddb16b6cdd30..316e9db28c9d 100755 --- a/components/ILIAS/Context/tests/ilServicesContextSuite.php +++ b/components/ILIAS/Context/tests/ilServicesContextSuite.php @@ -13,7 +13,7 @@ public static function suite(): self { $suite = new ilServicesContextSuite(); - require_once("components/ILIAS/Context/tests/ilContextTest.php"); + require_once(__DIR__ . "/ilContextTest.php"); $suite->addTestSuite("ilContextTest"); diff --git a/components/ILIAS/CopyWizard/tests/ilServicesCopyWizardSuite.php b/components/ILIAS/CopyWizard/tests/ilServicesCopyWizardSuite.php index ba36b1a33ae1..9c6b85440a6b 100755 --- a/components/ILIAS/CopyWizard/tests/ilServicesCopyWizardSuite.php +++ b/components/ILIAS/CopyWizard/tests/ilServicesCopyWizardSuite.php @@ -12,6 +12,8 @@ public static function suite() { $suite = new ilServicesCopyWizardSuite(); + require_once(__DIR__ . "/ilCopyWizardOptionsTest.php"); + $suite->addTestSuite(ilCopyWizardOptionsTest::class); return $suite; } diff --git a/components/ILIAS/EventHandling/tests/EventTest.php b/components/ILIAS/EventHandling/tests/EventTest.php index ec07b4dfd56f..799569da36fd 100755 --- a/components/ILIAS/EventHandling/tests/EventTest.php +++ b/components/ILIAS/EventHandling/tests/EventTest.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\TestCase; use ILIAS\DI\Container; -require_once __DIR__ . "/../../../vendor/composer/vendor/autoload.php"; +require_once __DIR__ . "/../../../../vendor/composer/vendor/autoload.php"; /** * Test clipboard repository diff --git a/components/ILIAS/EventHandling/tests/ilServicesEventHandlingSuite.php b/components/ILIAS/EventHandling/tests/ilServicesEventHandlingSuite.php index de1d21dc748a..8f3b71946778 100755 --- a/components/ILIAS/EventHandling/tests/ilServicesEventHandlingSuite.php +++ b/components/ILIAS/EventHandling/tests/ilServicesEventHandlingSuite.php @@ -20,7 +20,7 @@ use PHPUnit\Framework\TestSuite; -require_once 'vendor/composer/vendor/autoload.php'; +require_once __DIR__ . '/../../../../vendor/composer/vendor/autoload.php'; /** * @author Alexander Killing @@ -31,7 +31,7 @@ public static function suite(): self { $suite = new self(); - require_once("./components/ILIAS/EventHandling/tests/EventTest.php"); + require_once(__DIR__ . "/EventTest.php"); $suite->addTestSuite("EventTest"); return $suite; diff --git a/components/ILIAS/FileDelivery_/tests/FileDeliveryTypes/XAccelTest.php b/components/ILIAS/FileDelivery_/tests/FileDeliveryTypes/XAccelTest.php index aa534748c7fe..a2318f18d989 100755 --- a/components/ILIAS/FileDelivery_/tests/FileDeliveryTypes/XAccelTest.php +++ b/components/ILIAS/FileDelivery_/tests/FileDeliveryTypes/XAccelTest.php @@ -130,7 +130,7 @@ public function testDeliverWithNormalPathWhichShouldSucceed(): void public function testDeliverWithDataPathWhichShouldSucceed(): void { $expectedHeader = 'X-Accel-Redirect'; - $path = './public/data/path/to/what/ever'; + $path = './data/path/to/what/ever'; $expectedPath = '/secured-data/path/to/what/ever'; $response = $this->getMockBuilder(ResponseInterface::class) diff --git a/components/ILIAS/FileServices/classes/class.ilFileServicesSettings.php b/components/ILIAS/FileServices/classes/class.ilFileServicesSettings.php index 02089b4fb565..dbd2edb2ee30 100755 --- a/components/ILIAS/FileServices/classes/class.ilFileServicesSettings.php +++ b/components/ILIAS/FileServices/classes/class.ilFileServicesSettings.php @@ -48,7 +48,7 @@ public function __construct( $this->convert_to_ascii = $general_settings->isDownloadWithAsciiFileName(); $this->settings = $settings; /** @noRector */ - $this->white_list_default = include "../components/ILIAS/FileServices/defaults/default_whitelist.php"; + $this->white_list_default = include __DIR__ . "/../defaults/default_whitelist.php"; $this->file_admin_ref_id = $this->determineFileAdminRefId(); $this->read(); } @@ -122,7 +122,7 @@ private function readBlackList(): void explode(",", $this->settings->get("suffix_custom_expl_black") ?? '') ); - $this->black_list_prohibited = array_filter($this->black_list_prohibited, fn ($item): bool => $item !== ''); + $this->black_list_prohibited = array_filter($this->black_list_prohibited, fn($item): bool => $item !== ''); $this->black_list_overall = $this->black_list_prohibited; } diff --git a/components/ILIAS/FileServices/tests/ilServicesFileServicesTest.php b/components/ILIAS/FileServices/tests/ilServicesFileServicesTest.php index 1b986f36a9f9..b90ca244a145 100755 --- a/components/ILIAS/FileServices/tests/ilServicesFileServicesTest.php +++ b/components/ILIAS/FileServices/tests/ilServicesFileServicesTest.php @@ -144,7 +144,7 @@ public function testActualWhitelist(): void ->method('fetchAssoc') ->willReturn([]); - $default_whitelist = include __DIR__ . "/../../../components/ILIAS/FileServices/defaults/default_whitelist.php"; + $default_whitelist = include __DIR__ . "/../defaults/default_whitelist.php"; // Blacklist $settings_mock->expects($this->exactly(3)) diff --git a/components/ILIAS/FileSystem_/tests/ilServicesFileSystemSuite.php b/components/ILIAS/FileSystem_/tests/ilServicesFileSystemSuite.php index ef5801b2940e..fba85fcfb287 100755 --- a/components/ILIAS/FileSystem_/tests/ilServicesFileSystemSuite.php +++ b/components/ILIAS/FileSystem_/tests/ilServicesFileSystemSuite.php @@ -18,7 +18,7 @@ use PHPUnit\Framework\TestSuite; -require_once 'vendor/composer/vendor/autoload.php'; +require_once __DIR__ . '/../../../../vendor/composer/vendor/autoload.php'; class ilServicesFileSystemSuite extends TestSuite { @@ -26,7 +26,7 @@ public static function suite(): self { $suite = new self(); - require_once("./components/ILIAS/FileSystem/tests/ilServicesFileSystemTest.php"); + require_once(__DIR__ . "/ilServicesFileSystemTest.php"); $suite->addTestSuite("ilServicesFileSystemTest"); return $suite; diff --git a/components/ILIAS/LearningSequence/tests/LSLocatorBuilderTest.php b/components/ILIAS/LearningSequence/tests/LSLocatorBuilderTest.php index 980c0321bf1a..fc4166348aba 100755 --- a/components/ILIAS/LearningSequence/tests/LSLocatorBuilderTest.php +++ b/components/ILIAS/LearningSequence/tests/LSLocatorBuilderTest.php @@ -9,7 +9,7 @@ use ILIAS\UI\Implementation\Component\BreadCrumbs\Breadcrumbs; require_once('IliasMocks.php'); -require_once(__DIR__ . "/../../../components/ILIAS/UI/tests/Base.php"); +require_once(__DIR__ . "/../../../../components/ILIAS/UI/tests/Base.php"); /** * This file is part of ILIAS, a powerful learning management system diff --git a/components/ILIAS/ResourceStorage/tests/Collection/CollectionSortingTest.php b/components/ILIAS/ResourceStorage/tests/Collection/CollectionSortingTest.php index 5a9f61637311..117be57b79c2 100755 --- a/components/ILIAS/ResourceStorage/tests/Collection/CollectionSortingTest.php +++ b/components/ILIAS/ResourceStorage/tests/Collection/CollectionSortingTest.php @@ -18,6 +18,8 @@ namespace ILIAS\ResourceStorage\Resource; +require_once(__DIR__ . "/../AbstractBaseResourceBuilderTest.php"); + use ILIAS\ResourceStorage\AbstractBaseResourceBuilderTest; use ILIAS\ResourceStorage\Collection\CollectionBuilder; use ILIAS\ResourceStorage\Collection\ResourceCollection; @@ -300,7 +302,7 @@ public function testByTitleDescSorting(): void private function getFlatOrder(ResourceCollection $collection): array { return array_map( - fn (ResourceIdentification $rid): string => $rid->serialize(), + fn(ResourceIdentification $rid): string => $rid->serialize(), $collection->getResourceIdentifications() ); } diff --git a/components/ILIAS/ResourceStorage/tests/Policy/FileNamePolicyTest.php b/components/ILIAS/ResourceStorage/tests/Policy/FileNamePolicyTest.php index fd76f2e5a5f4..ed0e7b04cf86 100755 --- a/components/ILIAS/ResourceStorage/tests/Policy/FileNamePolicyTest.php +++ b/components/ILIAS/ResourceStorage/tests/Policy/FileNamePolicyTest.php @@ -18,6 +18,8 @@ namespace ILIAS\ResourceStorage\Policy; +require_once(__DIR__ . "/../AbstractBaseResourceBuilderTest.php"); + use ILIAS\MainMenu\Tests\DummyIDGenerator; use ILIAS\ResourceStorage\AbstractBaseResourceBuilderTest; use ILIAS\ResourceStorage\Resource\ResourceBuilder; diff --git a/components/ILIAS/ResourceStorage/tests/Resource/ResourceBuilderTest.php b/components/ILIAS/ResourceStorage/tests/Resource/ResourceBuilderTest.php index 3e1f499b015a..ab335aebcce2 100755 --- a/components/ILIAS/ResourceStorage/tests/Resource/ResourceBuilderTest.php +++ b/components/ILIAS/ResourceStorage/tests/Resource/ResourceBuilderTest.php @@ -18,6 +18,8 @@ namespace ILIAS\ResourceStorage\Resource; +require_once(__DIR__ . "/../AbstractBaseResourceBuilderTest.php"); + use ILIAS\ResourceStorage\AbstractBaseResourceBuilderTest; /** diff --git a/components/ILIAS/ResourceStorage/tests/StorageHandler/DirectoryNestingTest.php b/components/ILIAS/ResourceStorage/tests/StorageHandler/DirectoryNestingTest.php index d62b6c72a677..50b609949ad0 100755 --- a/components/ILIAS/ResourceStorage/tests/StorageHandler/DirectoryNestingTest.php +++ b/components/ILIAS/ResourceStorage/tests/StorageHandler/DirectoryNestingTest.php @@ -18,6 +18,8 @@ namespace ILIAS\ResourceStorage\Revision; +require_once(__DIR__ . "/../AbstractBaseTest.php"); + use ILIAS\Filesystem\Filesystem; use ILIAS\ResourceStorage\AbstractBaseTest; use ILIAS\ResourceStorage\StorageHandler\FileSystemBased\FileSystemStorageHandler; diff --git a/components/ILIAS/Setup/tests/Objective/ObjectiveWithPreconditionsTest.php b/components/ILIAS/Setup/tests/Objective/ObjectiveWithPreconditionsTest.php index 96cefada392c..e84b022ef6e1 100755 --- a/components/ILIAS/Setup/tests/Objective/ObjectiveWithPreconditionsTest.php +++ b/components/ILIAS/Setup/tests/Objective/ObjectiveWithPreconditionsTest.php @@ -20,6 +20,8 @@ namespace ILIAS\Tests\Setup\Objective; +require_once(__DIR__ . "/../Helper.php"); + use ILIAS\Setup; use ILIAS\Setup\Objective; use ILIAS\Tests\Setup as Test; @@ -27,7 +29,7 @@ class ObjectiveWithPreconditionsTest extends TestCase { - use Test\Helper; + use \ILIAS\Tests\Setup\Helper; protected Setup\Objective $objective; protected Setup\Objective $precondition; diff --git a/components/ILIAS/Style/Content/test/ilServicesStyleContentSuite.php b/components/ILIAS/Style/Content/test/ilServicesStyleContentSuite.php index c66371f540a3..e8fec32e29fd 100755 --- a/components/ILIAS/Style/Content/test/ilServicesStyleContentSuite.php +++ b/components/ILIAS/Style/Content/test/ilServicesStyleContentSuite.php @@ -20,7 +20,7 @@ use PHPUnit\Framework\TestSuite; -require_once 'vendor/composer/vendor/autoload.php'; +require_once __DIR__ . '/../../../../../vendor/composer/vendor/autoload.php'; /** * @author Alexander Killing @@ -31,7 +31,7 @@ public static function suite(): self { $suite = new self(); - require_once("./components/ILIAS/Style/Content/tests/ContentStyleStandardGUIRequestTest.php"); + require_once(__DIR__ . "/ContentStyleStandardGUIRequestTest.php"); $suite->addTestSuite("ContentStyleStandardGUIRequestTest"); return $suite; diff --git a/components/ILIAS/Style/System/classes/Documentation/class.ilSystemStyleDocumentationGUI.php b/components/ILIAS/Style/System/classes/Documentation/class.ilSystemStyleDocumentationGUI.php index 325f91550204..1fb1954fe342 100755 --- a/components/ILIAS/Style/System/classes/Documentation/class.ilSystemStyleDocumentationGUI.php +++ b/components/ILIAS/Style/System/classes/Documentation/class.ilSystemStyleDocumentationGUI.php @@ -31,7 +31,7 @@ class ilSystemStyleDocumentationGUI protected ILIAS\UI\Renderer $r; public const SHOW_TREE = 'system_styles_show_tree'; - public const DATA_PATH = '../components/ILIAS/Style/System/data/data.php'; + public const DATA_PATH = __DIR__ . '/../../data/data.php'; public const ROOT_FACTORY_PATH = __DIR__ . '/../../../../../../components/ILIAS/Style/System/data/abstractDataFactory.php'; public function __construct( diff --git a/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleColorExceptionTest.php b/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleColorExceptionTest.php index 1ed0340dc8ab..3149398114c2 100755 --- a/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleColorExceptionTest.php +++ b/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleColorExceptionTest.php @@ -18,8 +18,9 @@ declare(strict_types=1); -require_once('vendor/composer/vendor/autoload.php'); -include_once('components/ILIAS/Style/System/tests/Exceptions/ilSystemStyleExceptionBaseUnit.php'); + +require_once(__DIR__ . '/../../../../../../vendor/composer/vendor/autoload.php'); +require_once(__DIR__ . '/ilSystemStyleExceptionBaseUnit.php'); class ilSystemStyleColorExceptionTest extends ilSystemStyleExceptionBaseUnit { diff --git a/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleIconExceptionTest.php b/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleIconExceptionTest.php index 9122dcc9aa9c..fa78b6fad47d 100755 --- a/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleIconExceptionTest.php +++ b/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleIconExceptionTest.php @@ -18,13 +18,13 @@ declare(strict_types=1); -require_once('vendor/composer/vendor/autoload.php'); -include_once('components/ILIAS/Style/System/tests/Exceptions/ilSystemStyleExceptionBaseUnit.php'); +require_once(__DIR__ . '/../../../../../../vendor/composer/vendor/autoload.php'); +require_once(__DIR__ . '/ilSystemStyleExceptionBaseUnit.php'); class ilSystemStyleIconExceptionTest extends ilSystemStyleExceptionBaseUnit { protected function getClassName(): string { - return 'ilSystemStyleIconException'; + return ilSystemStyleIconException::class; } } diff --git a/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleMessageStackExceptionTest.php b/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleMessageStackExceptionTest.php index 95fbe976a90f..f6bae5c7ba03 100755 --- a/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleMessageStackExceptionTest.php +++ b/components/ILIAS/Style/System/test/Exceptions/ilSystemStyleMessageStackExceptionTest.php @@ -18,8 +18,8 @@ declare(strict_types=1); -require_once('vendor/composer/vendor/autoload.php'); -include_once('components/ILIAS/Style/System/tests/Exceptions/ilSystemStyleExceptionBaseUnit.php'); +require_once(__DIR__ . '/../../../../../../vendor/composer/vendor/autoload.php'); +require_once(__DIR__ . '/ilSystemStyleExceptionBaseUnit.php'); class ilSystemStyleMessageStackExceptionTest extends ilSystemStyleExceptionBaseUnit { diff --git a/components/ILIAS/Style/System/test/Scss/ilSystemStyleStyleScssFileTest.php b/components/ILIAS/Style/System/test/Scss/ilSystemStyleStyleScssFileTest.php index 310e13356ad7..52dc9f1c90b4 100755 --- a/components/ILIAS/Style/System/test/Scss/ilSystemStyleStyleScssFileTest.php +++ b/components/ILIAS/Style/System/test/Scss/ilSystemStyleStyleScssFileTest.php @@ -18,10 +18,12 @@ declare(strict_types=1); -require_once('vendor/composer/vendor/autoload.php'); +require_once(__DIR__ . '/../../../../../../vendor/composer/vendor/autoload.php'); class ilSystemStyleStyleScssFileTest extends ilSystemStyleBaseFS { + protected ilSystemStyleScssSettingsFile $file; + protected function setUp(): void { parent::setUp(); @@ -126,7 +128,7 @@ public function testGetItems(): void public function testGetContent(): void { - $expected_content = file_get_contents($this->file->getScssVariablesSettingsPath()."/variables1.scss"); + $expected_content = file_get_contents($this->file->getScssVariablesSettingsPath() . "/variables1.scss"); $this->assertEquals($expected_content, $this->file->getContent()); } diff --git a/components/ILIAS/Style/System/test/Style/ilSkinStyleContainerTest.php b/components/ILIAS/Style/System/test/Style/ilSkinStyleContainerTest.php index 69f34f9c9920..d306ddaa51a1 100755 --- a/components/ILIAS/Style/System/test/Style/ilSkinStyleContainerTest.php +++ b/components/ILIAS/Style/System/test/Style/ilSkinStyleContainerTest.php @@ -26,6 +26,7 @@ class ilSkinStyleContainerTest extends ilSystemStyleBaseFS protected ilSkinStyle $style1; protected ilSkinStyle $style2; protected ilSkinFactory $factory; + protected string $skin_directory; protected function setUp(): void { @@ -101,7 +102,7 @@ public function testAddStyle(): void $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack); - $this->assertTrue(is_dir($this->skin_directory. '/style1/style1image')); + $this->assertTrue(is_dir($this->skin_directory . '/style1/style1image')); $this->assertTrue(is_dir($this->skin_directory . '/style1/style1sound')); $this->assertTrue(is_dir($this->skin_directory . '/style1/style1font')); $this->assertTrue(is_file($this->skin_directory . '/style1/style1.css')); @@ -238,7 +239,7 @@ public function testAddSubstyle(): void $new_sub_style->setSubstyleOf("style1"); - $this->assertTrue(is_dir($this->skin_directory. '/style1/style1image')); + $this->assertTrue(is_dir($this->skin_directory . '/style1/style1image')); $this->assertTrue(is_dir($this->skin_directory . '/style1/style1sound')); $this->assertTrue(is_dir($this->skin_directory . '/style1/style1font')); $this->assertTrue(is_file($this->skin_directory . '/style1/style1.css')); @@ -259,7 +260,7 @@ public function testAddSubstyle(): void $this->assertCount(1, $container->getSkin()->getSubstylesOfStyle('style1')); - $this->assertTrue(is_dir($this->skin_directory. '/style1/style1image')); + $this->assertTrue(is_dir($this->skin_directory . '/style1/style1image')); $this->assertTrue(is_dir($this->skin_directory . '/style1/style1sound')); $this->assertTrue(is_dir($this->skin_directory . '/style1/style1font')); $this->assertTrue(is_file($this->skin_directory . '/style1/style1.css')); diff --git a/components/ILIAS/Style/System/test/fixtures/mocks/ilSystemStyleConfigMock.php b/components/ILIAS/Style/System/test/fixtures/mocks/ilSystemStyleConfigMock.php index dcc3f47e3592..38cc6db9fcc8 100755 --- a/components/ILIAS/Style/System/test/fixtures/mocks/ilSystemStyleConfigMock.php +++ b/components/ILIAS/Style/System/test/fixtures/mocks/ilSystemStyleConfigMock.php @@ -10,14 +10,14 @@ class ilSystemStyleConfigMock extends ilSystemStyleConfig { protected string $default_skin_id = 'defaultSkin'; protected string $default_style_id = 'defaultStyle'; - protected string $default_template_path = '../components/ILIAS/Style/System/tests/fixtures/skins_temp/defaultSkin/template.xml'; - protected string $delos_path = '../components/ILIAS/Style/System/tests/fixtures/skins_temp/defaultSkin/defaultStyle'; - protected string $rel_delos_path = '../components/ILIAS/Style/System/tests/fixtures/skins_temp/defaultSkin/defaultStyle'; - protected string $default_settings_path = '../components/ILIAS/Style/System/tests/fixtures/skins_temp/defaultSkin/010-settings'; - protected string $default_images_path = '../components/ILIAS/Style/System/tests/fixtures/skins_temp/defaultSkin/images/'; - protected string $default_fonts_path = '../components/ILIAS/Style/System/tests/fixtures/skins_temp/defaultSkin/fonts/'; + protected string $default_template_path = __DIR__ . '/../skins_temp/defaultSkin/template.xml'; + protected string $delos_path = __DIR__ . '/../skins_temp/defaultSkin/defaultStyle'; + protected string $rel_delos_path = __DIR__ . '/../skins_temp/defaultSkin/defaultStyle'; + protected string $default_settings_path = __DIR__ . '/../skins_temp/defaultSkin/010-settings'; + protected string $default_images_path = __DIR__ . '/../skins_temp/defaultSkin/images/'; + protected string $default_fonts_path = __DIR__ . '/../skins_temp/defaultSkin/fonts/'; protected string $default_sounds_path = ''; - protected string $customizing_skin_path = '../components/ILIAS/Style/System/tests/fixtures/skins_temp/customSkins/'; - public string $test_skin_original_path = '../components/ILIAS/Style/System/tests/fixtures/skins/'; - public string $test_skin_temp_path = '../components/ILIAS/Style/System/tests/fixtures/skins_temp/'; + protected string $customizing_skin_path = __DIR__ . '/../skins_temp/customSkins/'; + public string $test_skin_original_path = __DIR__ . '/../skins/'; + public string $test_skin_temp_path = __DIR__ . '/../skins_temp/'; } diff --git a/components/ILIAS/Style/System/test/ilServicesStyleSystemSuite.php b/components/ILIAS/Style/System/test/ilServicesStyleSystemSuite.php index b0a93e01c93a..8266aeb4bd31 100755 --- a/components/ILIAS/Style/System/test/ilServicesStyleSystemSuite.php +++ b/components/ILIAS/Style/System/test/ilServicesStyleSystemSuite.php @@ -26,12 +26,12 @@ public static function suite(): TestSuite { $suite = new ilServicesStyleSystemSuite(); - $base_dir = './components/ILIAS/Style/System/tests/'; + $base_dir = __DIR__; $rec_it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($base_dir)); foreach ($rec_it as $file) { - if (strpos($file->getFilename(), 'Test.php') !== false) { - include_once($file->getPathname()); + if (preg_match("#^[^.]+Test\.php$#", $file->getFilename())) { + require_once($file->getPathname()); $test_class = str_replace('.php', '', $file->getFilename()); $suite->addTestSuite($test_class); } diff --git a/components/ILIAS/Style/tests/ilServicesStyleSuite.php b/components/ILIAS/Style/tests/ilServicesStyleSuite.php index 76ad1b08e8af..9d3f6d2458e1 100755 --- a/components/ILIAS/Style/tests/ilServicesStyleSuite.php +++ b/components/ILIAS/Style/tests/ilServicesStyleSuite.php @@ -17,9 +17,9 @@ public static function suite() $suite = new ilServicesStyleSuite(); // add each test class of the component - include_once("./components/ILIAS/Style/System/tests/ilServicesStyleSystemSuite.php"); - include_once("./components/ILIAS/Style/Content/tests/ilServicesStyleContentSuite.php"); - $suite->addTestSuite("ilServicesStyleSystemSuite"); + require_once(__DIR__ . "/../System/test/ilServicesStyleSystemSuite.php"); + require_once(__DIR__ . "/../Content/test/ilServicesStyleContentSuite.php"); + $suite->addTestSuite(ilServicesStyleSystemSuite::class); $suite->addTestSuite("ilServicesStyleContentSuite"); return $suite; } diff --git a/components/ILIAS/Test/tests/ScoreSettingsTest.php b/components/ILIAS/Test/tests/ScoreSettingsTest.php index aac0f6bfaa31..26ceb5865163 100755 --- a/components/ILIAS/Test/tests/ScoreSettingsTest.php +++ b/components/ILIAS/Test/tests/ScoreSettingsTest.php @@ -18,6 +18,8 @@ declare(strict_types=1); +require_once(__DIR__ . "/../../UI/tests/Base.php"); + use ILIAS\UI\Implementation\Component as I; use ILIAS\UI\Component as C; use ILIAS\UI\Implementation\Component\SignalGenerator; diff --git a/components/ILIAS/UI_/tests/ilServiceUISuite.php b/components/ILIAS/UI_/tests/ilServiceUISuite.php index de788427fc1a..a966ba3e7edb 100755 --- a/components/ILIAS/UI_/tests/ilServiceUISuite.php +++ b/components/ILIAS/UI_/tests/ilServiceUISuite.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\TestSuite; -require_once 'vendor/composer/vendor/autoload.php'; +require_once __DIR__ . '/../../../../vendor/composer/vendor/autoload.php'; /** * UI Service test suite @@ -33,7 +33,7 @@ public static function suite(): self { $suite = new self(); - require_once("./components/ILIAS/Skill/tests/ilUIFilterTest.php"); + require_once(__DIR__ . "/UIFilterServiceSessionGatewayTest.php"); $suite->addTestSuite(UIFilterServiceSessionGatewayTest::class); return $suite; diff --git a/components/ILIAS/User/tests/ilObjUserPasswordTest.php b/components/ILIAS/User/tests/ilObjUserPasswordTest.php index 4710038c671e..40f2575da017 100755 --- a/components/ILIAS/User/tests/ilObjUserPasswordTest.php +++ b/components/ILIAS/User/tests/ilObjUserPasswordTest.php @@ -20,14 +20,8 @@ use org\bovigo\vfs; -require_once 'vendor/composer/vendor/autoload.php'; -require_once 'components/ILIAS/User/classes/class.ilUserPasswordManager.php'; -require_once 'components/ILIAS/User/classes/class.ilUserPasswordEncoderFactory.php'; -require_once 'components/ILIAS/Password/classes/class.ilBasePasswordEncoder.php'; -require_once 'components/ILIAS/Utilities/classes/class.ilUtil.php'; -require_once 'components/ILIAS/User/classes/class.ilObjUser.php'; -require_once 'components/ILIAS/User/exceptions/class.ilUserException.php'; -require_once 'components/ILIAS/User/tests/ilUserBaseTest.php'; +require_once __DIR__ . '/../../../../vendor/composer/vendor/autoload.php'; +require_once __DIR__ . '/ilUserBaseTest.php'; class ilObjUserPasswordTest extends ilUserBaseTest { @@ -60,7 +54,7 @@ public function setTestDirectoryUrl(string $testDirectoryUrl): void protected function setUp(): void { vfs\vfsStream::setup(); - $this->setTestDirectory(vfs\vfsStream::newDirectory('test')->at(vfs\vfsStreamWrapper::getRoot())); + $this->setTestDirectory(vfs\vfsStream::newDirectory('tests')->at(vfs\vfsStreamWrapper::getRoot())); $this->setTestDirectoryUrl(vfs\vfsStream::url('root/tests')); parent::setUp(); diff --git a/components/ILIAS/WebDAV/tests/ilServicesWebDAVSuite.php b/components/ILIAS/WebDAV/tests/ilServicesWebDAVSuite.php index 3f2457520114..cb75c15b6a11 100755 --- a/components/ILIAS/WebDAV/tests/ilServicesWebDAVSuite.php +++ b/components/ILIAS/WebDAV/tests/ilServicesWebDAVSuite.php @@ -20,7 +20,7 @@ use PHPUnit\Framework\TestSuite; -require_once __DIR__ . "/../../../vendor/composer/vendor/autoload.php"; +require_once __DIR__ . "/../../../../vendor/composer/vendor/autoload.php"; /** * @author Stephan Winiker diff --git a/scripts/ILIASSuite.php b/scripts/ILIASSuite.php deleted file mode 100755 index 4c6561dc955d..000000000000 --- a/scripts/ILIASSuite.php +++ /dev/null @@ -1,127 +0,0 @@ - - */ - -declare(strict_types=1); - -use PHPUnit\Framework\TestSuite; -use PHPUnit\Framework\TestCase; -use PHPUnit\Runner\Filter\Factory as FilterFactory; -use PHPUnit\Runner\Filter\ExcludeGroupFilterIterator as GroupExcludeFilter; - -class ILIASSuite extends TestSuite -{ - /** - * @var string - */ - public const REGEX_TEST_FILENAME = "#[a-zA-Z]+Test\.php#"; - public const PHP_UNIT_PARENT_CLASS = TestCase::class; - - public const COMPONENTS = [ - "App", - "BackgroundTasks", - "Cache", - "DI", - "Data", - "FileUpload", - "Filesystem", - "GlobalCache", - "GlobalScreen", - "HTTP", - "KioskMode", - "Language", - "Refinery", - "ResourceStorage", - "Setup", - "Types", - "UI", - "VirusScanner" - ]; - - public static function suite() - { - $suite = new ILIASSuite(); - echo "ILIAS PHPUnit-Tests need installed dev-requirements, please install using 'composer install' in ./vendor/composer \n"; - echo "\n"; - - // scan Modules and Services directories - $basedirs = array("components/ILIAS"); - foreach ($basedirs as $basedir) { - // read current directory - $dir = opendir($basedir); - - while ($file = readdir($dir)) { - if (!in_array($file, self::COMPONENTS, true)) { - if ($file != "." && $file != ".." && is_dir($basedir . "/" . $file)) { - $file_name = str_replace("_", "", $file); - $suite_path = - $basedir . "/" . $file . "/tests/ilComponents" . $file_name . "Suite.php"; - if (is_file($suite_path)) { - include_once($suite_path); - $file_name = str_replace("_", "", $file); - $name = "ilComponents" . $file_name . "Suite"; - $s = $name::suite(); - echo "Adding Suite: " . $name . "\n"; - $suite->addTest($s); - //$suite->addTestSuite("ilSettingTest"); - } - } - } - } - } - - $suite = self::addTestFolderToSuite($suite); - - echo "\n"; - - return $suite; - } - - /** - * Find and add all testSuits beneath ILIAS_ROOL/test - folder - */ - protected static function addTestFolderToSuite(ILIASSuite $suite): ILIASSuite - { - $test_directories = []; - foreach (self::COMPONENTS as $component) { - $test_directories[] = "components/ILIAS/" . $component . "/tests"; - } - - while ($aux_dir = current($test_directories)) { - if ($handle = opendir($aux_dir)) { - $aux_dir .= DIRECTORY_SEPARATOR; - while (false !== ($entry = readdir($handle))) { - if ($entry === '.' || $entry === '..') { - continue; - } - if (is_dir($aux_dir . $entry)) { - $test_directories[] = $aux_dir . $entry; - } else { - if (1 === preg_match(self::REGEX_TEST_FILENAME, $entry)) { - $ref_declared_classes = get_declared_classes(); - require_once $aux_dir . "/" . $entry; - $new_declared_classes = array_diff(get_declared_classes(), $ref_declared_classes); - foreach ($new_declared_classes as $entry_class) { - $reflection = new ReflectionClass($entry_class); - if (!$reflection->isAbstract() && $reflection->isSubclassOf(self::PHP_UNIT_PARENT_CLASS)) { - echo "Adding Test-Suite: " . $entry_class . "\n"; - $suite->addTestSuite($entry_class); - } - } - } - } - } - } - next($test_directories); - } - return $suite; - } -} diff --git a/scripts/PHPUnit/ILIASSuite.php b/scripts/PHPUnit/ILIASSuite.php new file mode 100755 index 000000000000..f9b1ebe6c8a8 --- /dev/null +++ b/scripts/PHPUnit/ILIASSuite.php @@ -0,0 +1,118 @@ +addTestFiles(self::getTestFilesIn($path)); + continue; + } + foreach ($suites as [$suite, $path]) { + require_once($path); + $suite = $suite::suite(); + echo "Adding tests from suite: " . $path . "\n"; + $ilias_suite->addTest($suite); + } + } + + echo "\n"; + + return $ilias_suite; + } + + public static function getComponents(): array + { + $vendors = new DirectoryIterator(self::COMPONENTS_DIRECTORY); + $dirs = []; + foreach ($vendors as $vendor) { + if (str_starts_with((string) $vendor, ".")) { + continue; + } + $components = new DirectoryIterator(self::COMPONENTS_DIRECTORY . "/" . $vendor); + foreach ($components as $component) { + if (str_starts_with((string) $component, ".")) { + continue; + } + $dirs[] = $component->getPathname(); + } + } + sort($dirs); + return $dirs; + } + + public static function getTestsOf(string $component): array + { + $test_dir = $component . "/" . self::TEST_DIRECTORY; + if (!is_dir($test_dir)) { + return [null, []]; + } + $tests = new DirectoryIterator($test_dir); + $suites = []; + foreach ($tests as $test) { + if (preg_match(self::REGEX_SUITE_FILENAME, (string) $test)) { + $suites[] = [$test->getBaseName(".php"), realpath($test->getPathname())]; + } + } + return [realpath($test_dir), $suites]; + } + + public static function getTestFilesIn(string $path): array + { + $tests = []; + $ds = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); + foreach ($ds as $d) { + if (!$d->isFile()) { + continue; + } + if (preg_match(self::REGEX_TEST_FILENAME, (string) $d)) { + $tests[] = realpath($d->getPathname()); + } + } + return $tests; + } +} diff --git a/scripts/PHPUnit/phpunit.xml b/scripts/PHPUnit/phpunit.xml index ff812441eeca..c443794f8ff3 100755 --- a/scripts/PHPUnit/phpunit.xml +++ b/scripts/PHPUnit/phpunit.xml @@ -14,7 +14,7 @@ > - ../../scripts/ILIASSuite.php + ILIASSuite.php - \ No newline at end of file +