Merge branch '2.3' into 2.6

* 2.3:
  [FrameworkBundle] Fix title and placeholder rendering in php form templates.
  RequestDataCollector - small fix
  renamed composer.phar to composer to be consistent with the Symfony docs
  [FrameworkBundle] bumped min version of Routing to 2.3
  removed composer --dev option everywhere
  fixed a test
  [Console] Fixed output bug, if escaped string in a formatted string.
  [Security] Remove ContextListener's onKernelResponse listener as it is used
  Revert "minor #12652 [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value (skler)"
  Revert "fixed assertion"
  fixed assertion
  [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value
  fixed URL
  Add reference to documentation in FormEvents phpdocs
  [YAML] Fix one-liners to work with multiple new lines
  Keep "pre" meaning for var_dump quick-and-dirty debug
  [Console][Table] Fix cell padding with multi-byte

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php
	src/Symfony/Bundle/FrameworkBundle/composer.json
	src/Symfony/Component/Console/Helper/TableHelper.php
This commit is contained in:
Fabien Potencier 2015-02-11 08:12:14 +01:00
commit 38f03bd2f5
49 changed files with 150 additions and 57 deletions

View File

@ -36,10 +36,10 @@ before_install:
- if [ "$TRAVIS_BRANCH" = "master" ]; then export COMPOSER_ROOT_VERSION=dev-master; else export COMPOSER_ROOT_VERSION="$TRAVIS_BRANCH".x-dev; fi;
install:
- if [ "$components" = "no" ]; then composer --prefer-source --dev install; fi;
- if [ "$components" = "no" ]; then composer --prefer-source install; fi;
script:
- if [ "$components" = "no" ]; then ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; phpunit --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$components" = "no" ]; then echo -e "\\nRunning tests requiring tty"; phpunit --group tty || (echo -e "\\e[41mKO\\e[0m tty group" && $(exit 1)); fi;
- if [ "$components" = "high" ]; then find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist | sed 's#\(.*\)/.*#\1#' | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --dev update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$components" = "low" ]; then find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist | sed 's#\(.*\)/.*#\1#' | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --dev --prefer-lowest --prefer-stable update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$components" = "high" ]; then find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist | sed 's#\(.*\)/.*#\1#' | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$components" = "low" ]; then find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist | sed 's#\(.*\)/.*#\1#' | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;

View File

@ -10,5 +10,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Bridge/Doctrine/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -9,5 +9,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Bridge/Monolog/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -9,5 +9,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Bridge/Propel1/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -9,7 +9,7 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Bridge/ProxyManager/
$ composer.phar install --dev
$ composer install
$ phpunit
[1]: https://github.com/Ocramius/ProxyManager

View File

@ -11,5 +11,5 @@ If you want to run the unit tests, install dev dependencies before
running PHPUnit:
$ cd path/to/Symfony/Bridge/Twig/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -62,7 +62,7 @@ img {
width: 970px;
margin: 0 auto;
}
pre {
#content pre {
white-space: normal;
font-family: Arial, Helvetica, sans-serif;
}

View File

@ -2,7 +2,7 @@ id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name)
<?php if ($disabled): ?>disabled="disabled" <?php endif ?>
<?php if ($required): ?>required="required" <?php endif ?>
<?php foreach ($attr as $k => $v): ?>
<?php if (in_array($v, array('placeholder', 'title'), true)): ?>
<?php if (in_array($k, array('placeholder', 'title'), true)): ?>
<?php printf('%s="%s" ', $view->escape($k), $view->escape($view['translator']->trans($v, array(), $translation_domain))) ?>
<?php elseif ($v === true): ?>
<?php printf('%s="%s" ', $view->escape($k), $view->escape($k)) ?>

View File

@ -23,7 +23,7 @@
"symfony/http-foundation": "~2.4.9|~2.5,>=2.5.4",
"symfony/http-kernel": "~2.6",
"symfony/filesystem": "~2.3",
"symfony/routing": "~2.2",
"symfony/routing": "~2.3",
"symfony/security-core": "~2.6",
"symfony/security-csrf": "~2.6",
"symfony/stopwatch": "~2.3",

View File

@ -19,5 +19,5 @@ provided by the HttpKernel component.
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/BrowserKit/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -81,5 +81,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/ClassLoader/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -12,6 +12,6 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Config/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -150,6 +150,10 @@ class OutputFormatter implements OutputFormatterInterface
$pos = $match[1];
$text = $match[0];
if (0 != $pos && '\\' == $message[$pos - 1]) {
continue;
}
// add the text up to the next tag
$output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
$offset = $pos + strlen($text);
@ -164,9 +168,6 @@ class OutputFormatter implements OutputFormatterInterface
if (!$open && !$tag) {
// </>
$this->styleStack->pop();
} elseif ($pos && '\\' == $message[$pos - 1]) {
// escaped tag
$output .= $this->applyCurrentStyle($text);
} elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
$output .= $this->applyCurrentStyle($text);
} elseif ($open) {

View File

@ -43,7 +43,7 @@ abstract class Helper implements HelperInterface
}
/**
* Returns the length of a string, using mb_strlen if it is available.
* Returns the length of a string, using mb_strwidth if it is available.
*
* @param string $string The string to check its length
*

View File

@ -307,8 +307,8 @@ class Table
$width = $this->getColumnWidth($column);
// str_pad won't work properly with multi-byte strings, we need to fix the padding
if (function_exists('mb_strlen') && false !== $encoding = mb_detect_encoding($cell)) {
$width += strlen($cell) - mb_strlen($cell, $encoding);
if (function_exists('mb_strwidth') && false !== $encoding = mb_detect_encoding($cell)) {
$width += strlen($cell) - mb_strwidth($cell, $encoding);
}
$width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);

View File

@ -50,7 +50,7 @@ Tests
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Console/
$ composer.phar install
$ composer install
$ phpunit
Third Party

View File

@ -101,6 +101,11 @@ class OutputFormatterTest extends \PHPUnit_Framework_TestCase
"(\033[32mz>=2.0,<a2.3\033[39m)",
$formatter->format('(<info>'.$formatter->escape('z>=2.0,<a2.3').'</info>)')
);
$this->assertEquals(
"\033[32m<error>some error</error>\033[0m",
$formatter->format('<info>'.$formatter->escape('<error>some error</error>').'</info>')
);
}
public function testDeepNestedStyles()

View File

@ -256,7 +256,7 @@ TABLE
public function testRenderMultiByte()
{
if (!function_exists('mb_strlen')) {
if (!function_exists('mb_strwidth')) {
$this->markTestSkipped('The "mbstring" extension is not available');
}
@ -276,6 +276,33 @@ TABLE
| 1234 |
+------+
TABLE;
$this->assertEquals($expected, $this->getOutputContent($output));
}
public function testRenderFullWidthCharacters()
{
if (!function_exists('mb_strwidth')) {
$this->markTestSkipped('The "mbstring" extension is not available');
}
$table = new TableHelper();
$table
->setHeaders(array('あいうえお'))
->setRows(array(array(1234567890)))
->setLayout(TableHelper::LAYOUT_DEFAULT)
;
$table->render($output = $this->getOutputStream());
$expected =
<<<TABLE
+------------+
| あいうえお |
+------------+
| 1234567890 |
+------------+
TABLE;
$this->assertEquals($expected, $this->getOutputContent($output));

View File

@ -43,5 +43,5 @@ which is distributed under the BSD license.
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/CssSelector/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -39,5 +39,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Debug/
$ composer.phar install --dev
$ composer install
$ phpunit

View File

@ -76,5 +76,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/DependencyInjection/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -32,5 +32,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/DomCrawler/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -23,5 +23,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/EventDispatcher/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -43,5 +43,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Filesystem/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -45,7 +45,7 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Finder/
$ composer.phar install
$ composer install
$ phpunit
[1]: http://api.symfony.com/2.5/Symfony/Component/Finder/SplFileInfo.html

View File

@ -11,6 +11,12 @@
namespace Symfony\Component\Form;
/**
* To learn more about how form events work check the documentation
* entry at {@link http://symfony.com/doc/any/components/form/form_events.html}
*
* To learn how to dynamically modify forms using events check the cookbook
* entry at {@link http://symfony.com/doc/any/cookbook/form/dynamic_form_modification.html}
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
final class FormEvents

View File

@ -22,5 +22,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Form/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -2107,4 +2107,18 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
// no foo
$this->assertNotContains('foo="', $html);
}
public function testTranslatedAttributes()
{
$view = $this->factory->createNamedBuilder('name', 'form')
->add('firstName', 'text', array('attr' => array('title' => 'Foo')))
->add('lastName', 'text', array('attr' => array('placeholder' => 'Bar')))
->getForm()
->createView();
$html = $this->renderForm($view);
$this->assertMatchesXpath($html, '/form//input[@title="[trans]Foo[/trans]"]');
$this->assertMatchesXpath($html, '/form//input[@placeholder="[trans]Bar[/trans]"]');
}
}

View File

@ -52,5 +52,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/HttpFoundation/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -91,7 +91,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
$this->data = array(
'format' => $request->getRequestFormat(),
'content' => $content,
'content_type' => $response->headers->get('Content-Type') ? $response->headers->get('Content-Type') : 'text/html',
'content_type' => $response->headers->get('Content-Type', 'text/html'),
'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '',
'status_code' => $statusCode,
'request_query' => $request->query->all(),

View File

@ -95,5 +95,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/HttpKernel/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -10,7 +10,7 @@ Preparation
To prepare, you need to install the development dependencies of the component.
$ cd /path/to/Symfony/Component/Intl
$ composer.phar install --dev
$ composer install
Determining your ICU version
---------------------------

View File

@ -18,7 +18,7 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Intl/
$ composer.phar install --dev
$ composer install
$ phpunit
[0]: http://www.php.net/manual/en/intl.setup.php

View File

@ -50,7 +50,7 @@ the subdirectories bin/ and lib/.
For running this script, the intl extension must be loaded and all vendors
must have been installed through composer:
composer install --dev
composer install
MESSAGE
);

View File

@ -14,7 +14,7 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/OptionsResolver/
$ composer.phar install
$ composer install
$ phpunit
[1]: http://symfony.com/doc/current/components/options_resolver.html

View File

@ -47,5 +47,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Process/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -10,5 +10,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/PropertyAccess/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -32,5 +32,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Routing/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -113,6 +113,9 @@ class ContextListener implements ListenerInterface
return;
}
$this->dispatcher->removeListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
$this->registered = false;
if (null !== $this->logger) {
$this->logger->debug('Write SecurityContext in the session');
}

View File

@ -22,6 +22,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security\Http\Firewall\ContextListener;
use Symfony\Component\EventDispatcher\EventDispatcher;
class ContextListenerTest extends \PHPUnit_Framework_TestCase
{
@ -112,7 +113,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
new Response()
);
$listener = new ContextListener($this->securityContext, array(), 'session');
$listener = new ContextListener($this->securityContext, array(), 'session', null, new EventDispatcher());
$listener->onKernelResponse($event);
$this->assertTrue($session->isStarted());
@ -131,7 +132,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
new Response()
);
$listener = new ContextListener($this->securityContext, array(), 'session');
$listener = new ContextListener($this->securityContext, array(), 'session', null, new EventDispatcher());
$listener->onKernelResponse($event);
$this->assertFalse($session->isStarted());
@ -203,6 +204,35 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
$listener->handle($event);
}
public function testOnKernelResponseListenerRemovesItself()
{
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent')
->disableOriginalConstructor()
->getMock();
$listener = new ContextListener($context, array(), 'key123', null, $dispatcher);
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
$request->expects($this->any())
->method('hasSession')
->will($this->returnValue(true));
$event->expects($this->any())
->method('getRequestType')
->will($this->returnValue(HttpKernelInterface::MASTER_REQUEST));
$event->expects($this->any())
->method('getRequest')
->will($this->returnValue($request));
$dispatcher->expects($this->once())
->method('removeListener')
->with(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'));
$listener->onKernelResponse($event);
}
public function testHandleRemovesTokenIfNoPreviousSessionWasFound()
{
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
@ -241,7 +271,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
new Response()
);
$listener = new ContextListener($this->securityContext, array(), 'session');
$listener = new ContextListener($this->securityContext, array(), 'session', null, new EventDispatcher());
$listener->onKernelResponse($event);
return $session;

View File

@ -19,5 +19,5 @@ Tests
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Security/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -11,5 +11,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Serializer/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -9,5 +9,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Stopwatch/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -14,5 +14,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Templating/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -33,5 +33,5 @@ http://symfony.com/doc/2.6/book/translation.html
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Translation/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -122,5 +122,5 @@ http://jcp.org/en/jsr/detail?id=303
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Validator/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -52,13 +52,13 @@ class Parser
*/
public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false)
{
$this->currentLineNb = -1;
$this->currentLine = '';
$this->lines = explode("\n", $this->cleanup($value));
if (!preg_match('//u', $value)) {
throw new ParseException('The YAML value does not appear to be valid UTF-8.');
}
$this->currentLineNb = -1;
$this->currentLine = '';
$value = $this->cleanup($value);
$this->lines = explode("\n", $value);
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
@ -233,9 +233,8 @@ class Parser
throw new ParseException('Multiple documents are not supported.');
}
// 1-liner optionally followed by newline
$lineCount = count($this->lines);
if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) {
// 1-liner optionally followed by newline(s)
if ($this->lines[0] === trim($value)) {
try {
$value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
} catch (ParseException $e) {

View File

@ -17,5 +17,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Yaml/
$ composer.phar install
$ composer install
$ phpunit

View File

@ -135,6 +135,14 @@ EOF;
);
$tests['Literal block chomping strip with multiple trailing newlines'] = array($expected, $yaml);
$yaml = <<<'EOF'
{}
EOF;
$expected = array();
$tests['Literal block chomping strip with multiple trailing newlines after a 1-liner'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: |-
one