1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-04 16:10:08 +01:00

Test log command

This commit is contained in:
Matt Stauffer
2023-01-11 19:25:09 -05:00
parent 6a61acbb6c
commit 401a2e96fa
3 changed files with 26 additions and 2 deletions

View File

@@ -663,7 +663,7 @@ function (ConsoleCommandEvent $event) {
'to your "'.Configuration::path().'" file.',
]));
exit;
return;
}
if (! isset($logs[$key])) {

View File

@@ -36,6 +36,9 @@ public function prepTestConfig(): void
Configuration::createLogDirectory();
Configuration::createCertificatesDirectory();
Configuration::writeBaseConfiguration();
// Keep this file empty, as it's tailed in a test
Filesystem::touch(VALET_HOME_PATH.'/Log/nginx-error.log');
}
/**

View File

@@ -994,7 +994,28 @@ public function test_which_php_command_reads_phprc()
public function test_log_command()
{
$this->markTestIncomplete();
[$app, $tester] = $this->appAndTester();
$tester->run(['command' => 'log']);
$tester->assertCommandIsSuccessful();
$this->assertStringContainsString('In order to tail a log', $tester->getDisplay());
}
public function test_log_command_with_key()
{
[$app, $tester] = $this->appAndTester();
$tester->run(['command' => 'log', 'key' => 'nginx']);
$tester->assertCommandIsSuccessful();
// Can't test this because log's output is run via the tail command
// $this->assertStringContainsString('nginx-error-log-contents', $tester->getDisplay());
// So instead, we'll test *against* the negative states
$this->assertStringNotContainsString('does not (yet) exit', $tester->getDisplay());
$this->assertStringNotContainsString('No logs found', $tester->getDisplay());
$this->assertStringNotContainsString('In order to tail a log', $tester->getDisplay());
}
public function test_directory_listing_command_reads()