BlockCustomTranslationTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. namespace Drupal\Tests\block_content\Kernel\Plugin\migrate\source\d7;
  3. use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
  4. /**
  5. * Tests i18n custom block translations source plugin.
  6. *
  7. * @covers \Drupal\block_content\Plugin\migrate\source\d7\BlockCustomTranslation
  8. *
  9. * @group content_translation
  10. */
  11. class BlockCustomTranslationTest extends MigrateSqlSourceTestBase {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public static $modules = ['block_content', 'migrate_drupal'];
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public function providerSource() {
  20. $tests = [];
  21. // The source data.
  22. $tests[0]['database']['block_custom'] = [
  23. [
  24. 'bid' => 1,
  25. 'body' => 'box 1 body',
  26. 'info' => 'box 1 title',
  27. 'format' => '2',
  28. ],
  29. [
  30. 'bid' => 2,
  31. 'body' => 'box 2 body',
  32. 'info' => 'box 2 title',
  33. 'format' => '2',
  34. ],
  35. ];
  36. $tests[0]['database']['i18n_string'] = [
  37. [
  38. 'lid' => 1,
  39. 'objectid' => 1,
  40. 'type' => 'block',
  41. 'property' => 'title',
  42. 'objectindex' => 1,
  43. 'format' => 0,
  44. ],
  45. [
  46. 'lid' => 2,
  47. 'objectid' => 1,
  48. 'type' => 'block',
  49. 'property' => 'body',
  50. 'objectindex' => 1,
  51. 'format' => 0,
  52. ],
  53. [
  54. 'lid' => 3,
  55. 'objectid' => 2,
  56. 'type' => 'block',
  57. 'property' => 'body',
  58. 'objectindex' => 2,
  59. 'format' => 2,
  60. ],
  61. ];
  62. $tests[0]['database']['locales_target'] = [
  63. [
  64. 'lid' => 1,
  65. 'language' => 'fr',
  66. 'translation' => 'fr - title translation',
  67. 'plid' => 0,
  68. 'plural' => 0,
  69. 'i18n_status' => 0,
  70. ],
  71. [
  72. 'lid' => 2,
  73. 'language' => 'fr',
  74. 'translation' => 'fr - body translation',
  75. 'plid' => 0,
  76. 'plural' => 0,
  77. 'i18n_status' => 0,
  78. ],
  79. [
  80. 'lid' => 3,
  81. 'language' => 'zu',
  82. 'translation' => 'zu - body translation',
  83. 'plid' => 0,
  84. 'plural' => 0,
  85. 'i18n_status' => 0,
  86. ],
  87. ];
  88. $tests[0]['database']['system'] = [
  89. [
  90. 'type' => 'module',
  91. 'name' => 'system',
  92. 'schema_version' => '7001',
  93. 'status' => '1',
  94. ],
  95. ];
  96. $tests[0]['expected_results'] = [
  97. [
  98. 'lid' => '1',
  99. 'property' => 'title',
  100. 'language' => 'fr',
  101. 'translation' => 'fr - title translation',
  102. 'bid' => '1',
  103. 'format' => '2',
  104. 'title_translated' => 'fr - title translation',
  105. 'body_translated' => 'fr - body translation',
  106. 'title' => 'box 1 title',
  107. 'body' => 'box 1 body',
  108. ],
  109. [
  110. 'lid' => '2',
  111. 'property' => 'body',
  112. 'language' => 'fr',
  113. 'translation' => 'fr - body translation',
  114. 'bid' => '1',
  115. 'format' => '2',
  116. 'title_translated' => 'fr - title translation',
  117. 'body_translated' => 'fr - body translation',
  118. 'title' => 'box 1 title',
  119. 'body' => 'box 1 body',
  120. ],
  121. [
  122. 'lid' => '3',
  123. 'property' => 'body',
  124. 'language' => 'zu',
  125. 'translation' => 'zu - body translation',
  126. 'bid' => '2',
  127. 'format' => '2',
  128. 'title_translated' => NULL,
  129. 'body_translated' => 'zu - body translation',
  130. 'title' => 'box 2 title',
  131. 'body' => 'box 2 body',
  132. ],
  133. ];
  134. return $tests;
  135. }
  136. }