Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 9c1f4b7

Browse files
committed
add test for isAbsolute() check set port
1 parent 33502cf commit 9c1f4b7

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

test/ClientTest.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,21 +540,40 @@ public function testValidRelativeURI($uri, $isValidRelativeURI)
540540
{
541541
$client = new Client($uri);
542542
$this->assertSame($isValidRelativeURI, $client->getUri()->isValidRelative());
543+
544+
$client->setAdapter(Test::class);
545+
$client->send();
546+
$this->assertSame($isValidRelativeURI, $client->getUri()->isValidRelative());
543547
}
544548

545-
public function testSendRequestWithRelativeURI()
549+
public function portChangeDataProvider()
546550
{
547-
$client = new Client('/example');
551+
return [
552+
['https://localhost/example', 443],
553+
['http://localhost/example', 80]
554+
];
555+
}
556+
557+
/**
558+
* @dataProvider portChangeDataProvider
559+
*/
560+
public function testAbsoluteSetPort443OnHttps($absoluteURI, $port)
561+
{
562+
$client = new Client($absoluteURI);
563+
$this->assertSame($port, $client->getUri()->getPort());
564+
548565
$client->setAdapter(Test::class);
549566
$client->send();
550-
$this->assertTrue($client->getUri()->isValidRelative());
567+
$this->assertSame($port, $client->getUri()->getPort());
551568
}
552569

553-
public function testSendRequestWithAbsoluteURI()
570+
public function testRelativeURIDoesnotSetPort()
554571
{
555-
$client = new Client('http://localhost/example');
572+
$client = new Client('/example');
573+
$this->assertSame(null, $client->getUri()->getPort());
574+
556575
$client->setAdapter(Test::class);
557576
$client->send();
558-
$this->assertFalse($client->getUri()->isValidRelative());
577+
$this->assertSame(null, $client->getUri()->getPort());
559578
}
560579
}

0 commit comments

Comments
 (0)