From 3fd5f2dc9824009bebe623f861c921273edbb984 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Fri, 10 May 2024 12:18:33 +0200 Subject: [PATCH] fix test issues --- README.en.md | 2 +- composer.json | 8 ++++ tests/README.md | 47 ++----------------- tests/additional.inc.php | 4 +- .../Exceptions/InputUnvalidExceptionTest.php | 2 +- .../unit/Application/Model/ExportBaseTest.php | 2 +- .../ExportRenderer/ExportRendererTest.php | 2 +- 7 files changed, 19 insertions(+), 48 deletions(-) diff --git a/README.en.md b/README.en.md index 9ad0d59..d960495 100644 --- a/README.en.md +++ b/README.en.md @@ -72,7 +72,7 @@ If you have a suggestion that would make this better, please fork the repo and c - Push to the Branch (git push origin feature/AmazingFeature) - Open a Pull Request -## Licence +## License (status: 2021-05-06) Distributed under the GPLv3 license. diff --git a/composer.json b/composer.json index 0c983ac..3736805 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,10 @@ "form-manager/form-manager": "^6.1", "d3/modcfg": "^7.0" }, + "require-dev": { + "d3/testingtools": "^1.2.0.0", + "phpunit/phpunit": "^9.1.1" + }, "suggest": { "d3/datawizardtasks": "useful example tasks for Data Wizard", "d3/datawizardcli": "command line implementation for fully automated Data Wizard tasks", @@ -41,5 +45,9 @@ "psr-4": { "D3\\DataWizard\\": "./" } + }, + "scripts": { + "phpunit": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --config=vendor/d3/datawizard/ --no-coverage", + "phpunit-coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --config=vendor/d3/datawizard/ --coverage-html=vendor/d3/datawizard/tests/result/coverage" } } diff --git a/tests/README.md b/tests/README.md index 2e8a767..334d041 100644 --- a/tests/README.md +++ b/tests/README.md @@ -2,51 +2,14 @@ ## Requirements -Both unit and acceptance tests require OXID Testing Library installed. -See https://github.com/OXID-eSales/testing_library. +Please install the packages listed in the composer.json in "require-dev". Unfortunately Composer does not provide an automatic installation. +missing ext-sockets ### Configuration -Please install the packages listed in the composer.json in "require-dev". Unfortunately Composer does not provide an automatic installation. - -Here is an example of Testing Library configuration file `oxideshop/test_config.yml` - -``` -# This file is auto-generated during the composer install -mandatory_parameters: - shop_path: /var/www/oxideshop/source - shop_tests_path: /var/www/oxideshop/tests - partial_module_paths: d3/datawizard -optional_parameters: - shop_url: null - shop_serial: '' - enable_varnish: false - is_subshop: false - install_shop: false - remote_server_dir: null - shop_setup_path: null - restore_shop_after_tests_suite: false - test_database_name: null - restore_after_acceptance_tests: false - restore_after_unit_tests: false - tmp_path: /tmp/oxid_test_library/ - database_restoration_class: DatabaseRestorer - activate_all_modules: false - run_tests_for_shop: false - run_tests_for_modules: true - screen_shots_path: null - screen_shots_url: null - browser_name: firefox - selenium_server_ip: 127.0.0.1 - selenium_server_port: '4444' - additional_test_paths: null -``` +Make sure the module has been activated with a valid license key. +Configure the error reporting to `error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);` in the `config.inc.php` due some deprecation issues in original OXID code ## Unit Tests -To execute unit tests run the following: - -``` -cd /var/www/oxideshop/ -vendor/bin/runtests -``` +commands are described in composer.json scripts section \ No newline at end of file diff --git a/tests/additional.inc.php b/tests/additional.inc.php index f5244fa..c09b1f8 100755 --- a/tests/additional.inc.php +++ b/tests/additional.inc.php @@ -36,6 +36,6 @@ class additional extends additional_abstract } try { - d3GetModCfgDIC()->get(additional::class); -} catch (Exception $e) { + d3GetOxidDIC()->get(additional::class); +} catch (Exception) { } diff --git a/tests/unit/Application/Model/Exceptions/InputUnvalidExceptionTest.php b/tests/unit/Application/Model/Exceptions/InputUnvalidExceptionTest.php index a9dab16..c6119e6 100644 --- a/tests/unit/Application/Model/Exceptions/InputUnvalidExceptionTest.php +++ b/tests/unit/Application/Model/Exceptions/InputUnvalidExceptionTest.php @@ -69,7 +69,7 @@ class InputUnvalidExceptionTest extends d3ModCfgUnitTestCase [$taskMock, $invalidField, $code, $exception] ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/^testTitle\s-\s*->\s.*\sless\s/m', $this->callMethod( $this->_oModel, diff --git a/tests/unit/Application/Model/ExportBaseTest.php b/tests/unit/Application/Model/ExportBaseTest.php index 35b8d8d..2cbb4a0 100644 --- a/tests/unit/Application/Model/ExportBaseTest.php +++ b/tests/unit/Application/Model/ExportBaseTest.php @@ -524,7 +524,7 @@ class ExportBaseTest extends d3ModCfgUnitTestCase $this->_oModel = $modelMock; - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/^base_(\d{4})-(\d{2})-(\d{2})_(\d{2})-(\d{2})-(\d{2})\.extension$/m', $this->callMethod( $this->_oModel, diff --git a/tests/unit/Application/Model/ExportRenderer/ExportRendererTest.php b/tests/unit/Application/Model/ExportRenderer/ExportRendererTest.php index d167846..85891fe 100644 --- a/tests/unit/Application/Model/ExportRenderer/ExportRendererTest.php +++ b/tests/unit/Application/Model/ExportRenderer/ExportRendererTest.php @@ -38,7 +38,7 @@ abstract class ExportRendererTest extends d3ModCfgUnitTestCase */ public function canGetFileExtension() { - $this->assertRegExp( + $this->assertMatchesRegularExpression( "/^[a-z0-9._-]*$/i", $this->callMethod( $this->_oModel,