Skip to content

Comments

N°9009 Add phpunit test to GetSelectedModules#792

Open
Timmy38 wants to merge 4 commits intofeature/uninstallationfrom
feature/9009_check_extension_modules
Open

N°9009 Add phpunit test to GetSelectedModules#792
Timmy38 wants to merge 4 commits intofeature/uninstallationfrom
feature/9009_check_extension_modules

Conversation

@Timmy38
Copy link
Contributor

@Timmy38 Timmy38 commented Jan 8, 2026

No description provided.

@Timmy38 Timmy38 requested a review from rquetiez January 8, 2026 10:56
@CombodoApplicationsAccount CombodoApplicationsAccount added the internal Work made by Combodo label Jan 8, 2026
'aExpectedModules' => [],
'aExpectedExtensions' => [],
],
'One extension selected' => [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independently from the implementation, we should have tests scenarios with multiple extensions selected

public function ProviderGetSelectedModules()
{
return [
'No extension selected' => [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder : do we have other cases with different conditions and same result? How about having test cases with exclusive options ?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds PHPUnit tests for the GetSelectedModules method in the WizStepModulesChoice class. The changes enable testing of module selection logic during the setup/installation process by making the method public, adding validation for empty module arrays, and providing test coverage for basic scenarios.

Changes:

  • Added two test methods with a data provider to test the GetSelectedModules functionality
  • Changed GetSelectedModules visibility from protected to public to enable direct testing
  • Added validation to throw an exception when a selected extension has an empty modules array
  • Initialized the $aAnalyzeInstallationModules property with an empty array (fixes potential uninitialized property issue in test context)
  • Updated type hint documentation from hash to array for better PHP standards compliance

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php Added test provider and two test methods covering basic module selection scenarios and exception handling for empty module arrays
setup/wizardsteps/WizStepModulesChoice.php Changed method visibility, added empty modules validation, and initialized property to support testing
setup/setuputils.class.inc.php Updated docblock type hint from deprecated hash to standard array

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$sDisplayChoices .= '<li>'.$aChoice['title'].'</li>';
if (isset($aChoice['modules'])) {
if (count($aChoice['modules']) === 0) {
throw new Exception('Setup option does not have any module associated');
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message 'Setup option does not have any module associated' could be more helpful by including which extension or choice caused the error. Consider adding the extension code or choice title to the error message to help users identify the problematic configuration more easily.

Suggested change
throw new Exception('Setup option does not have any module associated');
$sChoiceTitle = isset($aChoice['title']) ? $aChoice['title'] : 'unknown title';
$sExtensionCode = isset($aChoice['extension_code']) ? $aChoice['extension_code'] : 'unknown extension';
throw new Exception(sprintf(
'Setup option "%s" (extension "%s") does not have any module associated',
$sChoiceTitle,
$sExtensionCode
));

Copilot uses AI. Check for mistakes.
'installed' => false,
],
];
$this->oStep->setExtensionMap(iTopExtensionsMapFake::createFromArray($aExtensionsMapData, ));
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a trailing comma after the array parameter. The createFromArray method signature only has one required parameter. This trailing comma appears to be a typo and should be removed.

Copilot uses AI. Check for mistakes.
'installed' => false,
],
];
$this->oStep->setExtensionMap(iTopExtensionsMapFake::createFromArray($aExtensionsMapData, ));
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a trailing comma after the array parameter. The createFromArray method signature only has one required parameter. This trailing comma appears to be a typo and should be removed.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Work made by Combodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants