PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

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

https://github.com/CodeYellowBV/piwik
PHP | 93 lines | 76 code | 2 blank | 15 comment | 0 complexity | faeae491414835047d19d17960a7195f 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\EmptyTranslations;
  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 EmptyTranslationsTest 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. ),
  20. // empty plugin is removed
  21. array(
  22. array(
  23. 'test' => array()
  24. ),
  25. array(),
  26. array(),
  27. ),
  28. // empty values/plugins are removed
  29. array(
  30. array(
  31. 'test' => array(
  32. 'empty' => '',
  33. 'whitespace' => ' '
  34. )
  35. ),
  36. array(),
  37. array(
  38. 'test' => array(
  39. 'empty' => '',
  40. 'whitespace' => ' '
  41. )
  42. ),
  43. ),
  44. // no change if no empty value
  45. array(
  46. array(
  47. 'test' => array(
  48. 'test' => 'test'
  49. )
  50. ),
  51. array(
  52. 'test' => array(
  53. 'test' => 'test'
  54. )
  55. ),
  56. array()
  57. ),
  58. // empty values are removed, others stay
  59. array(
  60. array(
  61. 'empty' => array(),
  62. 'test' => array(
  63. 'test' => 'test',
  64. 'empty' => ' ',
  65. )
  66. ),
  67. array(
  68. 'test' => array(
  69. 'test' => 'test'
  70. )
  71. ),
  72. array(
  73. 'test' => array(
  74. 'empty' => ' ',
  75. )
  76. )
  77. ),
  78. );
  79. }
  80. /**
  81. * @dataProvider getFilterTestData
  82. * @group Core
  83. */
  84. public function testFilter($translations, $expected, $filteredData)
  85. {
  86. $filter = new EmptyTranslations();
  87. $result = $filter->filter($translations);
  88. $this->assertEquals($expected, $result);
  89. $this->assertEquals($filteredData, $filter->getFilteredData());
  90. }
  91. }