This repository was archived by the owner on Feb 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,7 @@ function mapPlatformShEnvironment() : void
26
26
// Default to production. You can override this value by setting
27
27
// `env:APP_ENV` as a project variable, or by adding it to the
28
28
// .platform.app.yaml variables block.
29
- if (!isset ($ _SERVER ['APP_ENV ' ])) {
30
- $ _SERVER ['APP_ENV ' ] = 'prod ' ;
31
- }
29
+ $ _SERVER ['APP_ENV ' ] = $ _SERVER ['APP_ENV ' ] ?? (getenv ('APP_ENV ' ) ?: null ) ?? 'prod ' ;
32
30
33
31
if (!isset ($ _SERVER ['DATABASE_URL ' ])) {
34
32
mapPlatformShDatabase ();
Original file line number Diff line number Diff line change @@ -36,4 +36,33 @@ public function testDontChangeAppSecret()
36
36
$ this ->assertEquals ('original ' , $ _SERVER ['APP_SECRET ' ]);
37
37
}
38
38
39
+ public function testAppEnvAlreadySetInServer ()
40
+ {
41
+ putenv ('PLATFORM_APPLICATION=test ' );
42
+ $ _SERVER ['APP_ENV ' ] = 'dev ' ;
43
+
44
+ mapPlatformShEnvironment ();
45
+
46
+ $ this ->assertEquals ('dev ' , $ _SERVER ['APP_ENV ' ]);
47
+ }
48
+
49
+ public function testAppEnvAlreadySetInEnv ()
50
+ {
51
+ putenv ('PLATFORM_APPLICATION=test ' );
52
+ putenv ('APP_ENV=dev ' );
53
+
54
+ mapPlatformShEnvironment ();
55
+
56
+ $ this ->assertEquals ('dev ' , $ _SERVER ['APP_ENV ' ]);
57
+ }
58
+
59
+ public function testAppEnvNeedsDefault ()
60
+ {
61
+ putenv ('PLATFORM_APPLICATION=test ' );
62
+
63
+ mapPlatformShEnvironment ();
64
+
65
+ $ this ->assertEquals ('prod ' , $ _SERVER ['APP_ENV ' ]);
66
+ }
67
+
39
68
}
You can’t perform that action at this time.
0 commit comments