diff options
author | sgiehl <stefan@piwik.org> | 2013-08-30 20:44:34 +0400 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2013-09-04 02:15:14 +0400 |
commit | 8b01230fc5f0424e2dc8721c29737f7f4b25498c (patch) | |
tree | bbdd3d66b89afcf18db0d3bef08125f455867f23 /tests | |
parent | b5caa5e2894fd0b33484c81ce5747774bee560ea (diff) |
added translations filter to filter encoded entities
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Core/Translate/Filter/EncodedEntitiesTest.php | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/tests/PHPUnit/Core/Translate/Filter/EncodedEntitiesTest.php b/tests/PHPUnit/Core/Translate/Filter/EncodedEntitiesTest.php new file mode 100644 index 0000000000..afaf1142ca --- /dev/null +++ b/tests/PHPUnit/Core/Translate/Filter/EncodedEntitiesTest.php @@ -0,0 +1,108 @@ +<?php +use Piwik\Translate\Filter\EncodedEntities; + +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ +class EncodedEntitiesTest extends PHPUnit_Framework_TestCase +{ + public function getFilterTestData() + { + return array( + // empty stays empty - nothing to filter + array( + array(), + array(), + array() + ), + // empty plugin is removed + array( + array( + 'test' => array() + ), + array( + 'test' => array() + ), + array(), + ), + // no entites - nothing to filter + array( + array( + 'test' => array( + 'key' => 'val%sue', + 'test' => 'test' + ) + ), + array( + 'test' => array( + 'key' => 'val%sue', + 'test' => 'test' + ) + ), + array(), + ), + // entities needs to be decodded + array( + array( + 'test' => array( + 'test' => 'te&st' + ) + ), + array( + 'test' => array( + 'test' => 'te&st' + ) + ), + array( + 'test' => array( + 'test' => 'te&st' + ) + ), + ), + array( + array( + 'empty' => array( + 'test' => 'tüsest' + ), + 'test' => array( + 'test' => '%1$stest', + 'empty' => '˜', + ) + ), + array( + 'empty' => array( + 'test' => 'tüsest' + ), + 'test' => array( + 'test' => '%1$stest', + 'empty' => '˜', + ) + ), + array( + 'empty' => array( + 'test' => 'tüsest' + ), + 'test' => array( + 'empty' => '˜', + ) + ), + ), + ); + } + + /** + * @dataProvider getFilterTestData + * @group Core + * @group Translate + */ + public function testFilter($translations, $expected, $filteredData) + { + $filter = new EncodedEntities(); + $result = $filter->filter($translations); + $this->assertEquals($expected, $result); + $this->assertEquals($filteredData, $filter->getFilteredData()); + } +} |