/tests/PHPUnit/Core/Translate/Filter/ByBaseTranslationsTest.php
PHP | 156 lines | 139 code | 2 blank | 15 comment | 0 complexity | 343cff37cb737e2d3d34b08c82f032e3 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\ByBaseTranslations;
- /**
- * Piwik - free/libre analytics platform
- *
- * @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()
- ),
- ),
- // not existing 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 all exist
- array(
- array(
- 'test' => array(
- 'test' => 'test'
- )
- ),
- array(
- 'test' => array(
- 'test' => 'test'
- )
- ),
- array(
- 'test' => array(
- 'test' => 'test'
- )
- ),
- array()
- ),
- // unavailable 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' => ' ',
- )
- )
- ),
- array(
- array(
- 'empty' => array(
- 'test' => 'test'
- ),
- 'test' => array(
- 'test' => 'test',
- 'empty' => ' ',
- )
- ),
- array(
- 'empty' => array(
- 'bla' => 'test'
- ),
- 'test' => array(
- 'test' => 'test',
- )
- ),
- array(
- 'test' => array(
- 'test' => 'test'
- )
- ),
- array(
- 'empty' => array(
- 'test' => 'test'
- ),
- 'test' => array(
- 'empty' => ' ',
- )
- )
- ),
- );
- }
- /**
- * @dataProvider getFilterTestData
- * @group Core
- */
- public function testFilter($translations, $baseTranslations, $expected, $filteredData)
- {
- $filter = new ByBaseTranslations($baseTranslations);
- $result = $filter->filter($translations);
- $this->assertEquals($expected, $result);
- $this->assertEquals($filteredData, $filter->getFilteredData());
- }
- }