Skip to content

Commit 789111c

Browse files
committed
Merge branch '2.8' into 3.1
* 2.8: [TwigBundle] fixed usage when Templating is not installed [Validator] Check cascasdedGroups for being countable [Filesystem] Check that the directory is writable after created it in dumpFile() [HttpFoundation] Improved set cookie header tests [Console] increased code coverage of Output classes [Profiler][VarDumper] Fix minor color issue & duplicated selector
2 parents 41bbe5c + 4546377 commit 789111c

File tree

11 files changed

+93
-25
lines changed

11 files changed

+93
-25
lines changed

src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function process(ContainerBuilder $container)
4545
if ($container->has('form.extension')) {
4646
$container->getDefinition('twig.extension.form')->addTag('twig.extension');
4747
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
48-
$container->getDefinition('twig.loader.filesystem')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
48+
$container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
4949
}
5050

5151
if ($container->has('translator')) {
@@ -84,11 +84,13 @@ public function process(ContainerBuilder $container)
8484
$container->getDefinition('twig.extension.debug')->addTag('twig.extension');
8585
}
8686

87-
if (!$container->has('templating')) {
88-
$loader = $container->getDefinition('twig.loader.native_filesystem');
89-
$loader->addTag('twig.loader');
90-
$loader->setMethodCalls($container->getDefinition('twig.loader.filesystem')->getMethodCalls());
87+
$twigLoader = $container->getDefinition('twig.loader.native_filesystem');
88+
if ($container->has('templating')) {
89+
$loader = $container->getDefinition('twig.loader.filesystem');
90+
$loader->setMethodCalls($twigLoader->getMethodCalls());
9191

92+
$twigLoader->clearTag('twig.loader');
93+
} else {
9294
$container->setAlias('twig.loader.filesystem', new Alias('twig.loader.native_filesystem', false));
9395
}
9496

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function load(array $configs, ContainerBuilder $container)
7878
$envConfiguratorDefinition->replaceArgument(4, $config['number_format']['decimal_point']);
7979
$envConfiguratorDefinition->replaceArgument(5, $config['number_format']['thousands_separator']);
8080

81-
$twigFilesystemLoaderDefinition = $container->getDefinition('twig.loader.filesystem');
81+
$twigFilesystemLoaderDefinition = $container->getDefinition('twig.loader.native_filesystem');
8282

8383
// register user-configured paths
8484
foreach ($config['paths'] as $path => $namespace) {

src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
<tag name="twig.loader"/>
1111
</service>
1212

13-
<service id="twig.loader" alias="twig.loader.filesystem" />
14-
1513
<service id="templating.engine.twig" class="Symfony\Bundle\TwigBundle\TwigEngine" public="false">
1614
<argument type="service" id="twig" />
1715
<argument type="service" id="templating.name_parser" />

src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
<service id="twig.loader.native_filesystem" class="Twig_Loader_Filesystem" public="false">
4545
<argument type="collection" />
46+
<tag name="twig.loader"/>
4647
</service>
4748

4849
<service id="twig.loader.chain" class="Twig_Loader_Chain" public="false"/>

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function testTwigLoaderPaths($format)
151151
$this->loadFromFile($container, 'extra', $format);
152152
$this->compileContainer($container);
153153

154-
$def = $container->getDefinition('twig.loader.filesystem');
154+
$def = $container->getDefinition('twig.loader.native_filesystem');
155155
$paths = array();
156156
foreach ($def->getMethodCalls() as $call) {
157157
if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) {

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,10 @@
163163
font-size: 11px;
164164
padding: 4px 8px 4px 0;
165165
}
166-
.sf-toolbar-block .sf-toolbar-info-piece span {
167-
166+
.sf-toolbar-block:not(.sf-toolbar-block-dump) .sf-toolbar-info-piece span {
167+
color: #F5F5F5;
168168
}
169169
.sf-toolbar-block .sf-toolbar-info-piece span {
170-
color: #F5F5F5;
171170
font-size: 12px;
172171
}
173172

src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Console\Tests\Output;
1313

14+
use Symfony\Component\Console\Formatter\OutputFormatter;
1415
use Symfony\Component\Console\Output\ConsoleOutput;
1516
use Symfony\Component\Console\Output\Output;
1617

@@ -22,4 +23,19 @@ public function testConstructor()
2223
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
2324
$this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument');
2425
}
26+
27+
public function testSetFormatter()
28+
{
29+
$output = new ConsoleOutput();
30+
$outputFormatter = new OutputFormatter();
31+
$output->setFormatter($outputFormatter);
32+
$this->assertSame($outputFormatter, $output->getFormatter());
33+
}
34+
35+
public function testSetVerbosity()
36+
{
37+
$output = new ConsoleOutput();
38+
$output->setVerbosity(Output::VERBOSITY_VERBOSE);
39+
$this->assertSame(Output::VERBOSITY_VERBOSE, $output->getVerbosity());
40+
}
2541
}

src/Symfony/Component/Console/Tests/Output/NullOutputTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Symfony\Component\Console\Tests\Output;
1313

14+
use Symfony\Component\Console\Formatter\OutputFormatter;
1415
use Symfony\Component\Console\Output\NullOutput;
16+
use Symfony\Component\Console\Output\Output;
1517
use Symfony\Component\Console\Output\OutputInterface;
1618

1719
class NullOutputTest extends \PHPUnit_Framework_TestCase
@@ -36,4 +38,50 @@ public function testVerbosity()
3638
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
3739
$this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() always returns VERBOSITY_QUIET for NullOutput');
3840
}
41+
42+
public function testSetFormatter()
43+
{
44+
$output = new NullOutput();
45+
$outputFormatter = new OutputFormatter();
46+
$output->setFormatter($outputFormatter);
47+
$this->assertNotSame($outputFormatter, $output->getFormatter());
48+
}
49+
50+
public function testSetVerbosity()
51+
{
52+
$output = new NullOutput();
53+
$output->setVerbosity(Output::VERBOSITY_NORMAL);
54+
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity());
55+
}
56+
57+
public function testSetDecorated()
58+
{
59+
$output = new NullOutput();
60+
$output->setDecorated(true);
61+
$this->assertFalse($output->isDecorated());
62+
}
63+
64+
public function testIsQuiet()
65+
{
66+
$output = new NullOutput();
67+
$this->assertTrue($output->isQuiet());
68+
}
69+
70+
public function testIsVerbose()
71+
{
72+
$output = new NullOutput();
73+
$this->assertFalse($output->isVerbose());
74+
}
75+
76+
public function testIsVeryVerbose()
77+
{
78+
$output = new NullOutput();
79+
$this->assertFalse($output->isVeryVerbose());
80+
}
81+
82+
public function testIsDebug()
83+
{
84+
$output = new NullOutput();
85+
$this->assertFalse($output->isDebug());
86+
}
3987
}

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,9 @@ public function dumpFile($filename, $content)
548548

549549
if (!is_dir($dir)) {
550550
$this->mkdir($dir);
551-
} elseif (!is_writable($dir)) {
551+
}
552+
553+
if (!is_writable($dir)) {
552554
throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
553555
}
554556

src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ public function testToStringIncludesCookieHeaders()
116116
$bag = new ResponseHeaderBag(array());
117117
$bag->setCookie(new Cookie('foo', 'bar'));
118118

119-
$this->assertContains('Set-Cookie: foo=bar; path=/; httponly', explode("\r\n", $bag->__toString()));
119+
$this->assertSetCookieHeader('foo=bar; path=/; httponly', $bag);
120120

121121
$bag->clearCookie('foo');
122122

123-
$this->assertRegExp('#^Set-Cookie: foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; httponly#m', $bag->__toString());
123+
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; httponly', $bag);
124124
}
125125

126126
public function testClearCookieSecureNotHttpOnly()
@@ -129,7 +129,7 @@ public function testClearCookieSecureNotHttpOnly()
129129

130130
$bag->clearCookie('foo', '/', null, true, false);
131131

132-
$this->assertRegExp('#^Set-Cookie: foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; secure#m', $bag->__toString());
132+
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; secure', $bag);
133133
}
134134

135135
public function testReplace()
@@ -165,11 +165,10 @@ public function testCookiesWithSameNames()
165165

166166
$this->assertCount(4, $bag->getCookies());
167167

168-
$headers = explode("\r\n", $bag->__toString());
169-
$this->assertContains('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly', $headers);
170-
$this->assertContains('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly', $headers);
171-
$this->assertContains('Set-Cookie: foo=bar; path=/path/bar; domain=bar.foo; httponly', $headers);
172-
$this->assertContains('Set-Cookie: foo=bar; path=/; httponly', $headers);
168+
$this->assertSetCookieHeader('foo=bar; path=/path/foo; domain=foo.bar; httponly', $bag);
169+
$this->assertSetCookieHeader('foo=bar; path=/path/bar; domain=foo.bar; httponly', $bag);
170+
$this->assertSetCookieHeader('foo=bar; path=/path/bar; domain=bar.foo; httponly', $bag);
171+
$this->assertSetCookieHeader('foo=bar; path=/; httponly', $bag);
173172

174173
$cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
175174
$this->assertTrue(isset($cookies['foo.bar']['/path/foo']['foo']));
@@ -223,7 +222,7 @@ public function testGetCookiesWithInvalidArgument()
223222
{
224223
$bag = new ResponseHeaderBag();
225224

226-
$cookies = $bag->getCookies('invalid_argument');
225+
$bag->getCookies('invalid_argument');
227226
}
228227

229228
/**
@@ -294,4 +293,9 @@ public function provideMakeDispositionFail()
294293
array('attachment', 'föö.html'),
295294
);
296295
}
296+
297+
private function assertSetCookieHeader($expected, ResponseHeaderBag $actual)
298+
{
299+
$this->assertRegExp('#^Set-Cookie:\s+'.preg_quote($expected, '#').'$#m', str_replace("\r\n", "\n", (string) $actual));
300+
}
297301
}

0 commit comments

Comments
 (0)