diff options
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()); + } +} |