Skip to content

Commit 9f6cbad

Browse files
authored
standardizes env vars, skips tests if not set (GoogleCloudPlatform#129)
1 parent 216dfac commit 9f6cbad

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

appengine/standard/mailgun/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
$app = new Application();
2121

2222
$app->get('/', function () use ($app) {
23-
if ($app['mailgun.domain'] == 'MAILGUN_DOMAIN_NAME') {
23+
if ($app['mailgun.domain'] == 'MAILGUN_DOMAIN') {
2424
return 'set your mailgun domain and API key in index.php';
2525
}
2626

appengine/standard/mailgun/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
$app = require __DIR__ . '/app.php';
2323

2424
// set your Mailgun domain name and API key
25-
$app['mailgun.domain'] = 'MAILGUN_DOMAIN_NAME';
25+
$app['mailgun.domain'] = 'MAILGUN_DOMAIN';
2626
$app['mailgun.api_key'] = 'MAILGUN_APIKEY';
2727

2828
// Run the app!

appengine/standard/mailgun/test/DeployAppEngineFlexTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,29 @@ class DeployAppEngineFlexTest extends \PHPUnit_Framework_TestCase
2323
{
2424
use AppEngineDeploymentTrait;
2525

26-
public function beforeDeploy()
26+
public static function beforeDeploy()
2727
{
28+
// set your Mailgun domain name and API key
29+
$mailgunDomain = getenv('MAILGUN_DOMAIN');
30+
$mailgunApiKey = getenv('MAILGUN_APIKEY');
31+
32+
if (empty($mailgunDomain) || empty($mailgunApiKey)) {
33+
self::markTestSkipped('set the MAILGUN_DOMAIN and MAILGUN_APIKEY environment variables');
34+
}
35+
2836
$tmpDir = FileUtil::cloneDirectoryIntoTmp(__DIR__ . '/..');
2937
FileUtil::copyDir(__DIR__ . '/../../../flexible/mailgun', $tmpDir);
3038
self::$gcloudWrapper->setDir($tmpDir);
3139
chdir($tmpDir);
3240
$indexPhp = file_get_contents('index.php');
3341
$indexPhp = str_replace(
34-
'MAILGUN_DOMAIN_NAME',
35-
getenv('MAILGUN_DOMAIN_NAME'),
42+
'MAILGUN_DOMAIN',
43+
$mailgunDomain,
3644
$indexPhp
3745
);
3846
$indexPhp = str_replace(
3947
'MAILGUN_APIKEY',
40-
getenv('MAILGUN_APIKEY'),
48+
$mailgunApiKey,
4149
$indexPhp
4250
);
4351
file_put_contents('index.php', $indexPhp);

0 commit comments

Comments
 (0)