X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FFauxRequestTest.php;h=c054caa06f7f1926084ce957b90f2a1ad92cf576;hp=9f8bb385f25536dc11db1442117a94b5f5572673;hb=dfec83932fd38a9086eb5a2e212889ad00f35b0e;hpb=77e3624caba072521fbc1826af2d47f9b29f4032 diff --git a/tests/phpunit/includes/FauxRequestTest.php b/tests/phpunit/includes/FauxRequestTest.php index 9f8bb385f2..c054caa06f 100644 --- a/tests/phpunit/includes/FauxRequestTest.php +++ b/tests/phpunit/includes/FauxRequestTest.php @@ -5,6 +5,17 @@ use MediaWiki\Session\SessionManager; class FauxRequestTest extends PHPUnit\Framework\TestCase { use MediaWikiCoversValidator; + use PHPUnit4And6Compat; + + public function setUp() { + parent::setUp(); + $this->orgWgServer = $GLOBALS['wgServer']; + } + + public function tearDown() { + $GLOBALS['wgServer'] = $this->orgWgServer; + parent::tearDown(); + } /** * @covers FauxRequest::__construct @@ -147,7 +158,7 @@ class FauxRequestTest extends PHPUnit\Framework\TestCase { /** * @covers FauxRequest::getRequestURL */ - public function testGetRequestURL() { + public function testGetRequestURL_disallowed() { $req = new FauxRequest(); $this->setExpectedException( MWException::class ); $req->getRequestURL(); @@ -163,6 +174,45 @@ class FauxRequestTest extends PHPUnit\Framework\TestCase { $this->assertEquals( 'https://example.org', $req->getRequestURL() ); } + /** + * @covers FauxRequest::getFullRequestURL + */ + public function testGetFullRequestURL_disallowed() { + $GLOBALS['wgServer'] = '//wiki.test'; + $req = new FauxRequest(); + + $this->setExpectedException( MWException::class ); + $req->getFullRequestURL(); + } + + /** + * @covers FauxRequest::getFullRequestURL + */ + public function testGetFullRequestURL_http() { + $GLOBALS['wgServer'] = '//wiki.test'; + $req = new FauxRequest(); + $req->setRequestURL( '/path' ); + + $this->assertSame( + 'http://wiki.test/path', + $req->getFullRequestURL() + ); + } + + /** + * @covers FauxRequest::getFullRequestURL + */ + public function testGetFullRequestURL_https() { + $GLOBALS['wgServer'] = '//wiki.test'; + $req = new FauxRequest( [], false, null, 'https' ); + $req->setRequestURL( '/path' ); + + $this->assertSame( + 'https://wiki.test/path', + $req->getFullRequestURL() + ); + } + /** * @covers FauxRequest::__construct * @covers FauxRequest::getProtocol