diff --git a/README.md b/README.md index b073ce1..ab64c4f 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ Any output from this script is prefixed with `[php-watcher]`, otherwise all PHP-Watcher supports customization of its behavior with config files. The file for options may be named `.php-watcher.yml`, `php-watcher.yml` or `php -watcher.yml.dist`. The tool will look for a file in the current working directory in that order. +An alternative local configuration file can be specified with the `--config + ` option. The specificity is as follows, so that a command line argument will always override the config file settings: diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php new file mode 100644 index 0000000..0f6438d --- /dev/null +++ b/tests/ConfigTest.php @@ -0,0 +1,36 @@ + ['directory-to-watch']]); + $fileToWatch = Filesystem::createHelloWorldPHPFile(); + + $watcher = (new WatcherRunner())->run($fileToWatch, ['--watch', 'tests', '--config', $configFile]); + sleep(1); + + $output = $watcher->getOutput(); + $this->assertStringNotContainsString('directory-to-watch', $output); + } + + /** @test */ + public function it_can_use_config_path_from_command_line_arg(): void + { + $configFile = Filesystem::createConfigFile(['watch' => ['directory-to-watch']]); + $fileToWatch = Filesystem::createHelloWorldPHPFile(); + + $watcher = (new WatcherRunner())->run($fileToWatch, ['--config', $configFile]); + sleep(1); + + $output = $watcher->getOutput(); + $this->assertStringContainsString('directory-to-watch', $output); + } +}