Merge branch '4.4'
* 4.4: [HttpFoundation] fix not sending Content-Type header for 204 responses [ErrorHandler] silence warning when zend.assertions=-1 [Console] Handle zero row count in appendRow() for Table
This commit is contained in:
commit
c09128cf9f
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 =
|
||||
<<<TABLE
|
||||
My Table
|
||||
+------+-------+--------+-------+
|
||||
|\033[32m ISBN \033[39m|\033[32m Title \033[39m|\033[32m Author \033[39m|\033[32m Price \033[39m|
|
||||
+------+-------+--------+-------+
|
||||
\x1b[3A\x1b[0J+---------------+----------------------+-----------------+--------+
|
||||
|\033[32m ISBN \033[39m|\033[32m Title \033[39m|\033[32m Author \033[39m|\033[32m Price \033[39m|
|
||||
+---------------+----------------------+-----------------+--------+
|
||||
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | 139.25 |
|
||||
+---------------+----------------------+-----------------+--------+
|
||||
|
||||
TABLE;
|
||||
|
||||
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||
}
|
||||
|
||||
public function testIsNotDefinedStyleException()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException');
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Reference in New Issue