File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed
functions/slack_slash_command/test Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -50,9 +50,6 @@ public function testFunction(
50
50
$ statusCode ,
51
51
$ headers
52
52
): void {
53
- $ this ->requireEnv ('SLACK_SECRET ' );
54
- $ this ->requireEnv ('KG_API_KEY ' );
55
-
56
53
$ response = $ this ->client ->request (
57
54
$ method ,
58
55
'' ,
@@ -70,11 +67,16 @@ public function testFunction(
70
67
}
71
68
}
72
69
70
+ /**
71
+ * Deploy the Function.
72
+ *
73
+ * Overrides CloudFunctionLocalTestTrait::doDeploy().
74
+ */
73
75
private static function doDeploy ()
74
76
{
75
- // Forward required env variables to Cloud Functions
76
- $ envVars = 'SLACK_SECRET= ' . getenv ('SLACK_SECRET ' ) . ', ' ;
77
- $ envVars .= 'KG_API_KEY= ' . getenv ('KG_API_KEY ' );
77
+ // Forward required env variables to Cloud Functions.
78
+ $ envVars = 'SLACK_SECRET= ' . self :: requireEnv ('SLACK_SECRET ' ) . ', ' ;
79
+ $ envVars .= 'KG_API_KEY= ' . self :: requireEnv ('KG_API_KEY ' );
78
80
79
81
self ::$ fn ->deploy (['--update-env-vars ' => $ envVars ]);
80
82
}
Original file line number Diff line number Diff line change @@ -34,6 +34,19 @@ class IntegrationTest extends TestCase
34
34
35
35
private static $ entryPoint = 'receiveRequest ' ;
36
36
37
+ /**
38
+ * Run the PHP server locally for the defined function.
39
+ *
40
+ * Overrides CloudFunctionLocalTestTrait::doRun().
41
+ */
42
+ private static function doRun ()
43
+ {
44
+ self ::$ fn ->run ([
45
+ 'SLACK_SECRET ' => self ::requireEnv ('SLACK_SECRET ' ),
46
+ 'KG_API_KEY ' => self ::requireEnv ('KG_API_KEY ' ),
47
+ ]);
48
+ }
49
+
37
50
/**
38
51
* @dataProvider cases
39
52
*/
@@ -45,9 +58,6 @@ public function testFunction(
45
58
$ statusCode ,
46
59
$ headers
47
60
): void {
48
- $ this ->requireEnv ('SLACK_SECRET ' );
49
- $ this ->requireEnv ('KG_API_KEY ' );
50
-
51
61
$ response = $ this ->client ->request (
52
62
$ method ,
53
63
'/ ' ,
You can’t perform that action at this time.
0 commit comments