Skip to content

Commit 6bb1c6d

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: Validate XLIFF translation files replace alias in factory services
2 parents b537bf1 + 4b33fd3 commit 6bb1c6d

File tree

5 files changed

+108
-1
lines changed

5 files changed

+108
-1
lines changed

src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ private function updateReferences($container, $currentId, $newId)
9595
$definition->setProperties(
9696
$this->updateArgumentReferences($definition->getProperties(), $currentId, $newId)
9797
);
98+
99+
$definition->setFactoryService($this->updateFactoryServiceReference($definition->getFactoryService(), $currentId, $newId));
98100
}
99101
}
100102

@@ -122,4 +124,13 @@ private function updateArgumentReferences(array $arguments, $currentId, $newId)
122124

123125
return $arguments;
124126
}
127+
128+
private function updateFactoryServiceReference($factoryService, $currentId, $newId)
129+
{
130+
if (null === $factoryService) {
131+
return;
132+
}
133+
134+
return $currentId === $factoryService ? $newId : $currentId;
135+
}
125136
}

src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public function testProcess()
2121
{
2222
$container = new ContainerBuilder();
2323

24-
$container->register('a', '\stdClass');
24+
$aDefinition = $container->register('a', '\stdClass');
25+
$aDefinition->setFactoryService('b');
26+
$aDefinition->setFactoryMethod('createA');
2527

2628
$bDefinition = new Definition('\stdClass');
2729
$bDefinition->setPublic(false);
@@ -39,6 +41,7 @@ public function testProcess()
3941
$container->has('b_alias') && !$container->hasAlias('b_alias'),
4042
'->process() replaces alias to actual.'
4143
);
44+
$this->assertSame('b_alias', $aDefinition->getFactoryService());
4245
}
4346

4447
/**
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Tests\Resources;
13+
14+
class TranslationFilesTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @dataProvider provideTranslationFiles
18+
*/
19+
public function testTranslationFileIsValid($filePath)
20+
{
21+
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
22+
}
23+
24+
public function provideTranslationFiles()
25+
{
26+
return array_map(
27+
function ($filePath) { return (array) $filePath; },
28+
glob(dirname(dirname(__DIR__)).'/Resources/translations/*.xlf')
29+
);
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Tests\Resources;
13+
14+
class TranslationFilesTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @dataProvider provideTranslationFiles
18+
*/
19+
public function testTranslationFileIsValid($filePath)
20+
{
21+
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
22+
}
23+
24+
public function provideTranslationFiles()
25+
{
26+
return array_map(
27+
function ($filePath) { return (array) $filePath; },
28+
glob(dirname(dirname(__DIR__)).'/Resources/translations/*.xlf')
29+
);
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Tests\Resources;
13+
14+
class TranslationFilesTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @dataProvider provideTranslationFiles
18+
*/
19+
public function testTranslationFileIsValid($filePath)
20+
{
21+
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
22+
}
23+
24+
public function provideTranslationFiles()
25+
{
26+
return array_map(
27+
function ($filePath) { return (array) $filePath; },
28+
glob(dirname(dirname(__DIR__)).'/Resources/translations/*.xlf')
29+
);
30+
}
31+
}

0 commit comments

Comments
 (0)