diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/tests/phpunit/includes/exception/ErrorPageErrorTest.php |
first commit
Diffstat (limited to 'www/wiki/tests/phpunit/includes/exception/ErrorPageErrorTest.php')
-rw-r--r-- | www/wiki/tests/phpunit/includes/exception/ErrorPageErrorTest.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/www/wiki/tests/phpunit/includes/exception/ErrorPageErrorTest.php b/www/wiki/tests/phpunit/includes/exception/ErrorPageErrorTest.php new file mode 100644 index 00000000..49d454e8 --- /dev/null +++ b/www/wiki/tests/phpunit/includes/exception/ErrorPageErrorTest.php @@ -0,0 +1,52 @@ +<?php + +/** + * @covers ErrorPageError + * @author Addshore + */ +class ErrorPageErrorTest extends MediaWikiTestCase { + + private function getMockMessage() { + $mockMessage = $this->getMockBuilder( Message::class ) + ->disableOriginalConstructor() + ->getMock(); + $mockMessage->expects( $this->once() ) + ->method( 'inLanguage' ) + ->will( $this->returnValue( $mockMessage ) ); + $mockMessage->expects( $this->once() ) + ->method( 'useDatabase' ) + ->will( $this->returnValue( $mockMessage ) ); + return $mockMessage; + } + + public function testConstruction() { + $mockMessage = $this->getMockMessage(); + $title = 'Foo'; + $params = [ 'Baz' ]; + $e = new ErrorPageError( $title, $mockMessage, $params ); + $this->assertEquals( $title, $e->title ); + $this->assertEquals( $mockMessage, $e->msg ); + $this->assertEquals( $params, $e->params ); + } + + public function testReport() { + $mockMessage = $this->getMockMessage(); + $title = 'Foo'; + $params = [ 'Baz' ]; + + $mock = $this->getMockBuilder( OutputPage::class ) + ->disableOriginalConstructor() + ->getMock(); + $mock->expects( $this->once() ) + ->method( 'showErrorPage' ) + ->with( $title, $mockMessage, $params ); + $mock->expects( $this->once() ) + ->method( 'output' ); + $this->setMwGlobals( 'wgOut', $mock ); + $this->setMwGlobals( 'wgCommandLineMode', false ); + + $e = new ErrorPageError( $title, $mockMessage, $params ); + $e->report(); + } + +} |