/tests/PHPUnit/Core/Translate/Filter/EncodedEntitiesTest.php
PHP | 107 lines | 91 code | 2 blank | 14 comment | 0 complexity | c7c5defab21424198a999de29f943dac 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
- <?php
- use Piwik\Translate\Filter\EncodedEntities;
- /**
- * Piwik - free/libre analytics platform
- *
- * @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
- */
- public function testFilter($translations, $expected, $filteredData)
- {
- $filter = new EncodedEntities();
- $result = $filter->filter($translations);
- $this->assertEquals($expected, $result);
- $this->assertEquals($filteredData, $filter->getFilteredData());
- }
- }