- $output = $commandTester->getDisplay();
- $this->assertStringContainsString("A BookStack install has been initialized at: " . $dir, $output);
+ $result->assertStdoutContains("A BookStack install has been initialized at: " . $dir);
+
+ $this->deleteDirectory($dir);
+ }
+
+ public function test_command_custom_path_validation()
+ {
+ $dir = $this->getEmptyTestDir();
+ $file = $dir . '/out.txt';
+ file_put_contents($file, 'hello');
+
+ $result = $this->runCommand('init', ['target-directory' => $file]);
+ $result->assertErrorExit();
+ $result->assertStderrContains("Was provided [{$file}] as an install path but existing file provided.");
+
+ $result = $this->runCommand('init', ['target-directory' => $dir]);
+ $result->assertErrorExit();
+ $result->assertStderrContains("Expected install directory to be empty but existing files found in [{$dir}] target location.");
+
+ $result = $this->runCommand('init', ['target-directory' => '/my/duck/says/hello']);
+ $result->assertErrorExit();
+ $result->assertStderrContains("Could not resolve provided [/my/duck/says/hello] path to an existing folder.");