diff --git a/CHANGELOG.md b/CHANGELOG.md index 50ff3f3..ee9e61e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ## Unreleased +- Changed: Updated dependencies and integration tests + +## Version 2.0.0 + - Changed: Support for Composer 2 API - Changed: SimpleID modules are now installed in `site` diff --git a/RoboFile.php b/RoboFile.php index b6423f4..25c1ca6 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -1,5 +1,6 @@ collectionBuilder(); - // 1. Clean workspace directory $collection->taskFilesystemStack() - ->remove($workspace_dir . '/.gitignore') + ->remove($this->workspace_dir . '/.gitignore') ->run(); - $collection->taskCleanDir([$workspace_dir])->run(); + $collection->taskCleanDir([$this->workspace_dir])->run(); + + return $collection->run(); + } + + public function test(ConsoleIO $io, $version = 'dev-master') { + $composer_json = 'tests/integration/composer.site.json'; + + $collection = $this->collectionBuilder(); + + // 1. Clean workspace directory + $this->clean(); // 2. Install base SimpleID $collection->taskComposerCreateProject() - ->source('simpleid/simpleid:dev-master') - ->target($workspace_dir) + ->source('simpleid/simpleid:' . $version) + ->target($this->workspace_dir) + ->noInstall(true) ->noDev() ->run(); // 3. Update composer.json to add local repository $collection->taskFilesystemStack() - ->copy($composer_json, $workspace_dir . '/composer.site.json') + ->copy($composer_json, $this->workspace_dir . '/composer.site.json') ->run(); // 4. Update minimum-stability in root composer.json - $collection->addCode(function() use ($workspace_dir) { - $root_composer_json = $workspace_dir . '/composer.json'; - $root_composer = json_decode(file_get_contents($root_composer_json), true); - $root_composer['minimum-stability'] = 'dev'; - $root_composer['prefer-stable'] = true; - file_put_contents($root_composer_json, json_encode($root_composer)); - }); + $collection->taskComposerConfig() + ->workingDir($this->workspace_dir) + ->set('minimum-stability', 'dev') + ->run(); + $collection->taskComposerConfig() + ->workingDir($this->workspace_dir) + ->set('prefer-stable', 'true') + ->run(); // 5. Try installing the test module $collection->taskComposerUpdate() - ->workingDir($workspace_dir) + ->workingDir($this->workspace_dir) ->noDev() ->run(); - // 6. See if module exists in the right location - $collection->addCode(function() use ($workspace_dir) { - $expected_file = $workspace_dir . '/www/site/test/src/TestModule/TestModule.php'; - if (!file_exists($expected_file)) return 1; + // 6. See if module exists in the right location and is part of + // autoload + $collection->addCode(function() use ($io) { + $expected_file = $this->workspace_dir . '/www/site/test/src/TestModule/TestModule.php'; + if (!file_exists($expected_file)) { + $io->error('Test module not installed'); + return 1; + } else { + $io->success('Test module installed in expected location'); + } + }); + + $collection->addCode(function() use ($io) { + $autoload_file = $this->workspace_dir . '/www/vendor/composer/autoload_psr4.php'; + $autoloads = include($autoload_file); + if (!array_key_exists('SimpleID\\Modules\\TestModule\\', $autoloads)) { + $io->error('Test module not included in autoload'); + return 1; + } else { + $io->success('Test module included in autoload'); + } }); return $collection->run(); diff --git a/composer.json b/composer.json index f49932f..f066d22 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "consolidation/robo": " ^5.2.3" }, "scripts": { + "clean": [ "@composer install", "robo clean" ], "test": [ "@composer install", "robo test" ], "update-copyright": [ "@composer install", "robo update_copyright" ] } diff --git a/tests/integration/composer.site.json b/tests/integration/composer.site.json index f2e6fa3..cf2e91e 100644 --- a/tests/integration/composer.site.json +++ b/tests/integration/composer.site.json @@ -2,11 +2,17 @@ "repositories": [ { "type": "path", - "url": "../simpleid-test-module" + "url": "../simpleid-test-module", + "options": { + "symlink": false + } }, { "type": "path", - "url": "../../.." + "url": "../../..", + "options": { + "symlink": false + } } ], "require": {