Merge "Fix sessionfailure i18n message during authentication"
[lhc/web/wiklou.git] / tests / phpunit / includes / ListToggleTest.php
1 <?php
2
3 /**
4 * @covers ListToggle
5 */
6 class ListToggleTest extends MediaWikiTestCase {
7
8 /**
9 * @covers ListToggle::__construct
10 */
11 public function testConstruct() {
12 $output = $this->getMockBuilder( OutputPage::class )
13 ->setMethods( null )
14 ->disableOriginalConstructor()
15 ->getMock();
16
17 $listToggle = new ListToggle( $output );
18
19 $this->assertInstanceOf( ListToggle::class, $listToggle );
20 $this->assertContains( 'mediawiki.checkboxtoggle', $output->getModules() );
21 $this->assertContains( 'mediawiki.checkboxtoggle.styles', $output->getModuleStyles() );
22 }
23
24 /**
25 * @covers ListToggle::getHTML
26 */
27 public function testGetHTML() {
28 $output = $this->createMock( OutputPage::class );
29 $output->expects( $this->any() )
30 ->method( 'msg' )
31 ->will( $this->returnCallback( function ( $key ) {
32 return wfMessage( $key )->inLanguage( 'qqx' );
33 } ) );
34 $output->expects( $this->once() )
35 ->method( 'getLanguage' )
36 ->will( $this->returnValue( Language::factory( 'qqx' ) ) );
37
38 $listToggle = new ListToggle( $output );
39
40 $html = $listToggle->getHTML();
41 $this->assertEquals( '<div class="mw-checkbox-toggle-controls">' .
42 '(checkbox-select: <a class="mw-checkbox-all" role="button"' .
43 ' tabindex="0">(checkbox-all)</a>(comma-separator)' .
44 '<a class="mw-checkbox-none" role="button" tabindex="0">' .
45 '(checkbox-none)</a>(comma-separator)<a class="mw-checkbox-invert" ' .
46 'role="button" tabindex="0">(checkbox-invert)</a>)</div>',
47 $html );
48 }
49 }