PageLangLogFormatterTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @covers PageLangLogFormatter
  4. */
  5. class PageLangLogFormatterTest extends LogFormatterTestCase {
  6. protected function setUp() {
  7. parent::setUp();
  8. // Disable cldr extension
  9. $this->setMwGlobals( 'wgHooks', [] );
  10. // Register LogHandler, see $wgPageLanguageUseDB in Setup.php
  11. $this->mergeMwGlobalArrayValue( 'wgLogActionsHandlers', [
  12. 'pagelang/pagelang' => PageLangLogFormatter::class,
  13. ] );
  14. }
  15. /**
  16. * Provide different rows from the logging table to test
  17. * for backward compatibility.
  18. * Do not change the existing data, just add a new database row
  19. */
  20. public static function providePageLangLogDatabaseRows() {
  21. return [
  22. // Current format
  23. [
  24. [
  25. 'type' => 'pagelang',
  26. 'action' => 'pagelang',
  27. 'comment' => 'page lang comment',
  28. 'namespace' => NS_MAIN,
  29. 'title' => 'Page',
  30. 'params' => [
  31. '4::oldlanguage' => 'en',
  32. '5::newlanguage' => 'de[def]',
  33. ],
  34. ],
  35. [
  36. 'text' => 'User changed the language of Page from English (en) to Deutsch (de) [default]',
  37. 'api' => [
  38. 'oldlanguage' => 'en',
  39. 'newlanguage' => 'de[def]'
  40. ],
  41. ],
  42. ],
  43. ];
  44. }
  45. /**
  46. * @dataProvider providePageLangLogDatabaseRows
  47. */
  48. public function testPageLangLogDatabaseRows( $row, $extra ) {
  49. $this->doTestLogFormatter( $row, $extra );
  50. }
  51. }