MCPcopy Index your code
hub / github.com/php/frankenphp / TestExecuteScriptCLI

Function TestExecuteScriptCLI

cli_test.go:14–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestExecuteScriptCLI(t *testing.T) {
15 if _, err := os.Stat("internal/testcli/testcli"); err != nil {
16 t.Skip("internal/testcli/testcli has not been compiled, run `cd internal/testcli/ && go build`")
17 }
18
19 cmd := exec.Command("internal/testcli/testcli", "testdata/command.php", "foo", "bar")
20 stdoutStderr, err := cmd.CombinedOutput()
21 assert.Error(t, err)
22
23 var exitError *exec.ExitError
24 if errors.As(err, &exitError) {
25 assert.Equal(t, 3, exitError.ExitCode())
26 }
27
28 stdoutStderrStr := string(stdoutStderr)
29
30 assert.Contains(t, stdoutStderrStr, `"foo"`)
31 assert.Contains(t, stdoutStderrStr, `"bar"`)
32 assert.Contains(t, stdoutStderrStr, "From the CLI")
33}
34
35func TestExecuteCLICode(t *testing.T) {
36 if _, err := os.Stat("internal/testcli/testcli"); err != nil {

Callers

nothing calls this directly

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected