From db74083749de3b65d685010240d072c9f7cccb9a Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sun, 26 Feb 2023 15:54:38 +0100 Subject: [PATCH] Issue #35: Drupal 10 compatibility. --- src/FileFetcher.php | 3 ++- tests/PluginTest.php | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/FileFetcher.php b/src/FileFetcher.php index 6bde0ca..8a72b2e 100644 --- a/src/FileFetcher.php +++ b/src/FileFetcher.php @@ -72,9 +72,10 @@ public function __construct(IOInterface $io, HttpDownloader $http_downloader, ar $this->io = $io; $this->httpDownloader = $http_downloader; $this->options = $options; - $this->coreMajorVersion = substr($core_version, 0, 1); $this->fs = new Filesystem(); $this->progress = $progress; + $parsed_core_version = \explode('.', $core_version); + $this->coreMajorVersion = array_shift($parsed_core_version); } /** diff --git a/tests/PluginTest.php b/tests/PluginTest.php index 00a3007..77ab4c9 100644 --- a/tests/PluginTest.php +++ b/tests/PluginTest.php @@ -167,6 +167,27 @@ public function testDrupal7() { $this->assertFileExists($fr_translation_file, 'French translations file should exist.'); } + /** + * Tests that on Drupal 10, core and contrib modules are handled. + */ + public function testDrupal10() { + $core_version = '10.0.3'; + $contrib_module = 'speedboxes'; + $contrib_composer_version = '1.3.0'; + $contrib_drupal_version = '8.x-1.3'; + $translations_directory = $this->tmpDir . DIRECTORY_SEPARATOR . 'translations' . DIRECTORY_SEPARATOR . 'contrib'; + $core_translation_file = $translations_directory . DIRECTORY_SEPARATOR . 'drupal-' . $core_version . '.fr.po'; + $fr_translation_file = $translations_directory . DIRECTORY_SEPARATOR . $contrib_module . '-' . $contrib_drupal_version . '.fr.po'; + + $this->assertFileDoesNotExist($core_translation_file, 'French translations file should not exist.'); + $this->assertFileDoesNotExist($fr_translation_file, 'French translations file should not exist.'); + $this->composer('install'); + $this->composer('require --update-with-dependencies drupal/core:"' . $core_version . '"'); + $this->composer('require drupal/' . $contrib_module . ':"' . $contrib_composer_version . '"'); + $this->assertFileExists($core_translation_file, 'French translations file should exist.'); + $this->assertFileExists($fr_translation_file, 'French translations file should exist.'); + } + /** * Writes the default composer json to the temp directory. */