Skip to content

Commit e5f5340

Browse files
Merge branch '3.1'
* 3.1: [VarDumper] Various minor fixes & cleanups Revert "bug #18935 [Form] Consider a violation even if the form is not submitted (egeloen)" [Config] Fix DirectoryResourceTest for symlinks [HttpKernel] Add missing SsiFragmentRendererTest [DoctrineBridge] Fix exception message and tests after misresolved merge Fixes the calendar in constructor to handle null
2 parents 628d9de + 7491091 commit e5f5340

File tree

3 files changed

+103
-3
lines changed

3 files changed

+103
-3
lines changed

DataCollector/DumpDataCollector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public function serialize()
165165
return 'a:0:{}';
166166
}
167167

168+
$this->data[] = $this->fileLinkFormat;
169+
$this->data[] = $this->charset;
168170
$ser = serialize($this->data);
169171
$this->data = array();
170172
$this->dataCount = 0;
@@ -179,8 +181,10 @@ public function serialize()
179181
public function unserialize($data)
180182
{
181183
parent::unserialize($data);
184+
$charset = array_pop($this->data);
185+
$fileLinkFormat = array_pop($this->data);
182186
$this->dataCount = count($this->data);
183-
self::__construct($this->stopwatch);
187+
self::__construct($this->stopwatch, $fileLinkFormat, $charset);
184188
}
185189

186190
public function getDumpsCount()

Tests/DataCollector/DumpDataCollectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public function testDump()
4949
);
5050
$this->assertEquals($xDump, $dump);
5151

52-
$this->assertStringMatchesFormat('a:1:{i:0;a:5:{s:4:"data";O:39:"Symfony\Component\VarDumper\Cloner\Data":%a', $collector->serialize());
52+
$this->assertStringMatchesFormat('a:3:{i:0;a:5:{s:4:"data";O:39:"Symfony\Component\VarDumper\Cloner\Data":%a', $collector->serialize());
5353
$this->assertSame(0, $collector->getDumpsCount());
54-
$this->assertSame('a:0:{}', $collector->serialize());
54+
$this->assertSame('a:2:{i:0;b:0;i:1;s:5:"UTF-8";}', $collector->serialize());
5555
}
5656

5757
public function testCollectDefault()
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\HttpKernel\Tests\Fragment;
13+
14+
use Symfony\Component\HttpKernel\Controller\ControllerReference;
15+
use Symfony\Component\HttpKernel\Fragment\SsiFragmentRenderer;
16+
use Symfony\Component\HttpKernel\HttpCache\Ssi;
17+
use Symfony\Component\HttpFoundation\Request;
18+
use Symfony\Component\HttpKernel\UriSigner;
19+
20+
class SsiFragmentRendererTest extends \PHPUnit_Framework_TestCase
21+
{
22+
public function testRenderFallbackToInlineStrategyIfSsiNotSupported()
23+
{
24+
$strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy(true));
25+
$strategy->render('/', Request::create('/'));
26+
}
27+
28+
public function testRender()
29+
{
30+
$strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy());
31+
32+
$request = Request::create('/');
33+
$request->setLocale('fr');
34+
$request->headers->set('Surrogate-Capability', 'SSI/1.0');
35+
36+
$this->assertEquals('<!--#include virtual="/" -->', $strategy->render('/', $request)->getContent());
37+
$this->assertEquals('<!--#include virtual="/" -->', $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent(), 'Strategy options should not impact the ssi include tag');
38+
}
39+
40+
public function testRenderControllerReference()
41+
{
42+
$signer = new UriSigner('foo');
43+
$strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy(), $signer);
44+
45+
$request = Request::create('/');
46+
$request->setLocale('fr');
47+
$request->headers->set('Surrogate-Capability', 'SSI/1.0');
48+
49+
$reference = new ControllerReference('main_controller', array(), array());
50+
$altReference = new ControllerReference('alt_controller', array(), array());
51+
52+
$this->assertEquals(
53+
'<!--#include virtual="/_fragment?_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dmain_controller&_hash=Jz1P8NErmhKTeI6onI1EdAXTB85359MY3RIk5mSJ60w%3D" -->',
54+
$strategy->render($reference, $request, array('alt' => $altReference))->getContent()
55+
);
56+
}
57+
58+
/**
59+
* @expectedException \LogicException
60+
*/
61+
public function testRenderControllerReferenceWithoutSignerThrowsException()
62+
{
63+
$strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy());
64+
65+
$request = Request::create('/');
66+
$request->setLocale('fr');
67+
$request->headers->set('Surrogate-Capability', 'SSI/1.0');
68+
69+
$strategy->render(new ControllerReference('main_controller'), $request);
70+
}
71+
72+
/**
73+
* @expectedException \LogicException
74+
*/
75+
public function testRenderAltControllerReferenceWithoutSignerThrowsException()
76+
{
77+
$strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy());
78+
79+
$request = Request::create('/');
80+
$request->setLocale('fr');
81+
$request->headers->set('Surrogate-Capability', 'SSI/1.0');
82+
83+
$strategy->render('/', $request, array('alt' => new ControllerReference('alt_controller')));
84+
}
85+
86+
private function getInlineStrategy($called = false)
87+
{
88+
$inline = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer')->disableOriginalConstructor()->getMock();
89+
90+
if ($called) {
91+
$inline->expects($this->once())->method('render');
92+
}
93+
94+
return $inline;
95+
}
96+
}

0 commit comments

Comments
 (0)