From 31045933a1f02369030d4f3d2dfc922a2eeb6a56 Mon Sep 17 00:00:00 2001 From: ryan10145 Date: Wed, 3 Jan 2018 21:41:02 -0500 Subject: [PATCH] Added Tests for ListToggle Bug: T183898 Change-Id: I1c6cd8ea21127db56701cc6073fa880b2180d846 --- tests/phpunit/includes/ListToggleTest.php | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/phpunit/includes/ListToggleTest.php diff --git a/tests/phpunit/includes/ListToggleTest.php b/tests/phpunit/includes/ListToggleTest.php new file mode 100644 index 0000000000..7bbf448191 --- /dev/null +++ b/tests/phpunit/includes/ListToggleTest.php @@ -0,0 +1,49 @@ +getMockBuilder( 'OutputPage' ) + ->setMethods( null ) + ->disableOriginalConstructor() + ->getMock(); + + $listToggle = new ListToggle( $output ); + + $this->assertInstanceOf( 'ListToggle', $listToggle ); + $this->assertContains( 'mediawiki.checkboxtoggle', $output->getModules() ); + $this->assertContains( 'mediawiki.checkboxtoggle.styles', $output->getModuleStyles() ); + } + + /** + * @covers ListToggle::getHTML + */ + public function testGetHTML() { + $output = $this->createMock( 'OutputPage' ); + $output->expects( $this->any() ) + ->method( 'msg' ) + ->will( $this->returnCallback( function ( $key ) { + return wfMessage( $key )->inLanguage( 'qqx' ); + } ) ); + $output->expects( $this->once() ) + ->method( 'getLanguage' ) + ->will( $this->returnValue( Language::factory( 'qqx' ) ) ); + + $listToggle = new ListToggle( $output ); + + $html = $listToggle->getHTML(); + $this->assertEquals( '
' . + '(checkbox-select: (checkbox-all)(comma-separator)' . + '' . + '(checkbox-none)(comma-separator)(checkbox-invert))
', + $html ); + } +} -- 2.20.1