8000 Merge branch '2.8' into 3.1 · symfony/symfony@0a56032 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a56032

Browse files
committed
Merge branch '2.8' into 3.1
* 2.8: [TwigBundle] added missing dependencies for tests fixed CS [TwigBundle] Adjust CacheWarmingTest for TemplateCacheWarmer introduced in 2.8 [TwigBundle] Fix CacheWarmingTest are order dependent Revert "bug #20080 [Form] compound forms without children should be considered rendered implicitly (backbone87)" Fix #19943 Make sure to process each interface metadata only once #17580 compound forms without children should be considered rendered implicitly
2 parents bab7ef9 + 997e6d7 commit 0a56032

File tree

9 files changed

+94
-28
lines changed

9 files changed

+94
-28
lines changed

src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testCacheIsProperlyWarmedWhenTemplatingIsAvailable()
3131
$this->assertTrue(file_exists($kernel->getCacheDir().'/twig'));
3232
}
3333

34-
public function testCacheIsNotWarmedWhenTemplatingIsDisabled()
34+
public function testCacheIsProperlyWarmedWhenTemplatingIsDisabled()
3535
{
3636
$kernel = new CacheWarmingKernel(false);
3737
$kernel->boot();
@@ -40,7 +40,7 @@ public function testCacheIsNotWarmedWhenTemplatingIsDisabled()
4040
$warmer->enableOptionalWarmers();
4141
$warmer->warmUp($kernel->getCacheDir());
4242

43-
$this->assertFalse(file_exists($kernel->getCacheDir().'/twig'));
43+
$this->assertTrue(file_exists($kernel->getCacheDir().'/twig'));
4444
}
4545

4646
protected function setUp()
@@ -72,7 +72,7 @@ public function __construct($withTemplating)
7272
{
7373
$this->withTemplating = $withTemplating;
7474

75-
parent::__construct('dev', true);
75+
parent::__construct(($withTemplating ? 'with' : 'without').'_templating', true);
7676
}
7777

7878
public function getName()
@@ -106,7 +106,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
106106

107107
public function getCacheDir()
108108
{
109-
return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/cache';
109+
return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/cache/'.$this->environment;
110110
}
111111

112112
public function getLogDir()

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"symfony/routing": "~2.8|~3.0",
3333
"symfony/templating": "~2.8|~3.0",
3434
"symfony/yaml": "~2.8|~3.0",
35-
"symfony/framework-bundle": "~2.8|~3.0"
35+
"symfony/framework-bundle": "~2.8|~3.0",
36+
"doctrine/annotations": "~1.0"
3637
},
3738
"autoload": {
3839
"psr-4": { "Symfony\\Bundle\\TwigBundle\\": "" },

src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,27 @@ public function getMetadataFor($value)
114114
$metadata->mergeConstraints($this->getMetadataFor($parent->name));
115115
}
116116

117-
// Include constraints from all implemented interfaces that have not been processed via parent class yet
118-
foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) {
119-
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name || ($parent && $parent->implementsInterface($interface->name))) {
117+
$interfaces = $metadata->getReflectionClass()->getInterfaces();
118+
119+
$interfaces = array_filter($interfaces, function ($interface) use ($parent, $interfaces) {
120+
$interfaceName = $interface->getName();
121+
122+
if ($parent && $parent->implementsInterface($interfaceName)) {
123+
return false;
124+
}
125+
126+
foreach ($interfaces as $i) {
127+
if ($i !== $interface && $i->implementsInterface($interfaceName)) {
128+
return false;
129+
}
130+
}
131+
132+
return true;
133+
});
134+
135+
// Include constraints from all directly implemented interfaces
136+
foreach ($interfaces as $interface) {
137+
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name) {
120138
continue;
121139
}
122140
$metadata->mergeConstraints($this->getMetadataFor($interface->name));

src/Symfony/Component/Validator/Tests/Fixtures/Entity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @Assert\GroupSequence({"Foo", "Entity"})
2020
* @Assert\Callback({"Symfony\Component\Validator\Tests\Fixtures\CallbackClass", "callback"})
2121
*/
22-
class Entity extends EntityParent
22+
class Entity extends EntityParent implements EntityInterfaceB
2323
{
2424
/**
2525
* @Assert\NotNull

src/Symfony/Component/Validator/Tests/Fixtures/EntityInterface.php renamed to src/Symfony/Component/Validator/Tests/Fixtures/EntityInterfaceA.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Fixtures;
1313

14-
interface EntityInterface
14+
interface EntityInterfaceA
1515
{
1616
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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\Fixtures;
13+
14+
interface EntityInterfaceB extends EntityParentInterface
15+
{
16+
}

src/Symfony/Component/Validator/Tests/Fixtures/EntityParent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\Validator\Constraints\NotNull;
1515

16-
class EntityParent implements EntityInterface
16+
class EntityParent implements EntityInterfaceA
1717
{
1818
protected $firstName;
1919
private $internal;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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\Fixtures;
13+
14+
interface EntityParentInterface
15+
{
16+
}

src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@
1818

1919
class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
2020
{
21-
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
22-
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
23-
const INTERFACECLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityInterface';
21+
const CLASS_NAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
22+
const PARENT_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
23+
const INTERFACE_A_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityInterfaceA';
24+
const INTERFACE_B_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityInterfaceB';
25+
const PARENT_INTERFACE_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParentInterface';
2426

2527
public function testLoadClassMetadataWithInterface()
2628
{
2729
$factory = new LazyLoadingMetadataFactory(new TestLoader());
28-
$metadata = $factory->getMetadataFor(self::PARENTCLASS);
30+
$metadata = $factory->getMetadataFor(self::PARENT_CLASS);
2931

3032
$constraints = array(
31-
new ConstraintA(array('groups' => array('Default', 'EntityInterface', 'EntityParent'))),
33+
new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA', 'EntityParent'))),
3234
new ConstraintA(array('groups' => array('Default', 'EntityParent'))),
3335
);
3436

@@ -38,12 +40,12 @@ public function testLoadClassMetadataWithInterface()
3840
public function testMergeParentConstraints()
3941
{
4042
$factory = new LazyLoadingMetadataFactory(new TestLoader());
41-
$metadata = $factory->getMetadataFor(self::CLASSNAME);
43+
$metadata = $factory->getMetadataFor(self::CLASS_NAME);
4244

4345
$constraints = array(
4446
new ConstraintA(array('groups' => array(
4547
'Default',
46-
'EntityInterface',
48+
'EntityInterfaceA',
4749
'EntityParent',
4850
'Entity',
4951
))),
@@ -52,6 +54,17 @@ public function testMergeParentConstraints()
5254
'EntityParent',
5355
'Entity',
5456
))),
57+
new ConstraintA(array('groups' => array(
58+
'Default',
59+
'EntityParentInterface',
60+
'EntityInterfaceB',
61+
'Entity',
62+
))),
63+
new ConstraintA(array('groups' => array(
64+
'Default',
65+
'EntityInterfaceB',
66+
'Entity',
67+
))),
5568
new ConstraintA(array('groups' => array(
5669
'Default',
5770
'Entity',
@@ -67,34 +80,36 @@ public function testWriteMetadataToCache()
6780
$factory = new LazyLoadingMetadataFactory(new TestLoader(), $cache);
6881

6982
$parentClassConstraints = array(
70-
new ConstraintA(array('groups' => array('Default', 'EntityInterface', 'EntityParent'))),
83+
new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA', 'EntityParent'))),
7184
new ConstraintA(array('groups' => array('Default', 'EntityParent'))),
7285
);
73-
$interfaceConstraints = array(new ConstraintA(array('groups' => array('Default', 'EntityInterface'))));
86+
$interfaceAConstraints = array(
87+
new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA'))),
88+
);
7489

7590
$cache->expects($this->never())
7691
->method('has');
7792
$cache->expects($this->exactly(2))
7893
->method('read')
7994
->withConsecutive(
80-
array($this->equalTo(self::PARENTCLASS)),
81-
array($this->equalTo(self::INTERFACECLASS))
95+
array($this->equalTo(self::PARENT_CLASS)),
96+
array($this->equalTo(self::INTERFACE_A_CLASS))
8297
)
8398
->will($this->returnValue(false));
8499
$cache->expects($this->exactly(2))
85100
->method('write')
86101
->withConsecutive(
87-
$this->callback(function ($metadata) use ($interfaceConstraints) {
88-
return $interfaceConstraints == $metadata->getConstraints();
102+
$this->callback(function ($metadata) use ($interfaceAConstraints) {
103+
return $interfaceAConstraints == $metadata->getConstraints();
89104
}),
90105
$this->callback(function ($metadata) use ($parentClassConstraints) {
91106
return $parentClassConstraints == $metadata->getConstraints();
92107
})
93108
);
94109

95-
$metadata = $factory->getMetadataFor(self::PARENTCLASS);
110+
$metadata = $factory->getMetadataFor(self::PARENT_CLASS);
96111

97-
$this->assertEquals(self::PARENTCLASS, $metadata->getClassName());
112+
$this->assertEquals(self::PARENT_CLASS, $metadata->getClassName());
98113
$this->assertEquals($parentClassConstraints, $metadata->getConstraints());
99114
}
100115

@@ -104,7 +119,7 @@ public function testReadMetadataFromCache()
104119
$cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface');
105120
$factory = new LazyLoadingMetadataFactory($loader, $cache);
106121

107-
$metadata = new ClassMetadata(self::PARENTCLASS);
122+
$metadata = new ClassMetadata(self::PARENT_CLASS);
108123
$metadata->addConstraint(new ConstraintA());
109124

110125
$loader->expects($this->never())
@@ -116,7 +131,7 @@ public function testReadMetadataFromCache()
116131
->method('read')
117132
->will($this->returnValue($metadata));
118133

119-
$this->assertEquals($metadata, $factory->getMetadataFor(self::PARENTCLASS));
134+
$this->assertEquals($metadata, $factory->getMetadataFor(self::PARENT_CLASS));
120135
}
121136
}
122137

0 commit comments

Comments
 (0)
0