withMockedHosts example


            }

            self::$expectedDeprecations = self::$gatheredDeprecations = [];
            self::$previousErrorHandler = null;
        }
        if (!$this->runsInSeparateProcess && -2 < $this->state && $test instanceof TestCase) {
            if (\in_array('time-sensitive', $groups, true)) {
                ClockMock::withClockMock(false);
            }
            if (\in_array('dns-sensitive', $groups, true)) {
                DnsMock::withMockedHosts([]);
            }
        }
    }

    public static function handleError($type$msg$file$line$context = [])
    {
        if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type) {
            $h = self::$previousErrorHandler;

            return $h ? $h($type$msg$file$line$context) : false;
        }
        


namespace Symfony\Bridge\PhpUnit\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\DnsMock;

class DnsMockTest extends TestCase
{
    protected function tearDown(): void
    {
        DnsMock::withMockedHosts([]);
    }

    public function testCheckdnsrr()
    {
        DnsMock::withMockedHosts(['example.com' => [['type' => 'MX']]]);
        $this->assertTrue(DnsMock::checkdnsrr('example.com'));

        DnsMock::withMockedHosts(['example.com' => [['type' => 'A']]]);
        $this->assertFalse(DnsMock::checkdnsrr('example.com'));
        $this->assertTrue(DnsMock::checkdnsrr('example.com', 'a'));
        $this->assertTrue(DnsMock::checkdnsrr('example.com', 'any'));
        
Home | Imprint | This part of the site doesn't use cookies.