Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
<?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\Component\Intl\Tests\Collator;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Intl\Collator\Collator;
/**
* Test case for Collator implementations.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
abstract class AbstractCollatorTest extends TestCase
{
/**
* @dataProvider asortProvider
*/
public function testAsort($array, $sortFlag, $expected)
{
$collator = $this->getCollator('en');
$collator->asort($array, $sortFlag);
$this->assertSame($expected, $array);
}
public function asortProvider()
{
return [
/* array, sortFlag, expected */
[
['a', 'b', 'c'],
Collator::SORT_REGULAR,
['a', 'b', 'c'],
],
[
['c', 'b', 'a'],
Collator::SORT_REGULAR,
[2 => 'a', 1 => 'b', 0 => 'c'],
],
[
['b', 'c', 'a'],
Collator::SORT_REGULAR,
[2 => 'a', 0 => 'b', 1 => 'c'],
],
];
}
/**
* @param string $locale
*
* @return \Collator
*/
abstract protected function getCollator($locale);
}

View File

@@ -0,0 +1,101 @@
<?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\Component\Intl\Tests\Collator;
use Symfony\Component\Intl\Collator\Collator;
use Symfony\Component\Intl\Globals\IntlGlobals;
class CollatorTest extends AbstractCollatorTest
{
public function testConstructorWithUnsupportedLocale()
{
$this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
new Collator('pt_BR');
}
public function testCompare()
{
$this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->compare('a', 'b');
}
public function testGetAttribute()
{
$this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->getAttribute(Collator::NUMERIC_COLLATION);
}
public function testGetErrorCode()
{
$collator = $this->getCollator('en');
$this->assertEquals(IntlGlobals::U_ZERO_ERROR, $collator->getErrorCode());
}
public function testGetErrorMessage()
{
$collator = $this->getCollator('en');
$this->assertEquals('U_ZERO_ERROR', $collator->getErrorMessage());
}
public function testGetLocale()
{
$collator = $this->getCollator('en');
$this->assertEquals('en', $collator->getLocale());
}
public function testConstructWithoutLocale()
{
$collator = $this->getCollator(null);
$this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
}
public function testGetSortKey()
{
$this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->getSortKey('Hello');
}
public function testGetStrength()
{
$this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->getStrength();
}
public function testSetAttribute()
{
$this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
}
public function testSetStrength()
{
$this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->setStrength(Collator::PRIMARY);
}
public function testStaticCreate()
{
$collator = Collator::create('en');
$this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
}
protected function getCollator($locale)
{
return new Collator($locale);
}
}

View File

@@ -0,0 +1,36 @@
<?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\Component\Intl\Tests\Collator\Verification;
use Symfony\Component\Intl\Tests\Collator\AbstractCollatorTest;
use Symfony\Component\Intl\Util\IntlTestHelper;
/**
* Verifies that {@link AbstractCollatorTest} matches the behavior of the
* {@link \Collator} class in a specific version of ICU.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class CollatorTest extends AbstractCollatorTest
{
protected function setUp()
{
IntlTestHelper::requireFullIntl($this, false);
parent::setUp();
}
protected function getCollator($locale)
{
return new \Collator($locale);
}
}