MCPcopy Create free account
hub / github.com/ddev/ddev / TestComposerCreateProjectCmd

Function TestComposerCreateProjectCmd

cmd/ddev/cmd/composer-create-project_test.go:19–202  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestComposerCreateProjectCmd(t *testing.T) {
20 // Don't run this unless GOTEST_SHORT is unset; it doesn't need to be run everywhere.
21 if os.Getenv("GOTEST_SHORT") != "" {
22 t.Skip("Skip because GOTEST_SHORT is set")
23 }
24 if nodeps.IsWindows() {
25 t.Skip("Skipping on traditional windows where it hangs")
26 }
27 composerVersionForThisTest := nodeps.ComposerDefault
28 //composerVersionForThisTest := "2.8.0"
29
30 origDir, err := os.Getwd()
31 require.NoError(t, err)
32
33 validAppTypes := ddevapp.GetValidAppTypes()
34 if os.Getenv("GOTEST_SHORT") != "" {
35 validAppTypes = []string{nodeps.AppTypePHP, nodeps.AppTypeDrupal11}
36 }
37
38 for _, docRoot := range []string{"", "doc-root"} {
39 for _, projectType := range validAppTypes {
40 if projectType == nodeps.AppTypeDrupal6 {
41 t.Logf("== SKIP TestComposerCreateProjectCmd for project of type '%s' with docroot '%s'\n", projectType, docRoot)
42 t.Logf("== SKIP drupal6 projects uses a very old php version and composer create-project is very unlikely to be used")
43 continue
44 }
45 t.Logf("== BEGIN TestComposerCreateProjectCmd for project of type '%s' with docroot '%s'\n", projectType, docRoot)
46 tmpDir := testcommon.CreateTmpDir(t.Name() + projectType)
47 err = os.Chdir(tmpDir)
48 require.NoError(t, err)
49
50 // Prepare arguments
51 arguments := []string{"config", "--project-type", projectType, "--composer-version", composerVersionForThisTest}
52
53 composerDirOnHost := tmpDir
54 if docRoot != "" {
55 arguments = append(arguments, "--docroot", docRoot)
56 // For Drupal, we arbitrarily place the composer root to be the docroot
57 // Normally for Drupal the docroot would be web, and the composer root would be the
58 // project root (default). But here we're making sure we can use the docroot
59 // as the composer_root. Acquia sites often do this...
60 if slices.Contains([]string{nodeps.AppTypeDrupal12, nodeps.AppTypeDrupal11, nodeps.AppTypeDrupal10, nodeps.AppTypeDrupal9, nodeps.AppTypeDrupal8}, projectType) {
61 arguments = append(arguments, "--composer-root", docRoot)
62 composerDirOnHost = filepath.Join(tmpDir, docRoot)
63 }
64 }
65
66 // Basic config
67 _, err = exec.RunHostCommand(DdevBin, arguments...)
68 require.NoError(t, err)
69
70 // Test trivial command
71 out, err := exec.RunHostCommand(DdevBin, "composer", "--version")
72 require.NoError(t, err)
73 require.Contains(t, out, "Composer version")
74
75 // Get an app so we can do waits
76 app, err := ddevapp.NewApp(tmpDir, true)

Callers

nothing calls this directly

Calls 13

IsWindowsFunction · 0.92
GetValidAppTypesFunction · 0.92
CreateTmpDirFunction · 0.92
RunHostCommandFunction · 0.92
NewAppFunction · 0.92
NewManifestFunction · 0.92
ChdirMethod · 0.80
CleanupMethod · 0.80
StopMethod · 0.80
StartMethod · 0.80

Tested by

no test coverage detected