Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
@@ -50,7 +50,7 @@ class JsonFileLoaderTest extends TestCase
public function testParseException()
{
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$this->expectExceptionMessage('Error parsing JSON: Syntax error, malformed JSON');
$this->expectExceptionMessage('Error parsing JSON - Syntax error, malformed JSON');
$loader = new JsonFileLoader();
$resource = __DIR__.'/../fixtures/malformed.json';
$loader->load($resource, 'en', 'domain1');
@@ -15,7 +15,7 @@ use PHPUnit\Framework\TestCase;
abstract class LocalizedTestCase extends TestCase
{
protected function setUp()
protected function setUp(): void
{
if (!\extension_loaded('intl')) {
$this->markTestSkipped('Extension intl is required.');
@@ -23,7 +23,11 @@ class QtFileLoaderTest extends TestCase
$resource = __DIR__.'/../fixtures/resources.ts';
$catalogue = $loader->load($resource, 'en', 'resources');
$this->assertEquals(['foo' => 'bar'], $catalogue->all('resources'));
$this->assertEquals([
'foo' => 'bar',
'foo_bar' => 'foobar',
'bar_foo' => 'barfoo',
], $catalogue->all('resources'));
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
@@ -49,17 +49,13 @@ class XliffFileLoaderTest extends TestCase
public function testLoadWithExternalEntitiesDisabled()
{
if (\LIBXML_VERSION < 20900) {
$disableEntities = libxml_disable_entity_loader(true);
}
$disableEntities = libxml_disable_entity_loader(true);
$loader = new XliffFileLoader();
$resource = __DIR__.'/../fixtures/resources.xlf';
$catalogue = $loader->load($resource, 'en', 'domain1');
if (\LIBXML_VERSION < 20900) {
libxml_disable_entity_loader($disableEntities);
}
libxml_disable_entity_loader($disableEntities);
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
@@ -88,7 +84,17 @@ class XliffFileLoaderTest extends TestCase
$this->assertEquals(utf8_decode('föö'), $catalogue->get('bar', 'domain1'));
$this->assertEquals(utf8_decode('bär'), $catalogue->get('foo', 'domain1'));
$this->assertEquals(['notes' => [['content' => utf8_decode('bäz')]], 'id' => '1'], $catalogue->getMetadata('foo', 'domain1'));
$this->assertEquals(
[
'source' => 'foo',
'notes' => [['content' => utf8_decode('bäz')]],
'id' => '1',
'file' => [
'original' => 'file.ext',
],
],
$catalogue->getMetadata('foo', 'domain1')
);
}
public function testTargetAttributesAreStoredCorrectly()
@@ -154,11 +160,44 @@ class XliffFileLoaderTest extends TestCase
$loader = new XliffFileLoader();
$catalogue = $loader->load(__DIR__.'/../fixtures/withnote.xlf', 'en', 'domain1');
$this->assertEquals(['notes' => [['priority' => 1, 'content' => 'foo']], 'id' => '1'], $catalogue->getMetadata('foo', 'domain1'));
$this->assertEquals(
[
'source' => 'foo',
'notes' => [['priority' => 1, 'content' => 'foo']],
'id' => '1',
'file' => [
'original' => 'file.ext',
],
],
$catalogue->getMetadata('foo', 'domain1')
);
// message without target
$this->assertEquals(['notes' => [['content' => 'bar', 'from' => 'foo']], 'id' => '2'], $catalogue->getMetadata('extra', 'domain1'));
$this->assertEquals(
[
'source' => 'extrasource',
'notes' => [['content' => 'bar', 'from' => 'foo']],
'id' => '2',
'file' => [
'original' => 'file.ext',
],
],
$catalogue->getMetadata('extra', 'domain1')
);
// message with empty target
$this->assertEquals(['notes' => [['content' => 'baz'], ['priority' => 2, 'from' => 'bar', 'content' => 'qux']], 'id' => '123'], $catalogue->getMetadata('key', 'domain1'));
$this->assertEquals(
[
'source' => 'key',
'notes' => [
['content' => 'baz'],
['priority' => 2, 'from' => 'bar', 'content' => 'qux'],
],
'id' => '123',
'file' => [
'original' => 'file.ext',
],
],
$catalogue->getMetadata('key', 'domain1')
);
}
public function testLoadVersion2()
@@ -247,4 +286,32 @@ class XliffFileLoaderTest extends TestCase
$this->assertSame('processed', $metadata['notes'][0]['category']);
$this->assertSame('true', $metadata['notes'][0]['content']);
}
public function testLoadWithMultipleFileNodes()
{
$loader = new XliffFileLoader();
$catalogue = $loader->load(__DIR__.'/../fixtures/resources-multi-files.xlf', 'en', 'domain1');
$this->assertEquals(
[
'source' => 'foo',
'id' => '1',
'file' => [
'original' => 'file.ext',
],
],
$catalogue->getMetadata('foo', 'domain1')
);
$this->assertEquals(
[
'source' => 'test',
'notes' => [['content' => 'note']],
'id' => '4',
'file' => [
'original' => 'otherfile.ext',
],
],
$catalogue->getMetadata('test', 'domain1')
);
}
}