Skip to content

Commit

Permalink
Accept DNS ResolverInterface and fix failing test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Jul 18, 2019
1 parent e4c5bf8 commit 7db9e97
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -17,7 +17,7 @@
"php": ">=5.3",
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
"react/dns": "^1.0 || ^0.4.13",
"react/dns": "^1.1",
"react/promise": "~2.1|~1.2"
},
"require-dev": {
Expand Down
10 changes: 5 additions & 5 deletions src/Factory.php
Expand Up @@ -3,9 +3,9 @@
namespace React\Datagram;

use React\Datagram\Socket;
use React\Dns\Config\Config;
use React\Dns\Config\Config as DnsConfig;
use React\Dns\Resolver\Factory as DnsFactory;
use React\Dns\Resolver\Resolver;
use React\Dns\Resolver\ResolverInterface;
use React\EventLoop\LoopInterface;
use React\Promise;
use React\Promise\CancellablePromiseInterface;
Expand All @@ -19,15 +19,15 @@ class Factory
/**
*
* @param LoopInterface $loop
* @param Resolver|null $resolver Resolver instance to use. Will otherwise
* @param ?ResolverInterface $resolver Resolver instance to use. Will otherwise
* try to load the system default DNS config or fall back to using
* Google's public DNS 8.8.8.8
*/
public function __construct(LoopInterface $loop, Resolver $resolver = null)
public function __construct(LoopInterface $loop, ResolverInterface $resolver = null)
{
if ($resolver === null) {
// try to load nameservers from system config or default to Google's public DNS
$config = Config::loadSystemConfigBlocking();
$config = DnsConfig::loadSystemConfigBlocking();
$server = $config->nameservers ? \reset($config->nameservers) : '8.8.8.8';

$factory = new DnsFactory();
Expand Down
1 change: 1 addition & 0 deletions tests/SocketTest.php
Expand Up @@ -5,6 +5,7 @@

class SocketTest extends TestCase
{
private $loop;
private $factory;

public function setUp()
Expand Down
4 changes: 1 addition & 3 deletions tests/bootstrap.php
Expand Up @@ -31,9 +31,7 @@ protected function createCallableMock()

protected function createResolverMock()
{
return $this->getMockBuilder('React\Dns\Resolver\Resolver')
->disableOriginalConstructor()
->getMock();
return $this->getMockBuilder('React\Dns\Resolver\ResolverInterface')->getMock();
}
}

Expand Down

0 comments on commit 7db9e97

Please sign in to comment.