X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FFauxRequestTest.php;h=7b7f6b9d4361f0551db871403354d3534282324a;hb=9e8439e79d67788916d488f645108f79016d9aca;hp=9e7d68026841f81cc7640078493d410e71b87c0c;hpb=8519b66979096124a4a6e1720937a501d720fd5b;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/FauxRequestTest.php b/tests/phpunit/includes/FauxRequestTest.php index 9e7d680268..7b7f6b9d43 100644 --- a/tests/phpunit/includes/FauxRequestTest.php +++ b/tests/phpunit/includes/FauxRequestTest.php @@ -7,6 +7,16 @@ 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 */ @@ -40,7 +50,7 @@ class FauxRequestTest extends PHPUnit\Framework\TestCase { public function testGetText() { $req = new FauxRequest( [ 'x' => 'Value' ] ); $this->assertEquals( 'Value', $req->getText( 'x' ) ); - $this->assertEquals( '', $req->getText( 'z' ) ); + $this->assertSame( '', $req->getText( 'z' ) ); } /** @@ -148,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(); @@ -164,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 @@ -238,8 +287,8 @@ class FauxRequestTest extends PHPUnit\Framework\TestCase { */ public function testDummies() { $req = new FauxRequest(); - $this->assertEquals( '', $req->getRawQueryString() ); - $this->assertEquals( '', $req->getRawPostString() ); - $this->assertEquals( '', $req->getRawInput() ); + $this->assertSame( '', $req->getRawQueryString() ); + $this->assertSame( '', $req->getRawPostString() ); + $this->assertSame( '', $req->getRawInput() ); } }