/** * Test custom options works */ public function testMergeCustomOptions() { $generator = new ComposerGenerator('master', 'master', ComposerGenerator::REF_BRANCH); $base = array('require' => array('silverstripe/framework' => '~3.1')); $this->assertEquals(array('require' => array('silverstripe/framework' => '~3.1', 'silverstripe/subsites' => 'dev-master')), $generator->mergeCustomOptions(array('require' => 'silverstripe/subsites:dev-master'), $base)); $this->assertEquals(array('require' => array('silverstripe/framework' => '~3.1', 'silverstripe/translatable' => '*')), $generator->mergeCustomOptions(array('require' => 'silverstripe/translatable'), $base)); }
} /** * 5. Extract the package info from the module composer file, both for this module (from local) * and the core framework (from packagist) */ echo "Reading composer information...\n"; if (!file_exists("{$modulePath}/composer.json")) { echo "File not found: {$modulePath}/composer.json"; exit(1); } $modulePackageInfo = json_decode(file_get_contents("{$modulePath}/composer.json"), true); $corePackageInfo = json_decode(file_get_contents('https://packagist.org/packages/silverstripe/framework.json'), true); /** * 6. Generate composer data */ $composerGenerator = new ComposerGenerator($coreBranch, $moduleVersion, $moduleRef, $corePackageInfo, $modulePackageInfo); $moduleArchivePath = "{$parent}/{$moduleName}.tar"; $composer = $composerGenerator->generateComposerConfig($opts, $moduleArchivePath); $composerStr = json_encode($composer); echo "Generated composer file:\n"; echo "{$composerStr}\n\n"; /** * 7. Run it */ run("cd {$modulePath}"); run("tar -cf {$moduleArchivePath} ./*"); run("git clone --depth=100 --quiet -b {$coreBranch} git://github.com/silverstripe/silverstripe-installer.git {$targetPath}"); run("cp {$dir}/_ss_environment.php {$targetPath}/_ss_environment.php"); if ($configPath) { run("cp {$configPath} {$targetPath}/mysite/_config.php"); }
/** * Test custom options works when an array of required packages is provided */ public function testGenerateConfig() { $frameworkComposer = $this->getMockFrameworkJson(); $generator = new ComposerGenerator('master', 'master', ComposerGenerator::REF_BRANCH, $frameworkComposer, $this->getMockModuleJson('subsites-master')); $base = array('require' => array('silverstripe/framework' => '~3.1')); $requiredPackages = array('silverstripe/subsites:dev-master', 'silverstripe/comments:2.0.2', 'silverstripe/tagfield:1.2.1'); $options = array('require' => $requiredPackages, 'source' => '/home/user/checkout/travis/silverstripe/comments', 'target' => '/home/user/builds/ss'); $expected = array('repositories' => array(0 => array('type' => 'package', 'package' => array('name' => 'silverstripe/subsites', 'type' => 'silverstripe-module', 'require' => array('silverstripe/framework' => '~3.2', 'silverstripe/cms' => '~3.2'), 'extra' => array('branch-alias' => array('dev-master' => '1.1.x-dev')), 'version' => 'dev-master'))), 'require' => array('silverstripe/subsites' => 'dev-master', 'silverstripe/framework' => '4.0.x-dev', 'silverstripe/cms' => '4.0.x-dev', 'silverstripe/comments' => '2.0.2', 'silverstripe/tagfield' => '1.2.1', 'silverstripe-themes/simple' => '*'), 'require-dev' => array('silverstripe/postgresql' => '*', 'silverstripe/sqlite3' => '*', 'phpunit/PHPUnit' => '~3.7@stable'), 'minimum-stability' => 'dev', 'config' => array('notify-on-install' => false, 'process-timeout' => 600)); $this->assertEquals($expected, $generator->generateComposerConfig($options)); }