PageRenderTime 51ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/PHPUnit/Core/Translate/Filter/ByBaseTranslationsTest.php

https://github.com/CodeYellowBV/piwik
PHP | 156 lines | 139 code | 2 blank | 15 comment | 0 complexity | 343cff37cb737e2d3d34b08c82f032e3 MD5 | raw file
Possible License(s): LGPL-3.0, JSON, MIT, GPL-3.0, LGPL-2.1, GPL-2.0, AGPL-1.0, BSD-2-Clause, BSD-3-Clause
  1. <?php
  2. use Piwik\Translate\Filter\ByBaseTranslations;
  3. /**
  4. * Piwik - free/libre analytics platform
  5. *
  6. * @link http://piwik.org
  7. * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
  8. */
  9. class ByBaseTranslationsTest extends PHPUnit_Framework_TestCase
  10. {
  11. public function getFilterTestData()
  12. {
  13. return array(
  14. // empty stays empty
  15. array(
  16. array(),
  17. array(),
  18. array(),
  19. array()
  20. ),
  21. // empty plugin is removed
  22. array(
  23. array(
  24. 'test' => array()
  25. ),
  26. array(),
  27. array(),
  28. array(
  29. 'test' => array()
  30. ),
  31. ),
  32. // not existing values/plugins are removed
  33. array(
  34. array(
  35. 'test' => array(
  36. 'key' => 'value',
  37. 'test' => 'test'
  38. )
  39. ),
  40. array(
  41. 'test' => array(
  42. 'key' => 'value',
  43. 'x' => 'y'
  44. )
  45. ),
  46. array(
  47. 'test' => array(
  48. 'key' => 'value',
  49. )
  50. ),
  51. array(
  52. 'test' => array(
  53. 'test' => 'test',
  54. )
  55. ),
  56. ),
  57. // no change if all exist
  58. array(
  59. array(
  60. 'test' => array(
  61. 'test' => 'test'
  62. )
  63. ),
  64. array(
  65. 'test' => array(
  66. 'test' => 'test'
  67. )
  68. ),
  69. array(
  70. 'test' => array(
  71. 'test' => 'test'
  72. )
  73. ),
  74. array()
  75. ),
  76. // unavailable removed, others stay
  77. array(
  78. array(
  79. 'empty' => array(
  80. 'test' => 'test'
  81. ),
  82. 'test' => array(
  83. 'test' => 'test',
  84. 'empty' => ' ',
  85. )
  86. ),
  87. array(
  88. 'empty' => array(
  89. 'test' => 'test'
  90. ),
  91. 'test' => array(
  92. 'test' => 'test',
  93. )
  94. ),
  95. array(
  96. 'empty' => array(
  97. 'test' => 'test'
  98. ),
  99. 'test' => array(
  100. 'test' => 'test'
  101. )
  102. ),
  103. array(
  104. 'test' => array(
  105. 'empty' => ' ',
  106. )
  107. )
  108. ),
  109. array(
  110. array(
  111. 'empty' => array(
  112. 'test' => 'test'
  113. ),
  114. 'test' => array(
  115. 'test' => 'test',
  116. 'empty' => ' ',
  117. )
  118. ),
  119. array(
  120. 'empty' => array(
  121. 'bla' => 'test'
  122. ),
  123. 'test' => array(
  124. 'test' => 'test',
  125. )
  126. ),
  127. array(
  128. 'test' => array(
  129. 'test' => 'test'
  130. )
  131. ),
  132. array(
  133. 'empty' => array(
  134. 'test' => 'test'
  135. ),
  136. 'test' => array(
  137. 'empty' => ' ',
  138. )
  139. )
  140. ),
  141. );
  142. }
  143. /**
  144. * @dataProvider getFilterTestData
  145. * @group Core
  146. */
  147. public function testFilter($translations, $baseTranslations, $expected, $filteredData)
  148. {
  149. $filter = new ByBaseTranslations($baseTranslations);
  150. $result = $filter->filter($translations);
  151. $this->assertEquals($expected, $result);
  152. $this->assertEquals($filteredData, $filter->getFilteredData());
  153. }
  154. }