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
This commit is contained in:
Tobias Nyholm 2017-04-08 11:22:20 +02:00 committed by GitHub
parent afd8f361f3
commit fab86bbef3
2 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -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());