Skip to content

Commit 5682685

Browse files
committed
Switch around $method and $loop in the DohExecutor constructor, $method is more likely to be set than $loop
1 parent 6005dcc commit 5682685

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/DohExecutor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class DohExecutor implements ExecutorInterface {
4343

4444
/**
4545
* @param string $nameserver
46-
* @param ?LoopInterface $loop
4746
* @param string $method
47+
* @param ?LoopInterface $loop
4848
*/
49-
public function __construct(string $nameserver, LoopInterface $loop = null, string $method = self::METHOD_GET)
49+
public function __construct(string $nameserver, string $method = self::METHOD_GET, LoopInterface $loop = null)
5050
{
5151
if (!class_exists('\React\Http\Browser')) {
5252
throw new RuntimeException('DNS over HTTPS support requires reactphp/http library'); //@codeCoverageIgnore

tests/FunctionalTests.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class FunctionalTests extends TestCase
1515
{
1616
public function testResolveCloudflareViaPostResolves()
1717
{
18-
$executor = new DohExecutor('https://1.1.1.1/dns-query', null,DohExecutor::METHOD_POST);
18+
$executor = new DohExecutor('https://1.1.1.1/dns-query', DohExecutor::METHOD_POST);
1919
$query = new Query('one.one.one.one', Message::TYPE_A, Message::CLASS_IN);
2020
$promise = $executor->query($query);
2121

@@ -32,7 +32,7 @@ public function testResolveCloudflareViaPostResolves()
3232

3333
public function testResolveCloudflareViaGetResolves()
3434
{
35-
$executor = new DohExecutor('https://1.1.1.1/dns-query', null,DohExecutor::METHOD_GET);
35+
$executor = new DohExecutor('https://1.1.1.1/dns-query',DohExecutor::METHOD_GET);
3636
$query = new Query('one.one.one.one', Message::TYPE_A, Message::CLASS_IN);
3737
$promise = $executor->query($query);
3838

@@ -49,7 +49,7 @@ public function testResolveCloudflareViaGetResolves()
4949

5050
public function testResolveCloudflareHostnameViaGetResolves()
5151
{
52-
$executor = new DohExecutor('https://one.one.one.one/dns-query', null,DohExecutor::METHOD_GET);
52+
$executor = new DohExecutor('https://one.one.one.one/dns-query',DohExecutor::METHOD_GET);
5353
$query = new Query('one.one.one.one', Message::TYPE_A, Message::CLASS_IN);
5454
$promise = $executor->query($query);
5555

@@ -66,7 +66,7 @@ public function testResolveCloudflareHostnameViaGetResolves()
6666

6767
public function testResolveSecondQueryReusesConnection()
6868
{
69-
$executor = new DohExecutor('https://one.one.one.one/dns-query', null,DohExecutor::METHOD_GET);
69+
$executor = new DohExecutor('https://one.one.one.one/dns-query');
7070
$query = new Query('one.one.one.one', Message::TYPE_A, Message::CLASS_IN);
7171
$promise1 = $executor->query($query);
7272
$promise2 = $executor->query($query);
@@ -88,7 +88,7 @@ public function testResolveSecondQueryReusesConnection()
8888

8989
public function testResolveGoogleViaIPv6HostResolves()
9090
{
91-
$executor = new DohExecutor('https://dns64.dns.google/dns-query', null,DohExecutor::METHOD_GET);
91+
$executor = new DohExecutor('https://dns64.dns.google/dns-query');
9292
$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);
9393
$promise = $executor->query($query);
9494

@@ -105,7 +105,7 @@ public function testResolveGoogleViaIPv6HostResolves()
105105

106106
public function testResolveGoogleViaIPv6IpResolves()
107107
{
108-
$executor = new DohExecutor('https://[2001:4860:4860::8888]/dns-query', null,DohExecutor::METHOD_GET);
108+
$executor = new DohExecutor('https://[2001:4860:4860::8888]/dns-query');
109109
$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);
110110
$promise = $executor->query($query);
111111

@@ -167,6 +167,8 @@ public function testQueryRejectsIfMessageExceedsMaximumMessageSize()
167167
$exception = $reason;
168168
});
169169

170+
Loop::run();
171+
170172
/** @var \RuntimeException $exception */
171173
$this->assertInstanceOf('RuntimeException', $exception);
172174
$this->assertStringStartsWith('DNS query for '. $query->name . ' (A) failed: Query too large for HTTPS transport', $exception->getMessage());
@@ -176,7 +178,7 @@ public function testResolveViaInvalidHttpMethodThrows()
176178
{
177179
$this->expectException(\InvalidArgumentException::class);
178180

179-
new DohExecutor('https://1.1.1.1/dns-query', null, 'put');
181+
new DohExecutor('https://1.1.1.1/dns-query', 'put');
180182
}
181183

182184
public function testInvalidNameserverThrows()

0 commit comments

Comments
 (0)