Skip to content

Commit 3b7f7fd

Browse files
authored
Fixes mailjet test (GoogleCloudPlatform#770)
1 parent 2867f45 commit 3b7f7fd

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

.kokoro/secrets.sh.enc

45 Bytes
Binary file not shown.

appengine/php55/mailjet/app.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@
4040
/** @var Mailjet\Client $mailjet */
4141
$mailjet = $app['mailjet'];
4242
$recipient = $request->get('recipient');
43+
$sender = $app['mailjet.sender'] ?: "[email protected]";
4344

4445
# [START gae_mailjet_send_message]
4546
$body = [
46-
'FromEmail' => "[email protected]",
47+
'FromEmail' => $sender,
4748
'FromName' => "Testing Mailjet",
4849
'Subject' => "Your email flight plan!",
4950
'Text-part' => "Dear passenger, welcome to Mailjet! May the delivery force be with you!",

appengine/php55/mailjet/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"require-dev": {
88
"phpunit/phpunit": "~4.8",
99
"paragonie/random_compat": "^2.0",
10-
"google/cloud-tools": "^0.6"
10+
"google/cloud-tools": "^0.8.5"
1111
}
1212
}

appengine/php55/mailjet/index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
// set your Mailjet API key and secret
2525
$app['mailjet.api_key'] = 'MAILJET_APIKEY';
2626
$app['mailjet.secret'] = 'MAILJET_SECRET';
27+
// set your mailjet sender email. This must be verified in your mailjet account
28+
$app['mailjet.sender'] = '';
2729

2830
// Run the app!
2931
// use "gcloud app deploy" or run "php -S localhost:8000"

appengine/php55/mailjet/test/LocalTest.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,22 @@
1515
* limitations under the License.
1616
*/
1717
use Silex\WebTestCase;
18+
use Google\Cloud\TestUtils\TestTrait;
1819

1920
class LocalTest extends WebTestCase
2021
{
22+
use TestTrait;
23+
2124
public function createApplication()
2225
{
2326
$app = require __DIR__ . '/../app.php';
2427

2528
// set some parameters for testing
2629
$app['session.test'] = true;
2730
$app['debug'] = true;
28-
$projectId = getenv('GOOGLE_PROJECT_ID');
29-
30-
// set your Mailjet API key and secret
31-
$mailjetApiKey = getenv('MAILJET_APIKEY');
32-
$mailjetSecret = getenv('MAILJET_SECRET');
33-
34-
if (empty($mailjetApiKey) || empty($mailjetSecret)) {
35-
$this->markTestSkipped('set the MAILJET_APIKEY and MAILJET_SECRET environment variables');
36-
}
37-
38-
$app['mailjet.api_key'] = $mailjetApiKey;
39-
$app['mailjet.secret'] = $mailjetSecret;
31+
$app['mailjet.api_key'] = $this->requireEnv('MAILJET_APIKEY');
32+
$app['mailjet.secret'] = $this->requireEnv('MAILJET_SECRET');
33+
$app['mailjet.sender'] = $this->requireEnv('MAILJET_SENDER');
4034

4135
// prevent HTML error exceptions
4236
unset($app['exception_handler']);

testing/run_test_suite.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ FILES_CHANGED=$(git diff --name-only HEAD $(git merge-base HEAD master))
6767
# If any files outside the sample directories changed, or if we are not
6868
# on a Pull Request, run the whole test suite.
6969
if grep -q ^testing\/ <<< "$FILES_CHANGED" || \
70-
grep -q ^.kokoro\/ <<< "$FILES_CHANGED" || \
70+
grep -v ^.kokoro\/secrets.sh.enc$ <<< "$FILES_CHANGED" | grep -q ^.kokoro\/ || \
7171
grep -qv \/ <<< "$FILES_CHANGED" || \
7272
[ -z "$IS_PULL_REQUEST" ]; then
7373
RUN_ALL_TESTS=1

0 commit comments

Comments
 (0)