Skip to content

Commit 848aec0

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: Fixed the XPath filtering to have the same behavior than Symfony 2.4 [DomCrawler] Fixed filterXPath() chaining [DomCrawler] Added more tests for the XPath filtering [HttpKernel] fixed file uploads in functional tests when no file was selected Fixed test cases failing when the Intl extension is not installed Fixed the Travis build to avoid exiting too early Conflicts: src/Symfony/Component/DomCrawler/Crawler.php src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php
2 parents eef7415 + 0bfb14e commit 848aec0

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ protected function filterRequest(DomRequest $request)
143143
{
144144
$httpRequest = Request::create($request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), $request->getFiles(), $request->getServer(), $request->getContent());
145145

146-
$httpRequest->files->replace($this->filterFiles($httpRequest->files->all()));
146+
foreach ($this->filterFiles($httpRequest->files->all()) as $key => $value) {
147+
$httpRequest->files->set($key, $value);
148+
}
147149

148150
return $httpRequest;
149151
}
@@ -189,8 +191,6 @@ protected function filterFiles(array $files)
189191
true
190192
);
191193
}
192-
} else {
193-
$filtered[$key] = $value;
194194
}
195195
}
196196

Tests/ClientTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,21 @@ public function testUploadedFile()
128128
unlink($target);
129129
}
130130

131+
public function testUploadedFileWhenNoFileSelected()
132+
{
133+
$kernel = new TestHttpKernel();
134+
$client = new Client($kernel);
135+
136+
$file = array('tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => UPLOAD_ERR_NO_FILE);
137+
138+
$client->request('POST', '/', array(), array('foo' => $file));
139+
140+
$files = $client->getRequest()->files->all();
141+
142+
$this->assertCount(1, $files);
143+
$this->assertNull($files['foo']);
144+
}
145+
131146
public function testUploadedFileWhenSizeExceedsUploadMaxFileSize()
132147
{
133148
$source = tempnam(sys_get_temp_dir(), 'source');

0 commit comments

Comments
 (0)