diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php
index 0a641103d8..5aefa3d7b9 100644
--- a/src/Symfony/Component/Console/Helper/Table.php
+++ b/src/Symfony/Component/Console/Helper/Table.php
@@ -589,7 +589,9 @@ class Table
++$numberOfRows; // Add row for header separator
}
- ++$numberOfRows; // Add row for footer separator
+ if (\count($this->rows) > 0) {
+ ++$numberOfRows; // Add row for footer separator
+ }
return $numberOfRows;
}
diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php
index 124309dd5b..c4acc3fbff 100644
--- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php
@@ -951,6 +951,38 @@ TABLE;
$table->appendRow(['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '139.25']);
}
+ public function testSectionOutputHandlesZeroRowsAfterRender()
+ {
+ $sections = [];
+ $stream = $this->getOutputStream(true);
+ $output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
+ $output->writeln('My Table');
+ $table = new Table($output);
+ $table
+ ->setHeaders(['ISBN', 'Title', 'Author', 'Price'])
+ ->setRows([]);
+
+ $table->render();
+
+ $table->appendRow(['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '139.25']);
+
+ $expected =
+ <<
assertEquals($expected, $this->getOutputContent($output));
+ }
+
public function testIsNotDefinedStyleException()
{
$this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException');
diff --git a/src/Symfony/Component/ErrorHandler/Debug.php b/src/Symfony/Component/ErrorHandler/Debug.php
index a3c0511d22..9cc8ec17a8 100644
--- a/src/Symfony/Component/ErrorHandler/Debug.php
+++ b/src/Symfony/Component/ErrorHandler/Debug.php
@@ -29,7 +29,7 @@ class Debug
ini_set('display_errors', 1);
}
- ini_set('zend.assertions', 1);
+ @ini_set('zend.assertions', 1);
ini_set('assert.active', 1);
ini_set('assert.warning', 0);
ini_set('assert.exception', 1);
diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php
index 197f1d1b8f..b097634268 100644
--- a/src/Symfony/Component/HttpFoundation/Response.php
+++ b/src/Symfony/Component/HttpFoundation/Response.php
@@ -262,10 +262,12 @@ class Response
$this->setContent(null);
$headers->remove('Content-Type');
$headers->remove('Content-Length');
+ // prevent PHP from sending the Content-Type header based on default_mimetype
+ ini_set('default_mimetype', '');
} else {
// Content-type based on the Request
if (!$headers->has('Content-Type')) {
- $format = $request->getPreferredFormat();
+ $format = $request->getPreferredFormat(null);
if (null !== $format && $mimeType = $request->getMimeType($format)) {
$headers->set('Content-Type', $mimeType);
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
index ca75881daf..dd04d3f5b4 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
@@ -464,18 +464,10 @@ class ResponseTest extends ResponseTestCase
public function testDefaultContentType()
{
- $headerMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->setMethods(['set'])->getMock();
- $headerMock->expects($this->at(0))
- ->method('set')
- ->with('Content-Type', 'text/html');
- $headerMock->expects($this->at(1))
- ->method('set')
- ->with('Content-Type', 'text/html; charset=UTF-8');
-
$response = new Response('foo');
- $response->headers = $headerMock;
-
$response->prepare(new Request());
+
+ $this->assertSame('text/html; charset=UTF-8', $response->headers->get('Content-Type'));
}
public function testContentTypeCharset()