ListToggleTest.php 1.5 KB

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