diff --git a/src/Console/Commands/ModulesSync.php b/src/Console/Commands/ModulesSync.php index c518b5d..7d268c5 100644 --- a/src/Console/Commands/ModulesSync.php +++ b/src/Console/Commands/ModulesSync.php @@ -14,7 +14,9 @@ class ModulesSync extends Command { - protected $signature = 'modules:sync {--no-phpstorm : Do not update PhpStorm config files}'; + protected $signature = 'modules:sync + {--no-phpstorm : Do not update PhpStorm config files} + {--no-phpunit : Do not update phpunit.xml file}'; protected $description = 'Sync your project\'s configuration with your current modules'; @@ -32,8 +34,10 @@ public function handle(ModuleRegistry $registry, Filesystem $filesystem) { $this->filesystem = $filesystem; $this->registry = $registry; - - $this->updatePhpUnit(); + + if (true !== $this->option('no-phpunit')) { + $this->updatePhpUnit(); + } if (true !== $this->option('no-phpstorm')) { $this->updatePhpStormConfig(); diff --git a/tests/Commands/ModulesSyncTest.php b/tests/Commands/ModulesSyncTest.php index 217c8cc..272d8e7 100644 --- a/tests/Commands/ModulesSyncTest.php +++ b/tests/Commands/ModulesSyncTest.php @@ -26,7 +26,7 @@ public function test_it_updates_phpunit_config(): void $this->assertCount(1, $nodes); } - + public function test_it_updates_phpstorm_plugin_config(): void { $config_path = $this->copyStub('laravel-plugin.xml', '.idea'); @@ -120,4 +120,21 @@ public function test_it_updates_phpstorm_iml_file(): void $this->assertCount(6, $nodes); } + + public function test_it_skips_updating_phpunit_config_with_flag(): void + { + $config_path = $this->copyStub('phpunit.xml', '/'); + + $config = simplexml_load_string($this->filesystem->get($config_path)); + $nodes = $config->xpath("//phpunit//testsuites//testsuite//directory[text()='./app-modules/*/tests']"); + + $this->assertCount(0, $nodes); + + $this->artisan(ModulesSync::class, ['--no-phpunit' => true]); + + $config = simplexml_load_string($this->filesystem->get($config_path)); + $nodes = $config->xpath("//phpunit//testsuites//testsuite//directory[text()='./app-modules/*/tests']"); + + $this->assertCount(0, $nodes); + } }