diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Core/Translate/Filter/ByBaseTranslationsTest.php | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/tests/PHPUnit/Core/Translate/Filter/ByBaseTranslationsTest.php b/tests/PHPUnit/Core/Translate/Filter/ByBaseTranslationsTest.php new file mode 100644 index 0000000000..6596059ba7 --- /dev/null +++ b/tests/PHPUnit/Core/Translate/Filter/ByBaseTranslationsTest.php @@ -0,0 +1,125 @@ +<?php +use Piwik\Translate\Filter\ByBaseTranslations; + +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ +class ByBaseTranslationsTest extends PHPUnit_Framework_TestCase +{ + public function getFilterTestData() + { + return array( + // empty stays empty + array( + array(), + array(), + array(), + array() + ), + // empty plugin is removed + array( + array( + 'test' => array() + ), + array(), + array(), + array( + 'test' => array() + ), + ), + // empty values/plugins are removed + array( + array( + 'test' => array( + 'key' => 'value', + 'test' => 'test' + ) + ), + array( + 'test' => array( + 'key' => 'value', + 'x' => 'y' + ) + ), + array( + 'test' => array( + 'key' => 'value', + ) + ), + array( + 'test' => array( + 'test' => 'test', + ) + ), + ), + // no change if no empty value + array( + array( + 'test' => array( + 'test' => 'test' + ) + ), + array( + 'test' => array( + 'test' => 'test' + ) + ), + array( + 'test' => array( + 'test' => 'test' + ) + ), + array() + ), + // empty values are removed, others stay + array( + array( + 'empty' => array( + 'test' => 'test' + ), + 'test' => array( + 'test' => 'test', + 'empty' => ' ', + ) + ), + array( + 'empty' => array( + 'test' => 'test' + ), + 'test' => array( + 'test' => 'test', + ) + ), + array( + 'empty' => array( + 'test' => 'test' + ), + 'test' => array( + 'test' => 'test' + ) + ), + array( + 'test' => array( + 'empty' => ' ', + ) + ) + ), + ); + } + + /** + * @dataProvider getFilterTestData + * @group Core + * @group Translate + */ + public function testFilter($translations, $baseTranslations, $expected, $filteredData) + { + $filter = new ByBaseTranslations($baseTranslations); + $result = $filter->filter($translations); + $this->assertEquals($expected, $result); + $this->assertEquals($filteredData, $filter->getFilteredData()); + } +} |