File: NumberFormatterTest.php

package info (click to toggle)
php-symfony-polyfill 1.33.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,544 kB
  • sloc: php: 127,238; makefile: 69
file content (68 lines) | stat: -rw-r--r-- 1,812 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?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\Verification;

use Symfony\Polyfill\Tests\Intl\Icu\AbstractNumberFormatterTestCase;

/**
 * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known
 * behavior of PHP.
 *
 * @requires extension intl
 *
 * @group class-polyfill
 */
class NumberFormatterTest extends AbstractNumberFormatterTestCase
{
    protected function setUp(): void
    {
        \Locale::setDefault('en');

        if (version_compare(\INTL_ICU_VERSION, '55.1', '<')) {
            $this->markTestSkipped('ICU version 55.1 is required.');
        }
    }

    public function testCreate()
    {
        $this->assertInstanceOf('\NumberFormatter', \NumberFormatter::create('en', \NumberFormatter::DECIMAL));
    }

    public function testGetTextAttribute()
    {
        if (version_compare(\INTL_ICU_VERSION, '57.1', '<')) {
            $this->markTestSkipped('ICU version 57.1 is required.');
        }

        parent::testGetTextAttribute();
    }

    protected static function getNumberFormatter(?string $locale = 'en', ?string $style = null, ?string $pattern = null): \NumberFormatter
    {
        return new \NumberFormatter($locale, $style, $pattern);
    }

    protected static function getIntlErrorMessage(): string
    {
        return intl_get_error_message();
    }

    protected static function getIntlErrorCode(): int
    {
        return intl_get_error_code();
    }

    protected static function isIntlFailure($errorCode): bool
    {
        return intl_is_failure($errorCode);
    }
}