Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
71 changes: 50 additions & 21 deletions RoboFile.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Robo\Symfony\ConsoleIO;
use Symfony\Component\Finder\Finder;

/**
Expand All @@ -8,49 +9,77 @@
* @see https://robo.li/
*/
class RoboFile extends \Robo\Tasks {
public function test() {
$workspace_dir = 'tests/integration/workspace';
$composer_json = 'tests/integration/composer.site.json';
protected $workspace_dir = 'tests/integration/workspace';

public function clean() {
$collection = $this->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();
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
Expand Down
10 changes: 8 additions & 2 deletions tests/integration/composer.site.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Loading