From a433e5f4a8333436f27f87e36b683b698153ae32 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 10 May 2017 21:24:12 +1200 Subject: [PATCH 1/2] Find root modules with _config.php When modules are installed as the webroot, manifest generation should behave the same way as when they're in a subfolder. Which means accepting the module folder both with a _config/ folder and a _config.php file present. --- src/Core/Manifest/ManifestFileFinder.php | 1 + .../Core/Manifest/ManifestFileFinderTest.php | 41 +++++++++++++++++-- .../_config.php | 0 .../code/code.txt | 0 .../code/code.txt | 0 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfile/_config.php create mode 100644 tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfile/code/code.txt create mode 100644 tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfolder/code/code.txt diff --git a/src/Core/Manifest/ManifestFileFinder.php b/src/Core/Manifest/ManifestFileFinder.php index 22d047116..ecb3b39bf 100644 --- a/src/Core/Manifest/ManifestFileFinder.php +++ b/src/Core/Manifest/ManifestFileFinder.php @@ -66,6 +66,7 @@ class ManifestFileFinder extends FileFinder && !file_exists($pathname . '/' . self::CONFIG_DIR) && $basename !== self::CONFIG_DIR // include a root config dir && !file_exists("$pathname/../" . self::CONFIG_DIR) // include all paths if a root config dir exists + && !file_exists("$pathname/../" . self::CONFIG_FILE)// include all paths if a root config file exists ); if ($lackingConfig) { diff --git a/tests/php/Core/Manifest/ManifestFileFinderTest.php b/tests/php/Core/Manifest/ManifestFileFinderTest.php index 643ddf651..e3c45bbea 100644 --- a/tests/php/Core/Manifest/ManifestFileFinderTest.php +++ b/tests/php/Core/Manifest/ManifestFileFinderTest.php @@ -15,16 +15,20 @@ class ManifestFileFinderTest extends SapphireTest public function __construct() { - $this->base = dirname(__FILE__) . '/fixtures/manifestfilefinder'; + $this->defaultBase = dirname(__FILE__) . '/fixtures/manifestfilefinder'; parent::__construct(); } - public function assertFinderFinds($finder, $expect, $message = null) + public function assertFinderFinds($finder, $base, $expect, $message = null) { - $found = $finder->find($this->base); + if (!$base) { + $base = $this->defaultBase; + } + + $found = $finder->find($base); foreach ($expect as $k => $file) { - $expect[$k] = "{$this->base}/$file"; + $expect[$k] = "{$base}/$file"; } sort($expect); @@ -40,6 +44,7 @@ class ManifestFileFinderTest extends SapphireTest $this->assertFinderFinds( $finder, + null, array( 'module/module.txt' ) @@ -54,6 +59,7 @@ class ManifestFileFinderTest extends SapphireTest $this->assertFinderFinds( $finder, + null, array( 'module/module.txt', 'module/tests/tests.txt', @@ -70,10 +76,37 @@ class ManifestFileFinderTest extends SapphireTest $this->assertFinderFinds( $finder, + null, array( 'module/module.txt', 'themes/themes.txt' ) ); } + + public function testIncludeWithRootConfigFile() + { + $finder = new ManifestFileFinder(); + + $this->assertFinderFinds( + $finder, + dirname(__FILE__) . '/fixtures/manifestfilefinder_rootconfigfile', + array( + 'code/code.txt', + ) + ); + } + + public function testIncludeWithRootConfigFolder() + { + $finder = new ManifestFileFinder(); + + $this->assertFinderFinds( + $finder, + dirname(__FILE__) . '/fixtures/manifestfilefinder_rootconfigfolder', + array( + 'code/code.txt', + ) + ); + } } diff --git a/tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfile/_config.php b/tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfile/_config.php new file mode 100644 index 000000000..e69de29bb diff --git a/tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfile/code/code.txt b/tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfile/code/code.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfolder/code/code.txt b/tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfolder/code/code.txt new file mode 100644 index 000000000..e69de29bb From ba89c0804aab2c0f18c26a5aca8bea7e307a8a7a Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 22 May 2017 11:33:26 +1200 Subject: [PATCH 2/2] Add missing `_config` folder --- tests/php/Core/Manifest/ManifestFileFinderTest.php | 1 + .../manifestfilefinder_rootconfigfolder/_config/config.yml | 0 2 files changed, 1 insertion(+) create mode 100644 tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfolder/_config/config.yml diff --git a/tests/php/Core/Manifest/ManifestFileFinderTest.php b/tests/php/Core/Manifest/ManifestFileFinderTest.php index e3c45bbea..ee9d5a10e 100644 --- a/tests/php/Core/Manifest/ManifestFileFinderTest.php +++ b/tests/php/Core/Manifest/ManifestFileFinderTest.php @@ -105,6 +105,7 @@ class ManifestFileFinderTest extends SapphireTest $finder, dirname(__FILE__) . '/fixtures/manifestfilefinder_rootconfigfolder', array( + '_config/config.yml', 'code/code.txt', ) ); diff --git a/tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfolder/_config/config.yml b/tests/php/Core/Manifest/fixtures/manifestfilefinder_rootconfigfolder/_config/config.yml new file mode 100644 index 000000000..e69de29bb