Skip to content
Snippets Groups Projects
Commit f066e2d7 authored by Kunal Sachdev's avatar Kunal Sachdev Committed by Ted Bowman
Browse files

Issue #3318846 by kunal.sachdev, tedbow: Remove staged fixture files used for...

Issue #3318846 by kunal.sachdev, tedbow: Remove staged fixture files used for SupportedReleaseValidatorTest
parent 5c6b2e4d
No related branches found
No related tags found
No related merge requests found
Showing
with 106 additions and 282 deletions
{
"packages": [
{
"name": "drupal/core-recommended",
"version": "9.8.0",
"require": {
"drupal/core": "9.8.0"
}
},
{
"name": "drupal/core",
"version": "9.8.0"
},
{
"name": "drupal/dependency",
"version": "9.8.1",
"type": "drupal-library"
},
{
"name": "drupal/aaa_automatic_updates_test",
"version": "7.0.1",
"type": "drupal-module"
}
]
}
<?php
/**
* @file
* Lists packages installed by Composer.
*/
$projects_dir = __DIR__ . '/../../modules';
return [
'versions' => [
'drupal/aaa_automatic_updates_test' => [
'type' => 'drupal-module',
'install_path' => $projects_dir . '/aaa_automatic_updates_test',
],
],
];
{
"packages": [
{
"name": "drupal/core-recommended",
"version": "9.8.0",
"require": {
"drupal/core": "9.8.0"
}
},
{
"name": "drupal/core",
"version": "9.8.0"
},
{
"name": "drupal/dependency",
"version": "9.8.1",
"type": "drupal-library"
},
{
"name": "drupal/aaa_automatic_updates_test",
"version": "7.0.1-dev",
"type": "drupal-module"
}
]
}
<?php
/**
* @file
* Lists packages installed by Composer.
*/
$projects_dir = __DIR__ . '/../../modules';
return [
'versions' => [
'drupal/aaa_automatic_updates_test' => [
'type' => 'drupal-module',
'install_path' => $projects_dir . '/aaa_automatic_updates_test',
],
],
];
...@@ -26,5 +26,6 @@ ...@@ -26,5 +26,6 @@
"version": "8.1.0", "version": "8.1.0",
"type": "drupal-module" "type": "drupal-module"
} }
] ],
"dev-package-names": []
} }
...@@ -16,5 +16,8 @@ return [ ...@@ -16,5 +16,8 @@ return [
'type' => 'drupal-module', 'type' => 'drupal-module',
'install_path' => $projects_dir . '/aaa_update_test', 'install_path' => $projects_dir . '/aaa_update_test',
], ],
'drupal/dependency' => [
'type' => 'drupal-library',
],
], ],
]; ];
{
"packages": [
{
"name": "drupal/core-recommended",
"version": "9.8.0",
"require": {
"drupal/core": "9.8.0"
}
},
{
"name": "drupal/core",
"version": "9.8.0"
},
{
"name": "drupal/dependency",
"version": "9.8.1",
"type": "drupal-library"
},
{
"name": "drupal/aaa_update_test",
"version": "2.1.0",
"type": "drupal-module"
}
]
}
<?php
/**
* @file
* Lists packages installed by Composer.
*/
$projects_dir = __DIR__ . '/../../modules';
return [
'versions' => [
'drupal/aaa_update_test' => [
'type' => 'drupal-module',
'install_path' => $projects_dir . '/aaa_update_test',
],
],
];
{
"packages": [
{
"name": "drupal/core-recommended",
"version": "9.8.0",
"require": {
"drupal/core": "9.8.0"
}
},
{
"name": "drupal/core",
"version": "9.8.0"
},
{
"name": "drupal/dependency",
"version": "9.8.1",
"type": "drupal-library"
},
{
"name": "drupal/aaa_update_test",
"version": "3.0.0",
"type": "drupal-module"
}
]
}
<?php
/**
* @file
* Lists packages installed by Composer.
*/
$projects_dir = __DIR__ . '/../../modules';
return [
'versions' => [
'drupal/aaa_update_test' => [
'type' => 'drupal-module',
'install_path' => $projects_dir . '/aaa_update_test',
],
],
];
{
"packages": [
{
"name": "drupal/core-recommended",
"version": "9.8.0",
"require": {
"drupal/core": "9.8.0"
}
},
{
"name": "drupal/core",
"version": "9.8.0"
},
{
"name": "drupal/dependency",
"version": "9.8.1",
"type": "drupal-library"
},
{
"name": "drupal/semver_test",
"version": "8.1.1",
"type": "drupal-module"
}
]
}
<?php
/**
* @file
* Lists packages installed by Composer.
*/
$projects_dir = __DIR__ . '/../../modules';
return [
'versions' => [
'drupal/semver_test' => [
'type' => 'drupal-module',
'install_path' => $projects_dir . '/semver_test',
],
],
];
{
"packages": [
{
"name": "drupal/core-recommended",
"version": "9.8.0",
"require": {
"drupal/core": "9.8.0"
}
},
{
"name": "drupal/core",
"version": "9.8.0"
},
{
"name": "drupal/dependency",
"version": "9.8.1",
"type": "drupal-library"
},
{
"name": "drupal/semver_test",
"version": "8.2.0",
"type": "drupal-module"
}
]
}
<?php
/**
* @file
* Lists packages installed by Composer.
*/
$projects_dir = __DIR__ . '/../../modules';
return [
'versions' => [
'drupal/semver_test' => [
'type' => 'drupal-module',
'install_path' => $projects_dir . '/semver_test',
],
],
];
...@@ -24,45 +24,93 @@ class SupportedReleaseValidatorTest extends PackageManagerKernelTestBase { ...@@ -24,45 +24,93 @@ class SupportedReleaseValidatorTest extends PackageManagerKernelTestBase {
$summary = t('Cannot update because the following project version is not in the list of installable releases.'); $summary = t('Cannot update because the following project version is not in the list of installable releases.');
return [ return [
'semver, supported update' => [ 'semver, supported update' => [
'semver_test', [
"$release_fixture_folder/semver_test.1.1.xml", 'semver_test' => "$release_fixture_folder/semver_test.1.1.xml",
"$fixtures_folder/semver_supported_update_stage", ],
NULL,
TRUE,
[
'name' => "drupal/semver_test",
'version' => '8.1.1',
'type' => 'drupal-module',
'install_path' => NULL,
],
[], [],
], ],
'semver, update to unsupported branch' => [ 'semver, update to unsupported branch' => [
'semver_test', [
"$release_fixture_folder/semver_test.1.1.xml", 'semver_test' => "$release_fixture_folder/semver_test.1.1.xml",
"$fixtures_folder/semver_unsupported_update_stage", ],
NULL,
TRUE,
[
'name' => "drupal/semver_test",
'version' => '8.2.0',
'type' => 'drupal-module',
'install_path' => NULL,
],
[ [
ValidationResult::createError(['semver_test (drupal/semver_test) 8.2.0'], $summary), ValidationResult::createError(['semver_test (drupal/semver_test) 8.2.0'], $summary),
], ],
], ],
'legacy, supported update' => [ 'legacy, supported update' => [
'aaa_update_test', [
"$release_fixture_folder/aaa_update_test.1.1.xml", 'aaa_update_test' => "$release_fixture_folder/aaa_update_test.1.1.xml",
"$fixtures_folder/legacy_supported_update_stage", ],
NULL,
TRUE,
[
'name' => "drupal/aaa_update_test",
'version' => '2.1.0',
'type' => 'drupal-module',
'install_path' => NULL,
],
[], [],
], ],
'legacy, update to unsupported branch' => [ 'legacy, update to unsupported branch' => [
'aaa_update_test', [
"$release_fixture_folder/aaa_update_test.1.1.xml", 'aaa_update_test' => "$release_fixture_folder/aaa_update_test.1.1.xml",
"$fixtures_folder/legacy_unsupported_update_stage", ],
NULL,
TRUE,
[
'name' => "drupal/aaa_update_test",
'version' => '3.0.0',
'type' => 'drupal-module',
'install_path' => NULL,
],
[ [
ValidationResult::createError(['aaa_update_test (drupal/aaa_update_test) 3.0.0'], $summary), ValidationResult::createError(['aaa_update_test (drupal/aaa_update_test) 3.0.0'], $summary),
], ],
], ],
'aaa_automatic_updates_test(not in active), update to unsupported branch' => [ 'aaa_automatic_updates_test(not in active), update to unsupported branch' => [
'aaa_automatic_updates_test', [
"$release_fixture_folder/aaa_automatic_updates_test.9.8.2.xml", 'aaa_automatic_updates_test' => "$release_fixture_folder/aaa_automatic_updates_test.9.8.2.xml",
],
"$fixtures_folder/aaa_automatic_updates_test_unsupported_update_stage", "$fixtures_folder/aaa_automatic_updates_test_unsupported_update_stage",
FALSE,
[
'name' => "drupal/aaa_automatic_updates_test",
'version' => '7.0.1-dev',
'type' => 'drupal-module',
'install_path' => '../../modules/aaa_automatic_updates_test',
],
[ [
ValidationResult::createError(['aaa_automatic_updates_test (drupal/aaa_automatic_updates_test) 7.0.1-dev'], $summary), ValidationResult::createError(['aaa_automatic_updates_test (drupal/aaa_automatic_updates_test) 7.0.1-dev'], $summary),
], ],
], ],
'aaa_automatic_updates_test(not in active), update to supported branch' => [ 'aaa_automatic_updates_test(not in active), update to supported branch' => [
'aaa_automatic_updates_test', [
"$release_fixture_folder/aaa_automatic_updates_test.9.8.2.xml", 'aaa_automatic_updates_test' => "$release_fixture_folder/aaa_automatic_updates_test.9.8.2.xml",
],
"$fixtures_folder/aaa_automatic_updates_test_supported_update_stage", "$fixtures_folder/aaa_automatic_updates_test_supported_update_stage",
FALSE,
[
'name' => "drupal/aaa_automatic_updates_test",
'version' => '7.0.1',
'type' => 'drupal-module',
'install_path' => '../../modules/aaa_automatic_updates_test',
],
[], [],
], ],
]; ];
...@@ -71,27 +119,49 @@ class SupportedReleaseValidatorTest extends PackageManagerKernelTestBase { ...@@ -71,27 +119,49 @@ class SupportedReleaseValidatorTest extends PackageManagerKernelTestBase {
/** /**
* Tests exceptions when updating to unsupported or insecure releases. * Tests exceptions when updating to unsupported or insecure releases.
* *
* @param string $project * @param array $release_metadata
* The project to update. * Array of paths of the fake release metadata keyed by project name.
* @param string $release_xml * @param string|null $stage_fixture_dir
* Path of release xml for project. * Path of fixture stage directory or NULL. It will be used to fixture files
* @param string $stage_dir * to virtual stage directory when the project is not in active.
* Path of fixture stage directory. It will be used as the virtual project's * @param bool $project_in_active
* stage directory. * Whether the project is in the active directory or not.
* @param array $package
* The package that will be added or modified.
* @param array $expected_results * @param array $expected_results
* The expected validation results. * The expected validation results.
* *
* @dataProvider providerException * @dataProvider providerException
*/ */
public function testException(string $project, string $release_xml, string $stage_dir, array $expected_results): void { public function testException(array $release_metadata, ?string $stage_fixture_dir, bool $project_in_active, array $package, array $expected_results): void {
$this->setReleaseMetadata([ $this->setReleaseMetadata(['drupal' => __DIR__ . '/../../fixtures/release-history/drupal.9.8.2.xml'] + $release_metadata);
$project => $release_xml, $active_fixture_dir = __DIR__ . '/../../fixtures/supported_release_validator/active';
'drupal' => __DIR__ . '/../../fixtures/release-history/drupal.9.8.2.xml', $this->copyFixtureFolderToActiveDirectory($active_fixture_dir);
]); if ($stage_fixture_dir) {
$active_dir = __DIR__ . '/../../fixtures/supported_release_validator/active'; $this->copyFixtureFolderToStageDirectoryOnApply($stage_fixture_dir);
$this->copyFixtureFolderToActiveDirectory($active_dir); }
$this->copyFixtureFolderToStageDirectoryOnApply($stage_dir);
$listener = function (PreApplyEvent $event) use ($project_in_active, $package): void {
$stage_dir = $event->getStage()->getStageDirectory();
// @todo add test coverage for packages that don't start with 'drupal/' in
// https://www.drupal.org/node/3321386.
if (!$project_in_active) {
$this->addPackage($stage_dir, $package);
}
else {
$this->modifyPackage($stage_dir, $package['name'], [
'version' => $package['version'],
]);
}
// We always update this module to prove that the validator will skip this
// module as it's of type 'drupal-library'.
// @see \Drupal\package_manager\Validator\SupportedReleaseValidator::checkStagedReleases()
$this->modifyPackage($stage_dir, "drupal/dependency", [
'version' => '9.8.1',
]);
};
$this->container->get('event_dispatcher')
->addListener(PreApplyEvent::class, $listener, PHP_INT_MAX);
$this->assertResults($expected_results, PreApplyEvent::class); $this->assertResults($expected_results, PreApplyEvent::class);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment