Skip to content

Commit cefe2c8

Browse files
author
Denis Smetannikov
committed
Fixes tests
1 parent dc88a79 commit cefe2c8

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

tests/AbstractDriverTest.php

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ public function testAllMethods()
103103
isSame($method, $body->find('method'), $message);
104104

105105
if ($method === 'GET') {
106-
isContain(Url::addArg($args, $url), $body->find('url'), $message);
106+
$this->isSameUrl(Url::addArg($args, $url), $body->find('url'), $message);
107107
isSame($uniq, $body->find('queryString.qwerty'), $message);
108108
} else {
109-
isContain($url, $body->find('url'), $message);
109+
$this->isContainUrl($url, $body->find('url'), $message);
110110
if ($this->driver === 'Rmccue' && $method === 'DELETE') {
111111
skip('DELETE is not supported with Rmccue/Requests correctly');
112112
}
@@ -140,7 +140,7 @@ public function testGetQueryString()
140140
isContain('application/json', $result->getHeader('Content-Type'));
141141

142142
$body = $result->getJSON();
143-
isSame(Url::addArg($args, $url), $body->find('url'));
143+
$this->isSameUrl(Url::addArg($args, $url), $body->find('url'));
144144
isSame($uniq, $body->find('args.qwerty'));
145145
isSame('value', $body->find('args.key'));
146146
}
@@ -166,7 +166,7 @@ public function testPost()
166166

167167
isSame(200, $result->code);
168168
isContain('application/json', $result->find('headers.content-type'));
169-
isContain('httpbin.org/post?key=value', $body->find('url'));
169+
$this->isSameUrl('//httpbin.org/post?key=value', $body->find('url'));
170170
isSame($uniq, $body->find('form.qwerty'));
171171
isSame('value', $body->find('args.key'));
172172
}
@@ -246,7 +246,7 @@ public function testMultiRedirects()
246246
$body = $result->getJSON();
247247

248248
isSame(200, $result->code);
249-
isSame('http://httpbin.org/get', $body->get('url'));
249+
$this->isSameUrl('http://httpbin.org/get', $body->get('url'));
250250
}
251251

252252
public function testDelayError()
@@ -278,7 +278,7 @@ public function testDelay()
278278
$body = $result->getJSON();
279279

280280
isSame(200, $result->code);
281-
isSame($url, $body->get('url'));
281+
$this->isSameUrl($url, $body->get('url'));
282282
}
283283

284284
public function testSSL()
@@ -326,4 +326,33 @@ public function testMultiRequest()
326326
isSame('POST', $body2->find('method'));
327327
isSame('value', $body2->find('postData.params.key'));
328328
}
329+
330+
/**
331+
* @param string $expected
332+
* @param string $actual
333+
* @param string $message
334+
*/
335+
private function isSameUrl(string $expected, string $actual, string $message = '')
336+
{
337+
isSame(
338+
str_replace(['https://', 'http://'], '//', $expected),
339+
str_replace(['https://', 'http://'], '//', $actual),
340+
$message
341+
);
342+
}
343+
344+
/**
345+
* @param string $expected
346+
* @param string $actual
347+
* @param string $message
348+
*/
349+
private function isContainUrl(string $expected, string $actual, string $message = '')
350+
{
351+
isContain(
352+
str_replace(['https://', 'http://'], '//', $expected),
353+
str_replace(['https://', 'http://'], '//', $actual),
354+
false,
355+
$message
356+
);
357+
}
329358
}

0 commit comments

Comments
 (0)