Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Nov 28, 2014
2 parents bfe4ccf + 4715fbe commit 84abb5d
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions test/EmailAddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function testBasicInvalid()
}
}

/**
/**
* Ensures that the validator follows expected behavior for valid email addresses with complex local parts
*
* @return void
Expand Down Expand Up @@ -300,9 +300,7 @@ public function testComplexLocalValid()
*/
public function testMXRecords()
{
if (!constant('TESTS_ZEND_VALIDATOR_ONLINE_ENABLED')) {
$this->markTestSkipped('Testing MX records has been disabled');
}
$this->skipIfOnlineTestsDisabled();

$validator = new EmailAddress(Hostname::ALLOW_DNS, true);

Expand Down Expand Up @@ -342,9 +340,7 @@ public function testMXRecords()
*/
public function testNoMxRecordARecordFallback()
{
if (!constant('TESTS_ZEND_VALIDATOR_ONLINE_ENABLED')) {
$this->markTestSkipped('Testing MX records has been disabled');
}
$this->skipIfOnlineTestsDisabled();

$validator = new EmailAddress(Hostname::ALLOW_DNS, true);

Expand Down Expand Up @@ -645,10 +641,9 @@ public function testNotSetHostnameValidator()
*/
public function testGetMXRecord()
{
if (!constant('TESTS_ZEND_VALIDATOR_ONLINE_ENABLED')) {
$this->markTestSkipped('Testing MX records has been disabled');
}
$this->skipIfOnlineTestsDisabled();

$validator = new EmailAddress(array('useMxCheck' => true, 'allow' => Hostname::ALLOW_ALL));
$validator = new EmailAddress(array('useMxCheck' => true, 'allow' => Hostname::ALLOW_ALL));

if (!$validator->isMxSupported()) {
Expand Down Expand Up @@ -679,9 +674,8 @@ public function testEqualsMessageVariables()
*/
public function testUseMxCheckBasicValid()
{
if (!constant('TESTS_ZEND_VALIDATOR_ONLINE_ENABLED')) {
$this->markTestSkipped('Testing MX records has been disabled');
}
$this->skipIfOnlineTestsDisabled();

$validator = new EmailAddress(array(
'useMxCheck' => true,
'useDeepMxCheck' => true
Expand Down Expand Up @@ -807,4 +801,16 @@ public function testIpRangeValidationOnRangesNoLongerMarkedAsReserved()
$this->assertFalse($validator->isReserved('223.255.255.0'));
$this->assertFalse($validator->isReserved('223.255.255.255'));
}

/**
* @throws \PHPUnit_Framework_SkippedTestError
*
* @return void
*/
private function skipIfOnlineTestsDisabled()
{
if (! (defined('TESTS_ZEND_VALIDATOR_ONLINE_ENABLED') && \TESTS_ZEND_VALIDATOR_ONLINE_ENABLED)) {
$this->markTestSkipped('Testing MX records has been disabled');
}
}
}

0 comments on commit 84abb5d

Please sign in to comment.