PageArchivePreMcrTest.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. use MediaWiki\MediaWikiServices;
  3. use MediaWiki\Storage\SqlBlobStore;
  4. use MediaWiki\Tests\Storage\PreMcrSchemaOverride;
  5. /**
  6. * Test class for page archiving, using the pre-MCR schema.
  7. *
  8. * @group ContentHandler
  9. * @group Database
  10. * ^--- important, causes temporary tables to be used instead of the real database
  11. *
  12. * @group medium
  13. * ^--- important, causes tests not to fail with timeout
  14. */
  15. class PageArchivePreMcrTest extends PageArchiveTestBase {
  16. use PreMcrSchemaOverride;
  17. /**
  18. * @covers PageArchive::getTextFromRow
  19. */
  20. public function testGetTextFromRow() {
  21. $this->hideDeprecated( PageArchive::class . '::getTextFromRow' );
  22. /** @var SqlBlobStore $blobStore */
  23. $blobStore = MediaWikiServices::getInstance()->getBlobStore();
  24. $textId = $blobStore->getTextIdFromAddress(
  25. $this->firstRev->getSlot( 'main' )->getAddress()
  26. );
  27. $row = (object)[ 'ar_text_id' => $textId ];
  28. $text = $this->archivedPage->getTextFromRow( $row );
  29. $this->assertSame( 'testing', $text );
  30. }
  31. protected function getExpectedArchiveRows() {
  32. /** @var SqlBlobStore $blobStore */
  33. $blobStore = MediaWikiServices::getInstance()->getBlobStore();
  34. return [
  35. [
  36. 'ar_minor_edit' => '0',
  37. 'ar_user' => '0',
  38. 'ar_user_text' => $this->ipEditor,
  39. 'ar_actor' => null,
  40. 'ar_len' => '11',
  41. 'ar_deleted' => '0',
  42. 'ar_rev_id' => strval( $this->ipRev->getId() ),
  43. 'ar_timestamp' => $this->db->timestamp( $this->ipRev->getTimestamp() ),
  44. 'ar_sha1' => '0qdrpxl537ivfnx4gcpnzz0285yxryy',
  45. 'ar_page_id' => strval( $this->ipRev->getPageId() ),
  46. 'ar_comment_text' => 'just a test',
  47. 'ar_comment_data' => null,
  48. 'ar_comment_cid' => null,
  49. 'ar_content_format' => null,
  50. 'ar_content_model' => null,
  51. 'ts_tags' => null,
  52. 'ar_id' => '2',
  53. 'ar_namespace' => '0',
  54. 'ar_title' => 'PageArchiveTest_thePage',
  55. 'ar_text_id' => (string)$blobStore->getTextIdFromAddress(
  56. $this->ipRev->getSlot( 'main' )->getAddress()
  57. ),
  58. 'ar_parent_id' => strval( $this->ipRev->getParentId() ),
  59. ],
  60. [
  61. 'ar_minor_edit' => '0',
  62. 'ar_user' => (string)$this->getTestUser()->getUser()->getId(),
  63. 'ar_user_text' => $this->getTestUser()->getUser()->getName(),
  64. 'ar_actor' => null,
  65. 'ar_len' => '7',
  66. 'ar_deleted' => '0',
  67. 'ar_rev_id' => strval( $this->firstRev->getId() ),
  68. 'ar_timestamp' => $this->db->timestamp( $this->firstRev->getTimestamp() ),
  69. 'ar_sha1' => 'pr0s8e18148pxhgjfa0gjrvpy8fiyxc',
  70. 'ar_page_id' => strval( $this->firstRev->getPageId() ),
  71. 'ar_comment_text' => 'testing',
  72. 'ar_comment_data' => null,
  73. 'ar_comment_cid' => null,
  74. 'ar_content_format' => null,
  75. 'ar_content_model' => null,
  76. 'ts_tags' => null,
  77. 'ar_id' => '1',
  78. 'ar_namespace' => '0',
  79. 'ar_title' => 'PageArchiveTest_thePage',
  80. 'ar_text_id' => (string)$blobStore->getTextIdFromAddress(
  81. $this->firstRev->getSlot( 'main' )->getAddress()
  82. ),
  83. 'ar_parent_id' => '0',
  84. ],
  85. ];
  86. }
  87. }