ArticleTablesTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * @group Database
  4. */
  5. class ArticleTablesTest extends MediaWikiLangTestCase {
  6. /**
  7. * Make sure that T16404 doesn't strike again. We don't want
  8. * templatelinks based on the user language when {{int:}} is used, only the
  9. * content language.
  10. *
  11. * @covers Title::getTemplateLinksFrom
  12. * @covers Title::getLinksFrom
  13. */
  14. public function testTemplatelinksUsesContentLanguage() {
  15. $title = Title::newFromText( 'T16404' );
  16. $page = WikiPage::factory( $title );
  17. $user = new User();
  18. $user->mRights = [ 'createpage', 'edit', 'purge' ];
  19. $this->setContentLang( 'es' );
  20. $this->setUserLang( 'fr' );
  21. $page->doEditContent(
  22. new WikitextContent( '{{:{{int:history}}}}' ),
  23. 'Test code for T16404',
  24. 0,
  25. false,
  26. $user
  27. );
  28. $templates1 = $title->getTemplateLinksFrom();
  29. $this->setUserLang( 'de' );
  30. $page = WikiPage::factory( $title ); // In order to force the re-rendering of the same wikitext
  31. // We need an edit, a purge is not enough to regenerate the tables
  32. $page->doEditContent(
  33. new WikitextContent( '{{:{{int:history}}}}' ),
  34. 'Test code for T16404',
  35. EDIT_UPDATE,
  36. false,
  37. $user
  38. );
  39. $templates2 = $title->getTemplateLinksFrom();
  40. /**
  41. * @var Title[] $templates1
  42. * @var Title[] $templates2
  43. */
  44. $this->assertEquals( $templates1, $templates2 );
  45. $this->assertEquals( $templates1[0]->getFullText(), 'Historial' );
  46. }
  47. }