From 186bee10422a2c5db87c2767a453b0828ed25b73 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 11 Dec 2018 14:10:55 +0100 Subject: [PATCH] Allow configuring the "extra.symfony.root-dir" of the Symfony app --- src/Configurator/AbstractConfigurator.php | 2 +- src/Configurator/BundlesConfigurator.php | 2 +- src/Configurator/ContainerConfigurator.php | 4 ++-- .../CopyFromPackageConfigurator.php | 6 +++--- .../CopyFromRecipeConfigurator.php | 6 +++--- src/Configurator/EnvConfigurator.php | 10 +++++----- src/Configurator/GitignoreConfigurator.php | 4 ++-- src/Configurator/MakefileConfigurator.php | 11 ++++++----- src/Flex.php | 11 +++++++---- src/ScriptExecutor.php | 2 +- tests/Configurator/BundlesConfiguratorTest.php | 4 ++-- .../Configurator/ContainerConfiguratorTest.php | 16 ++++++++-------- ...opyDirectoryFromPackageConfiguratorTest.php | 12 ++++++------ .../CopyFromPackageConfiguratorTest.php | 12 ++++++------ .../CopyFromRecipeConfiguratorTest.php | 6 +++--- tests/Configurator/EnvConfiguratorTest.php | 12 ++++++------ .../Configurator/GitignoreConfiguratorTest.php | 4 ++-- .../Configurator/MakefileConfiguratorTest.php | 4 ++-- tests/bootstrap.php | 18 +++--------------- 19 files changed, 69 insertions(+), 77 deletions(-) diff --git a/src/Configurator/AbstractConfigurator.php b/src/Configurator/AbstractConfigurator.php index c61b4aeea..befb84e21 100644 --- a/src/Configurator/AbstractConfigurator.php +++ b/src/Configurator/AbstractConfigurator.php @@ -32,7 +32,7 @@ public function __construct(Composer $composer, IOInterface $io, Options $option $this->composer = $composer; $this->io = $io; $this->options = $options; - $this->path = new Path(getcwd()); + $this->path = new Path($options->get('root-dir')); } abstract public function configure(Recipe $recipe, $config, array $options = []); diff --git a/src/Configurator/BundlesConfigurator.php b/src/Configurator/BundlesConfigurator.php index 4c94371d4..ac7a30fba 100644 --- a/src/Configurator/BundlesConfigurator.php +++ b/src/Configurator/BundlesConfigurator.php @@ -100,6 +100,6 @@ private function dump(string $file, array $bundles) private function getConfFile(): string { - return $this->options->expandTargetDir('%CONFIG_DIR%/bundles.php'); + return $this->options->get('root-dir').'/'.$this->options->expandTargetDir('%CONFIG_DIR%/bundles.php'); } } diff --git a/src/Configurator/ContainerConfigurator.php b/src/Configurator/ContainerConfigurator.php index 8e80b5822..5d57a2896 100644 --- a/src/Configurator/ContainerConfigurator.php +++ b/src/Configurator/ContainerConfigurator.php @@ -27,7 +27,7 @@ public function configure(Recipe $recipe, $parameters, array $options = []) public function unconfigure(Recipe $recipe, $parameters) { $this->write('Unsetting parameters'); - $target = $this->options->expandTargetDir('%CONFIG_DIR%/services.yaml'); + $target = $this->options->get('root-dir').'/'.$this->options->expandTargetDir('%CONFIG_DIR%/services.yaml'); $lines = []; foreach (file($target) as $line) { foreach (array_keys($parameters) as $key) { @@ -42,7 +42,7 @@ public function unconfigure(Recipe $recipe, $parameters) private function addParameters(array $parameters) { - $target = $this->options->expandTargetDir('%CONFIG_DIR%/services.yaml'); + $target = $this->options->get('root-dir').'/'.$this->options->expandTargetDir('%CONFIG_DIR%/services.yaml'); $endAt = 0; $isParameters = false; $lines = []; diff --git a/src/Configurator/CopyFromPackageConfigurator.php b/src/Configurator/CopyFromPackageConfigurator.php index debee4b77..4813bef2e 100644 --- a/src/Configurator/CopyFromPackageConfigurator.php +++ b/src/Configurator/CopyFromPackageConfigurator.php @@ -23,14 +23,14 @@ public function configure(Recipe $recipe, $config, array $options = []) { $this->write('Setting configuration and copying files'); $packageDir = $this->composer->getInstallationManager()->getInstallPath($recipe->getPackage()); - $this->copyFiles($config, $packageDir, getcwd(), $options['force'] ?? false); + $this->copyFiles($config, $packageDir, $this->options->get('root-dir'), $options['force'] ?? false); } public function unconfigure(Recipe $recipe, $config) { $this->write('Removing configuration and files'); $packageDir = $this->composer->getInstallationManager()->getInstallPath($recipe->getPackage()); - $this->removeFiles($config, $packageDir, getcwd()); + $this->removeFiles($config, $packageDir, $this->options->get('root-dir')); } private function copyFiles(array $manifest, string $from, string $to, bool $overwrite = false) @@ -97,7 +97,7 @@ public function copyFile(string $source, string $target, bool $overwrite = false throw new LogicException(sprintf('File "%s" does not exist!', $source)); } - copy($source, $target); + file_put_contents($target, $this->options->expandTargetDir(file_get_contents($source))); @chmod($target, fileperms($target) | (fileperms($source) & 0111)); $this->write(sprintf('Created "%s"', $this->path->relativize($target))); } diff --git a/src/Configurator/CopyFromRecipeConfigurator.php b/src/Configurator/CopyFromRecipeConfigurator.php index b8d103ce0..ce246f3f7 100644 --- a/src/Configurator/CopyFromRecipeConfigurator.php +++ b/src/Configurator/CopyFromRecipeConfigurator.php @@ -21,13 +21,13 @@ class CopyFromRecipeConfigurator extends AbstractConfigurator public function configure(Recipe $recipe, $config, array $options = []) { $this->write('Setting configuration and copying files'); - $this->copyFiles($config, $recipe->getFiles(), getcwd(), $options['force'] ?? false); + $this->copyFiles($config, $recipe->getFiles(), $this->options->get('root-dir'), $options['force'] ?? false); } public function unconfigure(Recipe $recipe, $config) { $this->write('Removing configuration and files'); - $this->removeFiles($config, $recipe->getFiles(), getcwd()); + $this->removeFiles($config, $recipe->getFiles(), $this->options->get('root-dir')); } private function copyFiles(array $manifest, array $files, string $to, bool $overwrite = false) @@ -62,7 +62,7 @@ private function copyFile(string $to, string $contents, bool $executable, bool $ mkdir(\dirname($to), 0777, true); } - file_put_contents($to, $contents); + file_put_contents($to, $this->options->expandTargetDir($contents)); if ($executable) { @chmod($to, fileperms($to) | 0111); } diff --git a/src/Configurator/EnvConfigurator.php b/src/Configurator/EnvConfigurator.php index e6a334562..d454ff133 100644 --- a/src/Configurator/EnvConfigurator.php +++ b/src/Configurator/EnvConfigurator.php @@ -23,7 +23,7 @@ public function configure(Recipe $recipe, $vars, array $options = []) $this->write('Added environment variable defaults'); $this->configureEnvDist($recipe, $vars); - if (!file_exists(getcwd().'/.env.test')) { + if (!file_exists($this->options->get('root-dir').'/.env.test')) { $this->configurePhpUnit($recipe, $vars); } } @@ -37,7 +37,7 @@ public function unconfigure(Recipe $recipe, $vars) private function configureEnvDist(Recipe $recipe, $vars) { foreach (['.env.dist', '.env'] as $file) { - $env = getcwd().'/'.$file; + $env = $this->options->get('root-dir').'/'.$file; if (!is_file($env)) { continue; } @@ -69,7 +69,7 @@ private function configureEnvDist(Recipe $recipe, $vars) private function configurePhpUnit(Recipe $recipe, $vars) { foreach (['phpunit.xml.dist', 'phpunit.xml'] as $file) { - $phpunit = getcwd().'/'.$file; + $phpunit = $this->options->get('root-dir').'/'.$file; if (!is_file($phpunit)) { continue; } @@ -110,7 +110,7 @@ private function configurePhpUnit(Recipe $recipe, $vars) private function unconfigureEnvFiles(Recipe $recipe, $vars) { foreach (['.env', '.env.dist'] as $file) { - $env = getcwd().'/'.$file; + $env = $this->options->get('root-dir').'/'.$file; if (!file_exists($env)) { continue; } @@ -128,7 +128,7 @@ private function unconfigureEnvFiles(Recipe $recipe, $vars) private function unconfigurePhpUnit(Recipe $recipe, $vars) { foreach (['phpunit.xml.dist', 'phpunit.xml'] as $file) { - $phpunit = getcwd().'/'.$file; + $phpunit = $this->options->get('root-dir').'/'.$file; if (!is_file($phpunit)) { continue; } diff --git a/src/Configurator/GitignoreConfigurator.php b/src/Configurator/GitignoreConfigurator.php index 9787bcfa1..d9da91580 100644 --- a/src/Configurator/GitignoreConfigurator.php +++ b/src/Configurator/GitignoreConfigurator.php @@ -22,7 +22,7 @@ public function configure(Recipe $recipe, $vars, array $options = []) { $this->write('Added entries to .gitignore'); - $gitignore = getcwd().'/.gitignore'; + $gitignore = $this->options->get('root-dir').'/.gitignore'; if ($this->isFileMarked($recipe, $gitignore)) { return; } @@ -37,7 +37,7 @@ public function configure(Recipe $recipe, $vars, array $options = []) public function unconfigure(Recipe $recipe, $vars) { - $file = getcwd().'/.gitignore'; + $file = $this->options->get('root-dir').'/.gitignore'; if (!file_exists($file)) { return; } diff --git a/src/Configurator/MakefileConfigurator.php b/src/Configurator/MakefileConfigurator.php index 9963cfe3e..a6aa47419 100644 --- a/src/Configurator/MakefileConfigurator.php +++ b/src/Configurator/MakefileConfigurator.php @@ -22,16 +22,17 @@ public function configure(Recipe $recipe, $definitions, array $options = []) { $this->write('Added Makefile entries'); - $makefile = getcwd().'/Makefile'; + $makefile = $this->options->get('root-dir').'/Makefile'; if ($this->isFileMarked($recipe, $makefile)) { return; } - $data = $this->markData($recipe, implode("\n", $definitions)); + $data = $this->options->expandTargetDir(implode("\n", $definitions)); + $data = $this->markData($recipe, $data); if (!file_exists($makefile)) { file_put_contents( - getcwd().'/Makefile', + $this->options->get('root-dir').'/Makefile', <<options->get('root-dir').'/Makefile', "\n".ltrim($data, "\r\n"), FILE_APPEND); } public function unconfigure(Recipe $recipe, $vars) { - if (!file_exists($makefile = getcwd().'/Makefile')) { + if (!file_exists($makefile = $this->options->get('root-dir').'/Makefile')) { return; } diff --git a/src/Flex.php b/src/Flex.php index 6dfcfd42f..12e39e3dc 100644 --- a/src/Flex.php +++ b/src/Flex.php @@ -292,10 +292,10 @@ public function update(Event $event, $operations = []) if ($operations) { $this->operations = $operations; } - $cwd = getcwd(); + $rootDir = $this->options->get('root-dir'); - if (!file_exists("$cwd/.env") && !file_exists("$cwd/.env.local") && file_exists("$cwd/.env.dist") && false === strpos(file_get_contents("$cwd/.env.dist"), '.env.local')) { - copy(getcwd().'/.env.dist', getcwd().'/.env'); + if (!file_exists("$rootDir/.env") && !file_exists("$rootDir/.env.local") && file_exists("$rootDir/.env.dist") && false === strpos(file_get_contents("$rootDir/.env.dist"), '.env.local')) { + copy($rootDir.'/.env.dist', $rootDir.'/.env'); } list($recipes, $vulnerabilities) = $this->fetchRecipes(); @@ -629,6 +629,8 @@ private function fetchRecipes(): array private function initOptions(): Options { + $extra = $this->composer->getPackage()->getExtra(); + $options = array_merge([ 'bin-dir' => 'bin', 'conf-dir' => 'conf', @@ -636,7 +638,8 @@ private function initOptions(): Options 'src-dir' => 'src', 'var-dir' => 'var', 'public-dir' => 'public', - ], $this->composer->getPackage()->getExtra()); + 'root-dir' => $extra['symfony']['root-dir'] ?? '.', + ], $extra); return new Options($options, $this->io); } diff --git a/src/ScriptExecutor.php b/src/ScriptExecutor.php index d22dacb08..dc9d80e64 100644 --- a/src/ScriptExecutor.php +++ b/src/ScriptExecutor.php @@ -99,7 +99,7 @@ private function expandSymfonyCmd(string $cmd) return null; } - $console = ProcessExecutor::escape($this->options->get('bin-dir').'/console'); + $console = ProcessExecutor::escape($this->options->get('root-dir').'/'.$this->options->get('bin-dir').'/console'); if ($this->io->isDecorated()) { $console .= ' --ansi'; } diff --git a/tests/Configurator/BundlesConfiguratorTest.php b/tests/Configurator/BundlesConfiguratorTest.php index 5a921565a..1313db53e 100644 --- a/tests/Configurator/BundlesConfiguratorTest.php +++ b/tests/Configurator/BundlesConfiguratorTest.php @@ -20,12 +20,12 @@ class BundlesConfiguratorTest extends TestCase { public function testConfigure() { - $config = getcwd().'/config/bundles.php'; + $config = FLEX_TEST_DIR.'/config/bundles.php'; $configurator = new BundlesConfigurator( $this->getMockBuilder('Composer\Composer')->getMock(), $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), - new Options(['config-dir' => \dirname($config)]) + new Options(['config-dir' => 'config', 'root-dir' => FLEX_TEST_DIR]) ); $recipe = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); diff --git a/tests/Configurator/ContainerConfiguratorTest.php b/tests/Configurator/ContainerConfiguratorTest.php index 2f9c316d4..731fa034b 100644 --- a/tests/Configurator/ContainerConfiguratorTest.php +++ b/tests/Configurator/ContainerConfiguratorTest.php @@ -23,7 +23,7 @@ class ContainerConfiguratorTest extends TestCase public function testConfigure() { $recipe = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); - $config = getcwd().'/config/services.yaml'; + $config = FLEX_TEST_DIR.'/config/services.yaml'; file_put_contents( $config, <<getMockBuilder(Composer::class)->getMock(), $this->getMockBuilder(IOInterface::class)->getMock(), - new Options(['config-dir' => \dirname($config)]) + new Options(['config-dir' => 'config', 'root-dir' => FLEX_TEST_DIR]) ); $configurator->configure($recipe, ['locale' => 'en']); $this->assertEquals(<<getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); - $config = getcwd().'/config/services.yaml'; + $config = FLEX_TEST_DIR.'/config/services.yaml'; file_put_contents( $config, <<getMockBuilder(Composer::class)->getMock(), $this->getMockBuilder(IOInterface::class)->getMock(), - new Options(['config-dir' => \dirname($config)]) + new Options(['config-dir' => 'config', 'root-dir' => FLEX_TEST_DIR]) ); $configurator->configure($recipe, ['locale' => 'en']); $this->assertEquals(<<getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); - $config = getcwd().'/config/services.yaml'; + $config = FLEX_TEST_DIR.'/config/services.yaml'; file_put_contents( $config, <<getMockBuilder(Composer::class)->getMock(), $this->getMockBuilder(IOInterface::class)->getMock(), - new Options(['config-dir' => \dirname($config)]) + new Options(['config-dir' => 'config', 'root-dir' => FLEX_TEST_DIR]) ); $configurator->configure($recipe, ['locale' => 'en']); $this->assertEquals(<<getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); - $config = getcwd().'/config/services.yaml'; + $config = FLEX_TEST_DIR.'/config/services.yaml'; file_put_contents( $config, <<getMockBuilder(Composer::class)->getMock(), $this->getMockBuilder(IOInterface::class)->getMock(), - new Options(['config-dir' => \dirname($config)]) + new Options(['config-dir' => 'config', 'root-dir' => FLEX_TEST_DIR]) ); $configurator->configure($recipe, ['locale' => 'en', 'foobar' => 'baz']); $this->assertEquals(<<sourceDirectory = getcwd().'/package/files'; + $this->sourceDirectory = FLEX_TEST_DIR.'/package/files'; $this->sourceFileRelativePath = 'package/files/'; $this->sourceFiles = [ $this->sourceDirectory.'/file1', $this->sourceDirectory.'/file2', ]; - $this->targetDirectory = getcwd().'/public/files'; + $this->targetDirectory = FLEX_TEST_DIR.'/public/files'; $this->targetFileRelativePath = 'public/files/'; $this->targetFiles = [ $this->targetDirectory.'/file1', @@ -79,7 +79,7 @@ protected function setUp() $installationManager->expects($this->exactly(1)) ->method('getInstallPath') ->with($package) - ->willReturn(getcwd()) + ->willReturn(FLEX_TEST_DIR) ; $this->composer = $this->getMockBuilder(Composer::class)->getMock(); $this->composer->expects($this->exactly(1)) @@ -102,13 +102,13 @@ protected function tearDown() private function createConfigurator(): CopyFromPackageConfigurator { - return new CopyFromPackageConfigurator($this->composer, $this->io, new Options()); + return new CopyFromPackageConfigurator($this->composer, $this->io, new Options(['root-dir' => FLEX_TEST_DIR])); } private function cleanUpTargetFiles() { - $this->rrmdir(getcwd().'/package'); - $this->rrmdir(getcwd().'/public'); + $this->rrmdir(FLEX_TEST_DIR.'/package'); + $this->rrmdir(FLEX_TEST_DIR.'/public'); } /** diff --git a/tests/Configurator/CopyFromPackageConfiguratorTest.php b/tests/Configurator/CopyFromPackageConfiguratorTest.php index f9deb59e4..08b856aff 100644 --- a/tests/Configurator/CopyFromPackageConfiguratorTest.php +++ b/tests/Configurator/CopyFromPackageConfiguratorTest.php @@ -119,11 +119,11 @@ protected function setUp() { parent::setUp(); - $this->sourceDirectory = getcwd().'/package'; + $this->sourceDirectory = FLEX_TEST_DIR.'/package'; $this->sourceFileRelativePath = 'package/file'; $this->sourceFile = $this->sourceDirectory.'/file'; - $this->targetDirectory = getcwd().'/public'; + $this->targetDirectory = FLEX_TEST_DIR.'/public'; $this->targetFileRelativePath = 'public/file'; $this->targetFile = $this->targetDirectory.'/file'; @@ -137,7 +137,7 @@ protected function setUp() $installationManager->expects($this->exactly(1)) ->method('getInstallPath') ->with($package) - ->willReturn(getcwd()) + ->willReturn(FLEX_TEST_DIR) ; $this->composer = $this->getMockBuilder(Composer::class)->getMock(); $this->composer->expects($this->exactly(1)) @@ -158,13 +158,13 @@ protected function tearDown() private function createConfigurator(): CopyFromPackageConfigurator { - return new CopyFromPackageConfigurator($this->composer, $this->io, new Options([], $this->io)); + return new CopyFromPackageConfigurator($this->composer, $this->io, new Options(['root-dir' => FLEX_TEST_DIR], $this->io)); } private function cleanUpTargetFiles() { @unlink($this->targetFile); - @rmdir(getcwd().'/package'); - @rmdir(getcwd().'/public'); + @rmdir(FLEX_TEST_DIR.'/package'); + @rmdir(FLEX_TEST_DIR.'/public'); } } diff --git a/tests/Configurator/CopyFromRecipeConfiguratorTest.php b/tests/Configurator/CopyFromRecipeConfiguratorTest.php index 1944a484d..036b0bb3a 100644 --- a/tests/Configurator/CopyFromRecipeConfiguratorTest.php +++ b/tests/Configurator/CopyFromRecipeConfiguratorTest.php @@ -98,11 +98,11 @@ protected function setUp() { parent::setUp(); - $this->sourceDirectory = getcwd().'/source'; + $this->sourceDirectory = FLEX_TEST_DIR.'/source'; $this->sourceFileRelativePath = 'source/file'; $this->sourceFile = $this->targetDirectory.'/file'; - $this->targetDirectory = getcwd().'/config'; + $this->targetDirectory = FLEX_TEST_DIR.'/config'; $this->targetFileRelativePath = 'config/file'; $this->targetFile = $this->targetDirectory.'/file'; @@ -127,7 +127,7 @@ protected function tearDown() private function createConfigurator(): CopyFromRecipeConfigurator { - return new CopyFromRecipeConfigurator($this->getMockBuilder(Composer::class)->getMock(), $this->io, new Options([], $this->io)); + return new CopyFromRecipeConfigurator($this->getMockBuilder(Composer::class)->getMock(), $this->io, new Options(['root-dir' => FLEX_TEST_DIR], $this->io)); } private function cleanUpTargetFiles() diff --git a/tests/Configurator/EnvConfiguratorTest.php b/tests/Configurator/EnvConfiguratorTest.php index e2f901f3d..01e0eb7b1 100644 --- a/tests/Configurator/EnvConfiguratorTest.php +++ b/tests/Configurator/EnvConfiguratorTest.php @@ -25,17 +25,17 @@ public function testConfigure() $configurator = new EnvConfigurator( $this->getMockBuilder(Composer::class)->getMock(), $this->getMockBuilder(IOInterface::class)->getMock(), - new Options() + new Options(['root-dir' => FLEX_TEST_DIR]) ); $recipe = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); $recipe->expects($this->any())->method('getName')->will($this->returnValue('FooBundle')); - $env = getcwd().'/.env.dist'; + $env = FLEX_TEST_DIR.'/.env.dist'; @unlink($env); touch($env); - $phpunit = getcwd().'/phpunit.xml'; + $phpunit = FLEX_TEST_DIR.'/phpunit.xml'; $phpunitDist = $phpunit.'.dist'; @unlink($phpunit); @unlink($phpunitDist); @@ -152,16 +152,16 @@ public function testConfigureGeneratedSecret() $configurator = new EnvConfigurator( $this->getMockBuilder(Composer::class)->getMock(), $this->getMockBuilder(IOInterface::class)->getMock(), - new Options() + new Options(['root-dir' => FLEX_TEST_DIR]) ); $recipe = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); $recipe->expects($this->any())->method('getName')->will($this->returnValue('FooBundle')); - $env = getcwd().'/.env.dist'; + $env = FLEX_TEST_DIR.'/.env.dist'; @unlink($env); touch($env); - $phpunit = getcwd().'/phpunit.xml'; + $phpunit = FLEX_TEST_DIR.'/phpunit.xml'; $phpunitDist = $phpunit.'.dist'; @unlink($phpunit); @unlink($phpunitDist); diff --git a/tests/Configurator/GitignoreConfiguratorTest.php b/tests/Configurator/GitignoreConfiguratorTest.php index 0bde2c79e..b95b6aa52 100644 --- a/tests/Configurator/GitignoreConfiguratorTest.php +++ b/tests/Configurator/GitignoreConfiguratorTest.php @@ -25,7 +25,7 @@ public function testConfigure() $configurator = new GitignoreConfigurator( $this->getMockBuilder(Composer::class)->getMock(), $this->getMockBuilder(IOInterface::class)->getMock(), - new Options(['public-dir' => 'public']) + new Options(['public-dir' => 'public', 'root-dir' => FLEX_TEST_DIR]) ); $recipe1 = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); @@ -34,7 +34,7 @@ public function testConfigure() $recipe2 = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); $recipe2->expects($this->any())->method('getName')->will($this->returnValue('BarBundle')); - $gitignore = getcwd().'/.gitignore'; + $gitignore = FLEX_TEST_DIR.'/.gitignore'; @unlink($gitignore); touch($gitignore); diff --git a/tests/Configurator/MakefileConfiguratorTest.php b/tests/Configurator/MakefileConfiguratorTest.php index cc62645a2..d5697d8a4 100644 --- a/tests/Configurator/MakefileConfiguratorTest.php +++ b/tests/Configurator/MakefileConfiguratorTest.php @@ -25,7 +25,7 @@ public function testConfigure() $configurator = new MakefileConfigurator( $this->getMockBuilder(Composer::class)->getMock(), $this->getMockBuilder(IOInterface::class)->getMock(), - new Options() + new Options(['root-dir' => FLEX_TEST_DIR]) ); $recipe1 = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); @@ -34,7 +34,7 @@ public function testConfigure() $recipe2 = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock(); $recipe2->expects($this->any())->method('getName')->will($this->returnValue('BarBundle')); - $makefile = getcwd().'/Makefile'; + $makefile = FLEX_TEST_DIR.'/Makefile'; @unlink($makefile); touch($makefile); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index de90d20e9..dd9b9db2c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,22 +1,10 @@