Aude has uploaded a new change for review. https://gerrit.wikimedia.org/r/215077
Change subject: Add tests for HttpError ...................................................................... Add tests for HttpError Still missing tests for HttpError::report, but would have caught the issue that Ie216d19 fixed. Change-Id: Ic35d70af52c3a2d2a25fc3b9952383198db31fb1 --- A tests/phpunit/includes/exception/HttpErrorTest.php 1 file changed, 66 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/77/215077/1 diff --git a/tests/phpunit/includes/exception/HttpErrorTest.php b/tests/phpunit/includes/exception/HttpErrorTest.php new file mode 100644 index 0000000..4550316 --- /dev/null +++ b/tests/phpunit/includes/exception/HttpErrorTest.php @@ -0,0 +1,66 @@ +<?php + +/** + * @todo tests for HttpError::report + * + * @covers HttpError + */ +class HttpErrorTest extends MediaWikiLangTestCase { + + public function testIsLoggable() { + $httpError = new HttpError( 500, 'server error!' ); + $this->assertFalse( $httpError->isLoggable(), 'http error is not loggable' ); + } + + public function testGetStatusCode() { + $httpError = new HttpError( 500, 'server error!' ); + $this->assertEquals( 500, $httpError->getStatusCode() ); + } + + /** + * @dataProvider getHtmlProvider + */ + public function testGetHtml( $expected, $content, $header ) { + $httpError = new HttpError( 500, $content, $header ); + $errorHtml = $httpError->getHtml(); + + foreach( $expected as $key => $html ) { + $this->assertContains( $html, $errorHtml, $key ); + } + } + + public function getHtmlProvider() { + return array( + array( + array( + 'head html' => '<head><title>Server Error 123</title></head>', + 'body html' => '<body><h1>Server Error 123</h1>' + . '<p>a server error!</p></body>' + ), + 'a server error!', + 'Server Error 123' + ), + array( + array( + 'head html' => '<head><title>Login error</title></head>', + 'body html' => '<body><h1>Login error</h1>' + . '<p>Your request to log out was denied because it looks ' + . 'like it was sent by a broken browser or caching proxy.</p></body>' + ), + new Message( 'suspicious-userlogout' ), + new Message( 'loginerror' ) + ), + array( + array( + 'head html' => '<html><head><title>Internal Server Error</title></head>', + 'body html' => '<body><h1>Internal Server Error</h1>' + . '<p>a server error!</p></body></html>' + ), + 'a server error!', + null + ) + ); + } + + +} -- To view, visit https://gerrit.wikimedia.org/r/215077 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic35d70af52c3a2d2a25fc3b9952383198db31fb1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aude <aude.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits