(t *testing.T)
| 80 | } |
| 81 | |
| 82 | func TestComposerCmdCreateRequireRemoveConfigVersion(t *testing.T) { |
| 83 | assert := asrt.New(t) |
| 84 | |
| 85 | origDir, err := os.Getwd() |
| 86 | assert.NoError(err) |
| 87 | |
| 88 | for _, composerRoot := range []string{"", "composer-root"} { |
| 89 | tmpDir := testcommon.CreateTmpDir(t.Name()) |
| 90 | err = os.Chdir(tmpDir) |
| 91 | assert.NoError(err) |
| 92 | |
| 93 | // Prepare arguments |
| 94 | arguments := []string{"config", "--project-type", "php"} |
| 95 | |
| 96 | if composerRoot != "" { |
| 97 | arguments = append(arguments, "--composer-root", composerRoot) |
| 98 | err = os.Mkdir(composerRoot, 0777) |
| 99 | assert.NoError(err) |
| 100 | } |
| 101 | |
| 102 | // Basic config |
| 103 | _, err = exec.RunHostCommand(DdevBin, arguments...) |
| 104 | assert.NoError(err) |
| 105 | |
| 106 | // Test trivial command |
| 107 | out, err := exec.RunHostCommand(DdevBin, "composer") |
| 108 | assert.NoError(err) |
| 109 | assert.Contains(out, "Available commands:") |
| 110 | |
| 111 | // Get an app so we can do waits |
| 112 | app, err := ddevapp.NewApp(tmpDir, true) |
| 113 | assert.NoError(err) |
| 114 | |
| 115 | t.Cleanup(func() { |
| 116 | //nolint: errcheck |
| 117 | err = app.Stop(true, false) |
| 118 | assert.NoError(err) |
| 119 | |
| 120 | err = os.Chdir(origDir) |
| 121 | assert.NoError(err) |
| 122 | _ = os.RemoveAll(tmpDir) |
| 123 | }) |
| 124 | |
| 125 | // ddev composer create-project --prefer-dist --no-dev --no-install psr/log:1.1.0 . |
| 126 | args := []string{"composer", "create-project", "--prefer-dist", "--no-dev", "--no-install", "psr/log:1.1.0", "."} |
| 127 | out, err = exec.RunHostCommand(DdevBin, args...) |
| 128 | assert.NoError(err, "failed to run %v: err=%v, output=\n=====\n%s\n=====\n", args, err, out) |
| 129 | assert.Contains(out, "Created project in ") |
| 130 | assert.FileExists(filepath.Join(tmpDir, composerRoot, "composer.json")) |
| 131 | assert.FileExists(filepath.Join(tmpDir, composerRoot, "Psr/Log/LogLevel.php")) |
| 132 | |
| 133 | // Test a composer require, with passthrough args |
| 134 | args = []string{"composer", "require", "sebastian/version:5.0.1 as 5.0.0", "--no-plugins", "--ansi", "--no-security-blocking"} |
| 135 | out, err = exec.RunHostCommand(DdevBin, args...) |
| 136 | assert.NoError(err, "failed to run %v: err=%v, output=\n=====\n%s\n=====\n", args, err, out) |
| 137 | assert.Contains(out, "Generating autoload files") |
| 138 | assert.FileExists(filepath.Join(tmpDir, composerRoot, "vendor/sebastian/version/composer.json")) |
| 139 | // Test a composer remove |
nothing calls this directly
no test coverage detected