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,74 @@
<?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\Util;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Intl\Exception\RuntimeException;
use Symfony\Component\Intl\Util\GitRepository;
/**
* @group intl-data
*/
class GitRepositoryTest extends TestCase
{
private $targetDir;
const REPO_URL = 'https://github.com/symfony/intl.git';
/**
* @before
* @after
*/
protected function cleanup()
{
$this->targetDir = sys_get_temp_dir().'/GitRepositoryTest/source';
$fs = new Filesystem();
$fs->remove($this->targetDir);
}
public function testItThrowsAnExceptionIfInitialisedWithNonGitDirectory()
{
$this->expectException(RuntimeException::class);
@mkdir($this->targetDir, 0777, true);
new GitRepository($this->targetDir);
}
public function testItClonesTheRepository()
{
$git = GitRepository::download(self::REPO_URL, $this->targetDir);
$this->assertInstanceOf(GitRepository::class, $git);
$this->assertDirectoryExists($this->targetDir.'/.git');
$this->assertSame($this->targetDir, $git->getPath());
$this->assertSame(self::REPO_URL, $git->getUrl());
$this->assertMatchesRegularExpression('#^[0-9a-z]{40}$#', $git->getLastCommitHash());
$this->assertNotEmpty($git->getLastAuthor());
$this->assertInstanceOf('DateTime', $git->getLastAuthoredDate());
$this->assertStringMatchesFormat('v%s', $git->getLastTag());
$this->assertStringMatchesFormat('v3%s', $git->getLastTag(function ($tag) { return 0 === strpos($tag, 'v3'); }));
}
public function testItCheckoutsToTheLastTag()
{
$git = GitRepository::download(self::REPO_URL, $this->targetDir);
$lastCommitHash = $git->getLastCommitHash();
$lastV3Tag = $git->getLastTag(function ($tag) { return 0 === strpos($tag, 'v3'); });
$git->checkout($lastV3Tag);
$this->assertNotEquals($lastCommitHash, $git->getLastCommitHash());
}
}

View File

@@ -0,0 +1,112 @@
<?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\Util;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Intl\Util\IcuVersion;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class IcuVersionTest extends TestCase
{
public function normalizeProvider()
{
return [
[null, '1', '10'],
[null, '1.2', '12'],
[null, '1.2.3', '12.3'],
[null, '1.2.3.4', '12.3.4'],
[1, '1', '10'],
[1, '1.2', '12'],
[1, '1.2.3', '12'],
[1, '1.2.3.4', '12'],
[2, '1', '10'],
[2, '1.2', '12'],
[2, '1.2.3', '12.3'],
[2, '1.2.3.4', '12.3'],
[3, '1', '10'],
[3, '1.2', '12'],
[3, '1.2.3', '12.3'],
[3, '1.2.3.4', '12.3.4'],
];
}
/**
* @dataProvider normalizeProvider
*/
public function testNormalize($precision, $version, $result)
{
$this->assertSame($result, IcuVersion::normalize($version, $precision));
}
public function compareProvider()
{
return [
[null, '1', '==', '1', true],
[null, '1.0', '==', '1.1', false],
[null, '1.0.0', '==', '1.0.1', false],
[null, '1.0.0.0', '==', '1.0.0.1', false],
[null, '1.0.0.0.0', '==', '1.0.0.0.1', false],
[null, '1', '==', '10', true],
[null, '1.0', '==', '11', false],
[null, '1.0.0', '==', '10.1', false],
[null, '1.0.0.0', '==', '10.0.1', false],
[null, '1.0.0.0.0', '==', '10.0.0.1', false],
[1, '1', '==', '1', true],
[1, '1.0', '==', '1.1', false],
[1, '1.0.0', '==', '1.0.1', true],
[1, '1.0.0.0', '==', '1.0.0.1', true],
[1, '1.0.0.0.0', '==', '1.0.0.0.1', true],
[1, '1', '==', '10', true],
[1, '1.0', '==', '11', false],
[1, '1.0.0', '==', '10.1', true],
[1, '1.0.0.0', '==', '10.0.1', true],
[1, '1.0.0.0.0', '==', '10.0.0.1', true],
[2, '1', '==', '1', true],
[2, '1.0', '==', '1.1', false],
[2, '1.0.0', '==', '1.0.1', false],
[2, '1.0.0.0', '==', '1.0.0.1', true],
[2, '1.0.0.0.0', '==', '1.0.0.0.1', true],
[2, '1', '==', '10', true],
[2, '1.0', '==', '11', false],
[2, '1.0.0', '==', '10.1', false],
[2, '1.0.0.0', '==', '10.0.1', true],
[2, '1.0.0.0.0', '==', '10.0.0.1', true],
[3, '1', '==', '1', true],
[3, '1.0', '==', '1.1', false],
[3, '1.0.0', '==', '1.0.1', false],
[3, '1.0.0.0', '==', '1.0.0.1', false],
[3, '1.0.0.0.0', '==', '1.0.0.0.1', true],
[3, '1', '==', '10', true],
[3, '1.0', '==', '11', false],
[3, '1.0.0', '==', '10.1', false],
[3, '1.0.0.0', '==', '10.0.1', false],
[3, '1.0.0.0.0', '==', '10.0.0.1', true],
];
}
/**
* @dataProvider compareProvider
*/
public function testCompare($precision, $version1, $operator, $version2, $result)
{
$this->assertSame($result, IcuVersion::compare($version1, $version2, $operator, $precision));
}
}

View File

@@ -0,0 +1,88 @@
<?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\Util;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Intl\Util\Version;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class VersionTest extends TestCase
{
public function normalizeProvider()
{
return [
[null, '1', '1'],
[null, '1.2', '1.2'],
[null, '1.2.3', '1.2.3'],
[null, '1.2.3.4', '1.2.3.4'],
[1, '1', '1'],
[1, '1.2', '1'],
[1, '1.2.3', '1'],
[1, '1.2.3.4', '1'],
[2, '1', '1'],
[2, '1.2', '1.2'],
[2, '1.2.3', '1.2'],
[2, '1.2.3.4', '1.2'],
[3, '1', '1'],
[3, '1.2', '1.2'],
[3, '1.2.3', '1.2.3'],
[3, '1.2.3.4', '1.2.3'],
[4, '1', '1'],
[4, '1.2', '1.2'],
[4, '1.2.3', '1.2.3'],
[4, '1.2.3.4', '1.2.3.4'],
];
}
/**
* @dataProvider normalizeProvider
*/
public function testNormalize($precision, $version, $result)
{
$this->assertSame($result, Version::normalize($version, $precision));
}
public function compareProvider()
{
return [
[null, '1', '==', '1', true],
[null, '1.0', '==', '1.1', false],
[null, '1.0.0', '==', '1.0.1', false],
[null, '1.0.0.0', '==', '1.0.0.1', false],
[1, '1', '==', '1', true],
[1, '1.0', '==', '1.1', true],
[1, '1.0.0', '==', '1.0.1', true],
[1, '1.0.0.0', '==', '1.0.0.1', true],
[2, '1', '==', '1', true],
[2, '1.0', '==', '1.1', false],
[2, '1.0.0', '==', '1.0.1', true],
[2, '1.0.0.0', '==', '1.0.0.1', true],
[3, '1', '==', '1', true],
[3, '1.0', '==', '1.1', false],
[3, '1.0.0', '==', '1.0.1', false],
[3, '1.0.0.0', '==', '1.0.0.1', true],
];
}
/**
* @dataProvider compareProvider
*/
public function testCompare($precision, $version1, $operator, $version2, $result)
{
$this->assertSame($result, Version::compare($version1, $version2, $operator, $precision));
}
}