From 4c6c81ab9cf60391f014365d3e8ba19540098635 Mon Sep 17 00:00:00 2001 From: marcelmanzel Date: Mon, 27 May 2024 13:52:14 +0200 Subject: [PATCH] OXDEV-8207: Fix phpunit errors --- .../Controller/GreetingControllerTest.php | 40 ++++++------- .../Controller/StartControllerTest.php | 52 ++++++++-------- tests/Unit/Service/GreetingMessageTest.php | 2 +- tests/Unit/Service/ModuleSettingsTest.php | 4 +- tests/github_actions/module-template.yml | 60 ------------------- tests/phpunit.xml | 41 ++++++------- 6 files changed, 67 insertions(+), 132 deletions(-) delete mode 100644 tests/github_actions/module-template.yml diff --git a/tests/Integration/Controller/GreetingControllerTest.php b/tests/Integration/Controller/GreetingControllerTest.php index a918870..b8a3405 100644 --- a/tests/Integration/Controller/GreetingControllerTest.php +++ b/tests/Integration/Controller/GreetingControllerTest.php @@ -87,26 +87,26 @@ public function providerOemtGreeting(): array { return [ 'without_user_generic' => [ - 'user' => false, - 'greeting_mode' => ModuleSettings::GREETING_MODE_GENERIC, + 'hasUser' => false, + 'mode' => ModuleSettings::GREETING_MODE_GENERIC, 'expected' => '', 'count' => 0, ], 'without_user_personal' => [ - 'user' => false, - 'greeting_mode' => ModuleSettings::GREETING_MODE_PERSONAL, + 'hasUser' => false, + 'mode' => ModuleSettings::GREETING_MODE_PERSONAL, 'expected' => '', 'count' => 0, ], 'with_user_generic' => [ - 'user' => true, - 'greeting_mode' => ModuleSettings::GREETING_MODE_GENERIC, + 'hasUser' => true, + 'mode' => ModuleSettings::GREETING_MODE_GENERIC, 'expect' => self::TEST_GREETING, 'count' => 0, ], 'with_user_personal' => [ - 'user' => true, - 'greeting_mode' => ModuleSettings::GREETING_MODE_PERSONAL, + 'hasUser' => true, + 'mode' => ModuleSettings::GREETING_MODE_PERSONAL, 'expect' => self::TEST_GREETING_UPDATED, 'count' => 1, ], @@ -117,33 +117,33 @@ public function providerRender(): array { return [ 'without_user_generic' => [ - 'user' => false, - 'greeting_mode' => ModuleSettings::GREETING_MODE_GENERIC, - 'expected' => [ + 'hasUser' => false, + 'mode' => ModuleSettings::GREETING_MODE_GENERIC, + 'expected' => [ 'greeting' => '', 'counter' => 0, ], ], 'without_user_personal' => [ - 'user' => false, - 'greeting_mode' => ModuleSettings::GREETING_MODE_PERSONAL, - 'expected' => [ + 'hasUser' => false, + 'mode' => ModuleSettings::GREETING_MODE_PERSONAL, + 'expected' => [ 'greeting' => '', 'counter' => 0, ], ], 'with_user_generic' => [ - 'user' => true, - 'greeting_mode' => ModuleSettings::GREETING_MODE_GENERIC, - 'expected' => [ + 'hasUser' => true, + 'mode' => ModuleSettings::GREETING_MODE_GENERIC, + 'expected' => [ 'greeting' => '', 'counter' => 0, ], ], 'with_user_personal' => [ - 'user' => true, - 'greeting_mode' => ModuleSettings::GREETING_MODE_PERSONAL, - 'expected' => [ + 'hasUser' => true, + 'mode' => ModuleSettings::GREETING_MODE_PERSONAL, + 'expected' => [ 'greeting' => self::TEST_GREETING, 'counter' => 67, ], diff --git a/tests/Integration/Controller/StartControllerTest.php b/tests/Integration/Controller/StartControllerTest.php index cca7524..613557f 100644 --- a/tests/Integration/Controller/StartControllerTest.php +++ b/tests/Integration/Controller/StartControllerTest.php @@ -33,7 +33,7 @@ final class StartControllerTest extends IntegrationTestCase /** * @dataProvider providerCanUpdateOemtGreeting */ - public function testCanUpdateOemtGreeting(bool $hasUser, string $mode, string $expect): void + public function testCanUpdateOemtGreeting(bool $hasUser, string $mode, string $assert): void { $moduleSettings = $this->getServiceFromContainer(ModuleSettings::class); $moduleSettings->saveGreetingMode($mode); @@ -44,7 +44,7 @@ public function testCanUpdateOemtGreeting(bool $hasUser, string $mode, string $e $controller->setUser($this->getTestUser()); } - $this->$expect($controller->canUpdateOemtGreeting()); + $this->$assert($controller->canUpdateOemtGreeting()); } /** @@ -73,24 +73,24 @@ public function providerCanUpdateOemtGreeting(): array { return [ 'without_user_generic' => [ - 'user' => false, - 'greeting_mode' => ModuleSettings::GREETING_MODE_GENERIC, - 'assert' => 'assertFalse', + 'hasUser' => false, + 'mode' => ModuleSettings::GREETING_MODE_GENERIC, + 'assert' => 'assertFalse', ], 'without_user_personal' => [ - 'user' => false, - 'greeting_mode' => ModuleSettings::GREETING_MODE_PERSONAL, - 'assert' => 'assertFalse', + 'hasUser' => false, + 'mode' => ModuleSettings::GREETING_MODE_PERSONAL, + 'assert' => 'assertFalse', ], 'with_user_generic' => [ - 'user' => true, - 'greeting_mode' => ModuleSettings::GREETING_MODE_GENERIC, - 'assert' => 'assertFalse', + 'hasUser' => true, + 'mode' => ModuleSettings::GREETING_MODE_GENERIC, + 'assert' => 'assertFalse', ], 'with_user_personal' => [ - 'user' => true, - 'greeting_mode' => ModuleSettings::GREETING_MODE_PERSONAL, - 'assert' => 'assertTrue', + 'hasUser' => true, + 'mode' => ModuleSettings::GREETING_MODE_PERSONAL, + 'assert' => 'assertTrue', ], ]; } @@ -99,24 +99,24 @@ public function providerGetOemtGreeting(): array { return [ 'without_user_generic' => [ - 'user' => false, - 'greeting_mode' => ModuleSettings::GREETING_MODE_GENERIC, - 'expect' => 'OEMODULETEMPLATE_GREETING_GENERIC', + 'hasUser' => false, + 'mode' => ModuleSettings::GREETING_MODE_GENERIC, + 'expect' => 'OEMODULETEMPLATE_GREETING_GENERIC', ], 'without_user_personal' => [ - 'user' => false, - 'greeting_mode' => ModuleSettings::GREETING_MODE_PERSONAL, - 'expect' => '', + 'hasUser' => false, + 'mode' => ModuleSettings::GREETING_MODE_PERSONAL, + 'expect' => '', ], 'with_user_generic' => [ - 'user' => true, - 'greeting_mode' => ModuleSettings::GREETING_MODE_GENERIC, - 'expect' => 'OEMODULETEMPLATE_GREETING_GENERIC', + 'hasUser' => true, + 'mode' => ModuleSettings::GREETING_MODE_GENERIC, + 'expect' => 'OEMODULETEMPLATE_GREETING_GENERIC', ], 'with_user_personal' => [ - 'user' => true, - 'greeting_mode' => ModuleSettings::GREETING_MODE_PERSONAL, - 'expect' => self::TEST_GREETING, + 'hasUser' => true, + 'mode' => ModuleSettings::GREETING_MODE_PERSONAL, + 'expect' => self::TEST_GREETING, ], ]; } diff --git a/tests/Unit/Service/GreetingMessageTest.php b/tests/Unit/Service/GreetingMessageTest.php index 48058fd..9f6ba0e 100644 --- a/tests/Unit/Service/GreetingMessageTest.php +++ b/tests/Unit/Service/GreetingMessageTest.php @@ -30,7 +30,7 @@ public function testGenericGreetingNoUser(string $mode, string $expected): void $this->assertSame($expected, $service->getGreeting()); } - public function getGreetingDataProvider(): array + public static function getGreetingDataProvider(): array { return [ [ diff --git a/tests/Unit/Service/ModuleSettingsTest.php b/tests/Unit/Service/ModuleSettingsTest.php index 8031b09..4bbaa95 100644 --- a/tests/Unit/Service/ModuleSettingsTest.php +++ b/tests/Unit/Service/ModuleSettingsTest.php @@ -31,7 +31,7 @@ public function testGetGreetingMode(string $value, string $expected): void $this->assertSame($expected, $sut->getGreetingMode()); } - public function getGreetingModeDataProvider(): array + public static function getGreetingModeDataProvider(): array { return [ [ @@ -67,7 +67,7 @@ public function testIsPersonalGreetingMode(string $value, bool $expected): void $this->assertSame($expected, $sut->isPersonalGreetingMode()); } - public function isPersonalGreetingModeDataProvider(): array + public static function isPersonalGreetingModeDataProvider(): array { return [ [ diff --git a/tests/github_actions/module-template.yml b/tests/github_actions/module-template.yml deleted file mode 100644 index 9dd0165..0000000 --- a/tests/github_actions/module-template.yml +++ /dev/null @@ -1,60 +0,0 @@ -prepare_shop: - git: - shop_ref: '{{ .Data.global.git.default_ref }}' - -# {{ $ids := "oe_moduletemplate" }}ids: {{ print $ids }} -# {{ $org := "oxid-esales" }}organisation: {{ print $org }} -# {{ $name := "module-template" }}name: {{ print $name }} -install_module: - matrix: - testplan: '["-"]' - cache: - prefix: &install_module_prefix 'moduleInstallation-ce-{{ .Github.SHA }}-{{ .Github.RunID }}' - ids: &ids '{{ print $ids }}' - activate: *ids - git: - module: - url: &git_module_url '{{ .Github.Repository }}' - ref: '{{ .Github.RefName }}' - package_name: &package_name '{{ print $org }}/{{ print $name }}' - path: *ids - -phpunit: - matrix: - testplan: '["tests/github_actions/defaults/module_phpunit_unit.yml","tests/github_actions/defaults/module_phpunit_integration.yml"]' - load_shop: *install_module_prefix - -codeception: - matrix: - testplan: '["tests/github_actions/defaults/module_codeception_acceptance.yml"]' - load_shop: *install_module_prefix - -runtest: - matrix: - testplan: 'skip' - load_shop: *install_module_prefix - -sonarcloud: - matrix: - testplan: '["-"]' - strip_path: '/var/www/dev-packages/{{ print $ids }}/' - project_key: 'OXID-eSales_{{ print $name }}' - project_name: *package_name - parameters: | - -Dsonar.language=php - -Dsonar.scm.provider=git - -Dsonar.sources=src - -Dsonar.tests=tests - -phpcs_tests: - skip: true - -styles: - matrix: - testplan: '["-"]' - load_shop: *install_module_prefix - path: *ids - module_ids: *ids - -finish: - slack_title: 'Module {{ print $name }} ({{ .Data.global.git.shop_ref }}) on {{ .Github.Repository }} by {{ .Github.Actor }}' diff --git a/tests/phpunit.xml b/tests/phpunit.xml index ad21d62..ff96386 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -1,34 +1,21 @@ - - - ../src - - + backupStaticProperties="false" + colors="true"> + beStrictAboutTestsThatDoNotTestAnything="false" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" + cacheDirectory=".phpunit.cache" + requireCoverageMetadata="false" + displayDetailsOnTestsThatTriggerWarnings="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerErrors="true" + displayDetailsOnTestsThatTriggerDeprecations="true" Unit/ @@ -37,4 +24,12 @@ Integration/ + + + ../src + + + ../tests + +