From fab86bbef3290efb32b543cc0b28e708fcc2789a Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Sat, 8 Apr 2017 11:22:20 +0200 Subject: [PATCH] Make integrationt tests safe to run simultaneously (#338) * Make integrationt tests safe to run simultaneously * cs * We only have the credentials when we do not make a PR --- .travis.yml | 4 +++- tests/Integration/DomainApiTest.php | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4d19e80..b6146ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,13 +20,15 @@ matrix: fast_finish: true include: - php: 5.5 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true + env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" PREFER_COVERAGE=true install: - travis_retry composer update ${COMPOSER_FLAGS} --prefer-source --no-interaction before_script: - if [[ "COVERAGE" = true ]]; then TEST_COMMAND="composer test-coverage"; fi + - if ! [[ "$TRAVIS_PULL_REQUEST" = false ]]; then TEST_COMMAND="composer test"; fi + - if [[ "$PREFER_COVERAGE" = true ]] && [[ "$TRAVIS_PULL_REQUEST" = false ]]; then TEST_COMMAND="composer test-coverage" COVERAGE=true; fi script: - echo $TEST_COMMAND diff --git a/tests/Integration/DomainApiTest.php b/tests/Integration/DomainApiTest.php index 2b4ac12..da3b391 100644 --- a/tests/Integration/DomainApiTest.php +++ b/tests/Integration/DomainApiTest.php @@ -26,11 +26,19 @@ use Mailgun\Tests\Api\TestCase; */ class DomainApiTest extends TestCase { + private static $domainName; + protected function getApiClass() { return 'Mailgun\Api\Domain'; } + public static function setUpBeforeClass() + { + parent::setUpBeforeClass(); + self::$domainName = 'example.'.uniqid().'notareal.tld'; + } + /** * Performs `GET /v3/domains` and ensures $this->testDomain exists * in the returned list. @@ -89,7 +97,7 @@ class DomainApiTest extends TestCase $mg = $this->getMailgunClient(); $domain = $mg->domains()->create( - 'example.notareal.tld', // domain name + self::$domainName, // domain name 'exampleOrgSmtpPassword12', // smtp password 'tag', // default spam action false // wildcard domain? @@ -112,7 +120,7 @@ class DomainApiTest extends TestCase $mg = $this->getMailgunClient(); $mg->domains()->create( - 'example.notareal.tld', // domain name + self::$domainName, // domain name 'exampleOrgSmtpPassword12', // smtp password 'tag', // default spam action false // wildcard domain? @@ -126,7 +134,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $ret = $mg->domains()->delete('example.notareal.tld'); + $ret = $mg->domains()->delete(self::$domainName); $this->assertNotNull($ret); $this->assertInstanceOf(DeleteResponse::class, $ret); $this->assertEquals('Domain has been deleted', $ret->getMessage());