Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/115608
Change subject: Expand MWException tests
......................................................................
Expand MWException tests
Change-Id: Ia6d579eff66c949f6d4318d09afb143ed78f3ac1
---
M tests/phpunit/includes/exception/MWExceptionTest.php
1 file changed, 102 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/08/115608/1
diff --git a/tests/phpunit/includes/exception/MWExceptionTest.php
b/tests/phpunit/includes/exception/MWExceptionTest.php
index f1ddc17..c2e3db3 100644
--- a/tests/phpunit/includes/exception/MWExceptionTest.php
+++ b/tests/phpunit/includes/exception/MWExceptionTest.php
@@ -16,6 +16,108 @@
}
/**
+ * @dataProvider provideTextUseOutputPage
+ * @covers MWException::useOutputPage
+ */
+ public function testUseOutputPage( $expected, $wgLang,
$wgFullyInitialised, $wgOut ) {
+ $this->setMwGlobals( array(
+ 'wgLang' => $wgLang,
+ 'wgFullyInitialised' => $wgFullyInitialised,
+ 'wgOut' => $wgOut,
+ ) );
+
+ $e = new MWException();
+ $this->assertEquals( $expected, $e->useOutputPage() );
+ }
+
+ public function provideTextUseOutputPage() {
+ return array(
+ // expected, wgLang, wgFullyInitialised, wgOut
+ array( false, null, null, null ),
+ array( false, $this->getMockLanguage(), null, null ),
+ array( false, $this->getMockLanguage(), true, null ),
+ array( false, null, true, null ),
+ array( false, null, null, true ),
+ array( true, $this->getMockLanguage(), true, true ),
+ );
+ }
+
+ private function getMockLanguage() {
+ return $this->getMockBuilder( 'Language' )
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
+ /**
+ * @dataProvider provideUseMessageCache
+ * @covers MWException::useMessageCache
+ */
+ public function testUseMessageCache( $expected, $wgLang ) {
+ $this->setMwGlobals( array(
+ 'wgLang' => $wgLang,
+ ) );
+ $e = new MWException();
+ $this->assertEquals( $expected, $e->useMessageCache() );
+ }
+
+ public function provideUseMessageCache() {
+ return array(
+ array( false, null ),
+ array( true, $this->getMockLanguage() ),
+ );
+ }
+
+ /**
+ * @covers MWException::isLoggable
+ */
+ public function testIsLogable() {
+ $e = new MWException();
+ $this->assertTrue( $e->isLoggable() );
+ }
+
+ /**
+ * @dataProvider provideRunHooks
+ * @covers MWException::runHooks
+ */
+ public function testRunHooks( $wgExceptionHooks, $name, $args,
$expectedReturn ) {
+ $this->setMwGlobals( array(
+ 'wgExceptionHooks' => $wgExceptionHooks,
+ ) );
+ $e = new MWException();
+ $this->assertEquals( $expectedReturn, $e->runHooks( $name,
$args ) );
+ }
+
+ /**
+ * @todo test that hooks are actually called correctly
+ */
+ public function provideRunHooks() {
+ return array(
+ array( null, null, null, null ),
+ array( array(), 'name', array(), null ),
+ array( array( 'name' => false ), 'name', array(), null
),
+ );
+ }
+
+ /**
+ * @dataProvider provideIsCommandLine
+ * @covers MWException::isCommandLine
+ */
+ public function testisCommandLine( $expected, $wgCommandLineMode ) {
+ $this->setMwGlobals( array(
+ 'wgCommandLineMode' => $wgCommandLineMode,
+ ) );
+ $e = new MWException();
+ $this->assertEquals( $expected, $e->isCommandLine() );
+ }
+
+ public function provideIsCommandLine() {
+ return array(
+ array( false, null ),
+ array( true, true ),
+ );
+ }
+
+ /**
* Verify the exception classes are JSON serializabe.
*
* @covers MWExceptionHandler::jsonSerializeException
--
To view, visit https://gerrit.wikimedia.org/r/115608
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia6d579eff66c949f6d4318d09afb143ed78f3ac1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits