File: CurrenciesTest.php

package info (click to toggle)
php-symfony-polyfill 1.33.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 8,520 kB
  • sloc: php: 127,232; makefile: 69
file content (46 lines) | stat: -rw-r--r-- 1,339 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Polyfill\Tests\Intl\Icu;

use PHPUnit\Framework\TestCase;

/**
 * @group class-polyfill
 */
class CurrenciesTest extends TestCase
{
    public function testMetadata()
    {
        $dataDir = '/usr/share/php/Symfony/Component/Intl/Resources/data/currencies/';

        if (is_file($dataDir.'en.php')) {
            $en = require $dataDir.'en.php';
            $meta = require $dataDir.'meta.php';
        } else {
            $en = json_decode(file_get_contents($dataDir.'en.json'), true);
            $meta = json_decode(file_get_contents($dataDir.'meta.json'), true);
        }
        $data = [];

        foreach ($en['Names'] as $code => [$symbol, $name]) {
            $data[$code] = [$symbol];
        }

        foreach ($meta['Meta'] as $code => [$fractionDigit, $roundingIncrement]) {
            $data[$code] = ($data[$code] ?? []) + [1 => $fractionDigit, $roundingIncrement];
        }

        $data = "<?php\n\nreturn ".var_export($data, true).";\n";

        $this->assertStringEqualsFile(\dirname(__DIR__, 3).'/src/Intl/Icu/Resources/currencies.php', $data);
    }
}