قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-22 15:07:44 +00:00

* Update console command to import compact formats * Update Intl data * Add methods to NumberFormatter for compact number and currency formatting * Use new compact formatting for download numbers in marketplace * Add compact formatting to javascript formatter * Use compact formatting for MultiSites KPI metrics * update tests * apply review feedback * fix doc blocks
72 خطوط
1.9 KiB
PHP
72 خطوط
1.9 KiB
PHP
<?php
|
|
|
|
namespace Piwik\Plugins\Marketplace\tests\Unit;
|
|
|
|
use Piwik\Plugins\Marketplace\Plugins;
|
|
use Piwik\Tests\Framework\Fixture;
|
|
use ReflectionClass;
|
|
|
|
/**
|
|
* @group Marketplace
|
|
* @group PluginsTest
|
|
* @group Plugins
|
|
*/
|
|
class PluginsTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
/**
|
|
* @dataProvider getNumberOfDownloadsData
|
|
*/
|
|
public function testPrettifyNumberOfDownloads($numDownloads, $expectedPrettyDownloads)
|
|
{
|
|
Fixture::loadAllTranslations();
|
|
|
|
$pluginsClass = new Plugins(
|
|
$this->createMock('Piwik\Plugins\Marketplace\Api\Client'),
|
|
$this->createMock('Piwik\Plugins\Marketplace\Consumer'),
|
|
$this->createMock('Piwik\ProfessionalServices\Advertising')
|
|
);
|
|
|
|
$pluginsReflection = new ReflectionClass($pluginsClass);
|
|
$method = $pluginsReflection->getMethod('prettifyNumberOfDownloads');
|
|
$method->setAccessible(true);
|
|
|
|
$plugin = ['numDownloads' => $numDownloads];
|
|
$method->invokeArgs($pluginsClass, [&$plugin]);
|
|
|
|
$this->assertEquals($expectedPrettyDownloads, $plugin['numDownloadsPretty']);
|
|
}
|
|
|
|
public function getNumberOfDownloadsData(): array
|
|
{
|
|
return [
|
|
[-1, -1],
|
|
[0, 0],
|
|
[999, 999],
|
|
[1000, '1K'],
|
|
[1050, '1.1K'],
|
|
[1051, '1.1K'],
|
|
[1550, '1.6K'],
|
|
[1551, '1.6K'],
|
|
[9950, '10K'],
|
|
[9951, '10K'],
|
|
[9999, '10K'],
|
|
[10000, '10K'],
|
|
[10100, '10K'],
|
|
[99950, '100K'],
|
|
[99951, '100K'],
|
|
[100000, '100K'],
|
|
[999999, '1M'],
|
|
[1000000, '1M'],
|
|
[1100000, '1.1M'],
|
|
[9999999, '10M'],
|
|
[10000000, '10M'],
|
|
[10000001, '10M'],
|
|
[99999999, '100M'],
|
|
[100000000, '100M'],
|
|
[100000001, '100M'],
|
|
[999999999, '1B'],
|
|
[1000000000, '1B'],
|
|
];
|
|
}
|
|
}
|