From: jenkins-bot Date: Fri, 18 Nov 2016 21:14:47 +0000 (+0000) Subject: Merge "Add 'tests' testsuite" X-Git-Tag: 1.31.0-rc.0~4818 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=b330e5a736aa389a4babaceffa1116c879e49f1a;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "Add 'tests' testsuite" --- b330e5a736aa389a4babaceffa1116c879e49f1a diff --combined tests/phpunit/tests/MediaWikiTestCaseTest.php index fc075bbdc5,c005fe2c77..a2ef35fa26 --- a/tests/phpunit/tests/MediaWikiTestCaseTest.php +++ b/tests/phpunit/tests/MediaWikiTestCaseTest.php @@@ -90,22 -90,14 +90,22 @@@ class MediaWikiTestCaseTest extends Med /** * @covers MediaWikiTestCase::stashMwGlobals + * @covers MediaWikiTestCase::tearDown */ - public function testExceptionThrownWhenStashingNonExistentGlobals() { - $this->setExpectedException( - 'Exception', - 'Global with key ' . self::GLOBAL_KEY_NONEXISTING . ' doesn\'t exist and cant be stashed' + public function testSetNonExistentGlobalsAreUnsetOnTearDown() { + $globalKey = 'abcdefg1234567'; + $this->setMwGlobals( $globalKey, true ); + $this->assertTrue( + $GLOBALS[$globalKey], + 'Global failed to correctly set' ); - $this->stashMwGlobals( self::GLOBAL_KEY_NONEXISTING ); + $this->tearDown(); + + $this->assertFalse( + isset( $GLOBALS[$globalKey] ), + 'Global failed to be correctly unset' + ); } public function testOverrideMwServices() { @@@ -142,8 -134,7 +142,7 @@@ * @covers MediaWikiTestCase::setLogger * @covers MediaWikiTestCase::restoreLogger */ - public function testLoggersAreRestoredOnTearDown() { - // replacing an existing logger + public function testLoggersAreRestoredOnTearDown_replacingExistingLogger() { $logger1 = LoggerFactory::getInstance( 'foo' ); $this->setLogger( 'foo', $this->getMock( LoggerInterface::class ) ); $logger2 = LoggerFactory::getInstance( 'foo' ); @@@ -152,17 -143,27 +151,27 @@@ $this->assertSame( $logger1, $logger3 ); $this->assertNotSame( $logger1, $logger2 ); + } - // replacing a non-existing logger + /** + * @covers MediaWikiTestCase::setLogger + * @covers MediaWikiTestCase::restoreLogger + */ + public function testLoggersAreRestoredOnTearDown_replacingNonExistingLogger() { $this->setLogger( 'foo', $this->getMock( LoggerInterface::class ) ); - $logger1 = LoggerFactory::getInstance( 'bar' ); + $logger1 = LoggerFactory::getInstance( 'foo' ); $this->tearDown(); - $logger2 = LoggerFactory::getInstance( 'bar' ); + $logger2 = LoggerFactory::getInstance( 'foo' ); $this->assertNotSame( $logger1, $logger2 ); $this->assertInstanceOf( '\Psr\Log\LoggerInterface', $logger2 ); + } - // replacing same logger twice + /** + * @covers MediaWikiTestCase::setLogger + * @covers MediaWikiTestCase::restoreLogger + */ + public function testLoggersAreRestoredOnTearDown_replacingSameLoggerTwice() { $logger1 = LoggerFactory::getInstance( 'baz' ); $this->setLogger( 'foo', $this->getMock( LoggerInterface::class ) ); $this->setLogger( 'foo', $this->getMock( LoggerInterface::class ) );