userCmdPath = $consoleDir . '/_DummyDiscoveryCmd.php'; $cmd = <<<'PHP' writeln('ok'); return 0; } }; PHP; @file_put_contents($this->userCmdPath, $cmd); } protected function tearDown(): void { if (is_file($this->userCmdPath)) { @unlink($this->userCmdPath); } } public function testUserCommandIsDiscovered(): void { $root = dirname(__DIR__); $cmd = 'php ' . escapeshellarg($root . '/bin/phred') . ' list'; $output = shell_exec($cmd) ?: ''; $this->assertStringContainsString('dummy:discovery', $output, 'User command from console/commands should be discovered'); } }