public function testIsValidCheckRecordValue() { $recordName = '_acme-challenge.bar.com.'; $recordValue = 'record_value'; DnsMock::register(DnsValidator::class); DnsMock::withMockedHosts([$recordName => [['type' => 'A', 'ip' => '1.2.3.4'], ['type' => 'TXT', 'entries' => ['somethingElse']]]]); $mockExtractor = $this->prophesize(DnsDataExtractor::class); $stubChallenge = $this->prophesize(AuthorizationChallenge::class); $validator = new DnsValidator($mockExtractor->reveal()); $mockExtractor->getRecordName($stubChallenge->reveal())->willReturn($recordName); $mockExtractor->getRecordValue($stubChallenge->reveal())->willReturn($recordValue); $this->assertFalse($validator->isValid($stubChallenge->reveal())); }
public function startTest(\PHPUnit_Framework_Test $test) { if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) { $groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false)); if (in_array('time-sensitive', $groups, true)) { ClockMock::register(get_class($test)); ClockMock::withClockMock(true); } if (in_array('dns-sensitive', $groups, true)) { DnsMock::register(get_class($test)); } $annotations = \PHPUnit_Util_Test::parseTestMethodAnnotations(get_class($test), $test->getName(false)); if (isset($annotations['class']['expectedDeprecation'])) { $test->getTestResultObject()->addError($test, new \PHPUnit_Framework_AssertionFailedError('`@expectedDeprecation` annotations are not allowed at the class level.'), 0); } if (isset($annotations['method']['expectedDeprecation'])) { if (!in_array('legacy', $groups, true)) { $test->getTestResultObject()->addError($test, new \PHPUnit_Framework_AssertionFailedError('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`.'), 0); } $this->expectedDeprecations = $annotations['method']['expectedDeprecation']; $this->previousErrorHandler = set_error_handler(array($this, 'handleError')); } } }
public function startTest(\PHPUnit_Framework_Test $test) { if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) { $groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName()); if (in_array('time-sensitive', $groups, true)) { ClockMock::register(get_class($test)); ClockMock::withClockMock(true); } if (in_array('dns-sensitive', $groups, true)) { DnsMock::register(get_class($test)); } } }