From 0562463cb79db8bf484644fb59c3f097216dc1a0 Mon Sep 17 00:00:00 2001 From: Adrien BRAULT Date: Mon, 9 Jul 2012 01:05:31 +0200 Subject: [PATCH 001/597] [Security] Add an option to disable the hasPreviousSession() check in AbstractAuthenticationListener --- .../DependencyInjection/Security/Factory/AbstractFactory.php | 1 + .../Security/Http/Firewall/AbstractAuthenticationListener.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php index 611b0285c0638..288c5e3634125 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php @@ -36,6 +36,7 @@ abstract class AbstractFactory implements SecurityFactoryInterface 'use_referer' => false, 'failure_path' => null, 'failure_forward' => false, + 'require_previous_session' => true, ); public function create(ContainerBuilder $container, $id, $config, $userProviderId, $defaultEntryPointId) diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php index 1caaf0af0ba66..a5924ffb0d3da 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php @@ -98,6 +98,7 @@ public function __construct(SecurityContextInterface $securityContext, Authentic 'use_referer' => false, 'failure_path' => null, 'failure_forward' => false, + 'require_previous_session' => true, ), $options); $this->logger = $logger; $this->dispatcher = $dispatcher; @@ -132,7 +133,7 @@ public final function handle(GetResponseEvent $event) } try { - if (!$request->hasPreviousSession()) { + if ($this->options['require_previous_session'] && !$request->hasPreviousSession()) { throw new SessionUnavailableException('Your session has timed out, or you have disabled cookies.'); } From 92fbb0b6791792927b3712d63753e53393570cf3 Mon Sep 17 00:00:00 2001 From: Miha Vrhovnik Date: Thu, 19 Jul 2012 14:30:30 +0300 Subject: [PATCH 002/597] Classes should be removed only when adaptive is specified --- src/Symfony/Component/ClassLoader/ClassCollectionLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index 7f5bdd1e47548..a3202a8dedcaa 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -95,7 +95,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = $files = array(); $content = ''; foreach (self::getOrderedClasses($classes) as $class) { - if (in_array($class->getName(), $declared)) { + if ($adaptive && in_array($class->getName(), $declared)) { continue; } From e66bd14ca28cb7c80c6246286ddc142cd4232660 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 8 Jan 2013 18:27:02 +0100 Subject: [PATCH 003/597] [TwigBundle] Use display instead of visibility for exception page icons --- .../views/Exception/exception.html.twig | 18 +++++++++--------- .../Resources/views/Exception/trace.html.twig | 4 ++-- .../Resources/views/Exception/traces.html.twig | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig index 5b44b8121599b..a93d9c43255b2 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig @@ -47,8 +47,8 @@

Logs  - - - + + -

{% endspaceless %} @@ -74,8 +74,8 @@

Content of the Output  - - + + + +

{% endspaceless %} @@ -107,15 +107,15 @@ } function switchIcons(id1, id2) { - var icon1, icon2, visibility1, visibility2; + var icon1, icon2, display1, display2; icon1 = document.getElementById(id1); icon2 = document.getElementById(id2); - visibility1 = icon1.style.visibility; - visibility2 = icon2.style.visibility; + display1 = icon1.style.display; + display2 = icon2.style.display; - icon1.style.visibility = visibility2; - icon2.style.visibility = visibility1; + icon1.style.display = display2; + icon2.style.display = display1; } //]]> diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig index 37b2ecc2b4af2..d00a376a4589e 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig @@ -12,8 +12,8 @@ in {{ trace.file|format_file(trace.line) }}  {% spaceless %} - - - + + - + + {% endspaceless %}
diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig index e9359959d21ea..cf49082cf4ecf 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig @@ -5,8 +5,8 @@ {{ exception.class|abbr_class }}: {{ exception.message|nl2br|format_file_from_text }}  {% spaceless %} - - - + + - + + {% endspaceless %} From a557b89efc7cf5d8d9be838a170e044586d8f02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Fri, 18 Jan 2013 13:53:35 +0100 Subject: [PATCH 004/597] [Process] Added ProcessUtils::escapeArgument() to fix the bug in escapeshellarg() function on Windows --- src/Symfony/Component/Process/CHANGELOG.md | 1 + .../Component/Process/ProcessBuilder.php | 2 +- .../Component/Process/ProcessUtils.php | 60 +++++++++++++++++++ .../Process/Tests/ProcessBuilderTest.php | 12 ++++ .../Process/Tests/ProcessUtilsTest.php | 42 +++++++++++++ 5 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/Process/ProcessUtils.php create mode 100644 src/Symfony/Component/Process/Tests/ProcessUtilsTest.php diff --git a/src/Symfony/Component/Process/CHANGELOG.md b/src/Symfony/Component/Process/CHANGELOG.md index 7fa5b72d50275..8a3f631a4e0a4 100644 --- a/src/Symfony/Component/Process/CHANGELOG.md +++ b/src/Symfony/Component/Process/CHANGELOG.md @@ -7,6 +7,7 @@ CHANGELOG * added ProcessBuilder::setArguments() to reset the arguments on a builder * added a way to retrieve the standard and error output incrementally * added Process:restart() + * added ProcessUtils::escapeArgument() to fix the bug in escapeshellarg() function on Windows 2.1.0 ----- diff --git a/src/Symfony/Component/Process/ProcessBuilder.php b/src/Symfony/Component/Process/ProcessBuilder.php index 1a95bd0df4926..45a5cd1d406c3 100644 --- a/src/Symfony/Component/Process/ProcessBuilder.php +++ b/src/Symfony/Component/Process/ProcessBuilder.php @@ -143,7 +143,7 @@ public function getProcess() $options = $this->options; - $script = implode(' ', array_map('escapeshellarg', $this->arguments)); + $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $this->arguments)); if ($this->inheritEnv) { $env = $this->env ? $this->env + $_ENV : null; diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php new file mode 100644 index 0000000000000..73380be84d4ec --- /dev/null +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -0,0 +1,60 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process; + +/** + * ProcessUtils is a bunch of utility methods. + * + * This class contains static methods only and is not meant to be instantiated. + * + * @author Martin Hasoň + */ +class ProcessUtils +{ + /** + * This class should not be instantiated + */ + private function __construct() + { + } + + /** + * Escapes a string to be used as a shell argument. + * + * @param string $argument The argument that will be escaped + * + * @return string The escaped argument + */ + public static function escapeArgument($argument) + { + //Fix for PHP bug #43784 escapeshellarg removes % from given string + //Fix for PHP bug #49446 escapeshellarg dosn`t work on windows + //@see https://bugs.php.net/bug.php?id=43784 + //@see https://bugs.php.net/bug.php?id=49446 + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $escapedArgument = ''; + foreach(preg_split('/([%"])/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { + if ('"' == $part) { + $escapedArgument .= '\\"'; + } elseif ('%' == $part) { + $escapedArgument .= '^%'; + } else { + $escapedArgument .= escapeshellarg($part); + } + } + + return $escapedArgument; + } + + return escapeshellarg($argument); + } +} diff --git a/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php b/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php index 38e14910907e1..585aa9f137320 100644 --- a/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php @@ -115,4 +115,16 @@ public function testShouldSetArguments() $this->assertContains("second", $proc->getCommandLine()); } + + public function testShouldEscapeArguments() + { + $pb = new ProcessBuilder(array('%path%', 'foo " bar')); + $proc = $pb->getProcess(); + + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertSame('^%"path"^% "foo "\\"" bar"', $proc->getCommandLine()); + } else { + $this->assertSame("'%path%' 'foo \" bar'", $proc->getCommandLine()); + } + } } diff --git a/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php b/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php new file mode 100644 index 0000000000000..e51da5a5e22a8 --- /dev/null +++ b/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process\Tests; + +use Symfony\Component\Process\ProcessUtils; + +class ProcessUtilsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider dataArguments + */ + public function testEscapeArgument($result, $argument) + { + $this->assertSame($result, ProcessUtils::escapeArgument($argument)); + } + + public function dataArguments() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + return array( + array('"foo bar"', 'foo bar'), + array('^%"path"^%', '%path%'), + array('"<|>"\\"" "\\""\'f"', '<|>" "\'f'), + ); + } + + return array( + array("'foo bar'", 'foo bar'), + array("'%path%'", '%path%'), + array("'<|>\" \"'\\''f'", '<|>" "\'f'), + ); + } +} From 3c3d34d03c48562eb9ccd664bfdc237b4ad50503 Mon Sep 17 00:00:00 2001 From: Benoit Garret Date: Fri, 25 Jan 2013 09:25:30 +0100 Subject: [PATCH 005/597] [FrameworkBundle] [Templating] added Stopwatch support to the PHP engine --- .../FrameworkExtension.php | 3 + .../Resources/config/templating_debug.xml | 8 +++ .../Templating/TimedPhpEngine.php | 59 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 6423754059b24..e3d0418e72850 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -357,6 +357,9 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB if ($container->getParameter('kernel.debug')) { $loader->load('templating_debug.xml'); + + $container->setDefinition('templating.engine.php', $container->findDefinition('debug.templating.engine.php')); + $container->setAlias('debug.templating.engine.php', 'templating.engine.php'); } // create package definitions and add them to the assets helper diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml index 0d3cebebea9a7..23da774223b45 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml @@ -6,6 +6,7 @@ Symfony\Bundle\FrameworkBundle\Templating\Debugger + Symfony\Bundle\FrameworkBundle\Templating\TimedPhpEngine @@ -13,5 +14,12 @@ + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php new file mode 100644 index 0000000000000..56f529965df48 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Templating; + +use Symfony\Bundle\FrameworkBundle\Templating\PhpEngine; +use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables; +use Symfony\Component\Templating\TemplateNameParserInterface; +use Symfony\Component\HttpKernel\Debug\Stopwatch; +use Symfony\Component\Templating\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Times the time spent to render a template. + * + * @author Fabien Potencier + */ +class TimedPhpEngine extends PhpEngine +{ + protected $stopwatch; + + /** + * Constructor. + * + * @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance + * @param ContainerInterface $container A ContainerInterface instance + * @param LoaderInterface $loader A LoaderInterface instance + * @param Stopwatch $stopwatch A Stopwatch instance + * @param GlobalVariables $globals A GlobalVariables instance + */ + public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, Stopwatch $stopwatch, GlobalVariables $globals = null) + { + parent::__construct($parser, $container, $loader, $globals); + + $this->stopwatch = $stopwatch; + } + + /** + * {@inheritdoc} + */ + public function render($name, array $parameters = array()) + { + $e = $this->stopwatch->start(sprintf('template.php (%s)', $name), 'template'); + + $ret = parent::render($name, $parameters); + + $e->stop(); + + return $ret; + } +} From d0aaf625573254b5aff0a89cf12063d53067d81a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 31 Jan 2013 22:39:01 +0100 Subject: [PATCH 006/597] updated the branch alias in composer files --- composer.json | 2 +- src/Symfony/Bridge/Doctrine/composer.json | 2 +- src/Symfony/Bridge/Monolog/composer.json | 2 +- src/Symfony/Bridge/Propel1/composer.json | 2 +- src/Symfony/Bridge/Swiftmailer/composer.json | 2 +- src/Symfony/Bridge/Twig/composer.json | 2 +- src/Symfony/Bundle/FrameworkBundle/composer.json | 2 +- src/Symfony/Bundle/SecurityBundle/composer.json | 2 +- src/Symfony/Bundle/TwigBundle/composer.json | 2 +- src/Symfony/Bundle/WebProfilerBundle/composer.json | 2 +- src/Symfony/Component/BrowserKit/composer.json | 2 +- src/Symfony/Component/ClassLoader/composer.json | 2 +- src/Symfony/Component/Config/composer.json | 2 +- src/Symfony/Component/Console/composer.json | 2 +- src/Symfony/Component/CssSelector/composer.json | 2 +- src/Symfony/Component/DependencyInjection/composer.json | 2 +- src/Symfony/Component/DomCrawler/composer.json | 2 +- src/Symfony/Component/EventDispatcher/composer.json | 2 +- src/Symfony/Component/Filesystem/composer.json | 2 +- src/Symfony/Component/Finder/composer.json | 2 +- src/Symfony/Component/Form/composer.json | 2 +- src/Symfony/Component/HttpFoundation/composer.json | 2 +- src/Symfony/Component/HttpKernel/composer.json | 2 +- src/Symfony/Component/Locale/composer.json | 2 +- src/Symfony/Component/OptionsResolver/composer.json | 2 +- src/Symfony/Component/Process/composer.json | 2 +- src/Symfony/Component/PropertyAccess/composer.json | 2 +- src/Symfony/Component/Routing/composer.json | 2 +- src/Symfony/Component/Security/composer.json | 2 +- src/Symfony/Component/Serializer/composer.json | 2 +- src/Symfony/Component/Stopwatch/composer.json | 2 +- src/Symfony/Component/Templating/composer.json | 2 +- src/Symfony/Component/Translation/composer.json | 2 +- src/Symfony/Component/Validator/composer.json | 2 +- src/Symfony/Component/Yaml/composer.json | 2 +- 35 files changed, 35 insertions(+), 35 deletions(-) diff --git a/composer.json b/composer.json index 01aca2008abe5..d11e71b60ce14 100644 --- a/composer.json +++ b/composer.json @@ -74,7 +74,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 0ba9f1e93b608..ae790054cfbef 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -44,7 +44,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index 0e89cf2346b0f..0ac1bb7ed024f 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -27,7 +27,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bridge/Propel1/composer.json b/src/Symfony/Bridge/Propel1/composer.json index 3e9bdd329920e..2d56e57b890ae 100644 --- a/src/Symfony/Bridge/Propel1/composer.json +++ b/src/Symfony/Bridge/Propel1/composer.json @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bridge/Swiftmailer/composer.json b/src/Symfony/Bridge/Swiftmailer/composer.json index 7d96c19300575..e2b76eb4d1e6a 100644 --- a/src/Symfony/Bridge/Swiftmailer/composer.json +++ b/src/Symfony/Bridge/Swiftmailer/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 885718c506353..e02681e0fbe0e 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -44,7 +44,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 12bc33d882443..9c80b827adabf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -45,7 +45,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index f7be085bb7cc1..32e24fdccaa1c 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index b65b8923bd5f8..b505783577cdb 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index 338ad281d5ba6..8d5fba85dad53 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/BrowserKit/composer.json b/src/Symfony/Component/BrowserKit/composer.json index e1921435106fc..2c9e18ad2f312 100644 --- a/src/Symfony/Component/BrowserKit/composer.json +++ b/src/Symfony/Component/BrowserKit/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/ClassLoader/composer.json b/src/Symfony/Component/ClassLoader/composer.json index cd56c8c2faa4f..ec594e5b7ad53 100644 --- a/src/Symfony/Component/ClassLoader/composer.json +++ b/src/Symfony/Component/ClassLoader/composer.json @@ -28,7 +28,7 @@ "target-dir": "Symfony/Component/ClassLoader", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Config/composer.json b/src/Symfony/Component/Config/composer.json index e148c27c09085..6a182492d1c22 100644 --- a/src/Symfony/Component/Config/composer.json +++ b/src/Symfony/Component/Config/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index 3369681580e30..a3c71521bb42b 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/CssSelector/composer.json b/src/Symfony/Component/CssSelector/composer.json index 54661fb87ba55..4a2f46192c2c0 100644 --- a/src/Symfony/Component/CssSelector/composer.json +++ b/src/Symfony/Component/CssSelector/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index d951f3041d29d..87d49297b456a 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/DomCrawler/composer.json b/src/Symfony/Component/DomCrawler/composer.json index 5696a86893435..492bb26edd8e2 100644 --- a/src/Symfony/Component/DomCrawler/composer.json +++ b/src/Symfony/Component/DomCrawler/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/EventDispatcher/composer.json b/src/Symfony/Component/EventDispatcher/composer.json index 1a90992fd1867..c6eed3c37e789 100644 --- a/src/Symfony/Component/EventDispatcher/composer.json +++ b/src/Symfony/Component/EventDispatcher/composer.json @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Filesystem/composer.json b/src/Symfony/Component/Filesystem/composer.json index d1f97cf8d42d2..167dd506a9958 100644 --- a/src/Symfony/Component/Filesystem/composer.json +++ b/src/Symfony/Component/Filesystem/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Finder/composer.json b/src/Symfony/Component/Finder/composer.json index 2ad5b34ccb4a6..7480b3edb1ab1 100644 --- a/src/Symfony/Component/Finder/composer.json +++ b/src/Symfony/Component/Finder/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 51afa67c3a15b..b5f5a89682aa1 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -37,7 +37,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/HttpFoundation/composer.json b/src/Symfony/Component/HttpFoundation/composer.json index 09b8725308d85..f77e08ebd6ace 100644 --- a/src/Symfony/Component/HttpFoundation/composer.json +++ b/src/Symfony/Component/HttpFoundation/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 9680fadd2a760..01c6d83f251a2 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -47,7 +47,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Locale/composer.json b/src/Symfony/Component/Locale/composer.json index 1e977cb9e8bc4..f8267fd3c026c 100644 --- a/src/Symfony/Component/Locale/composer.json +++ b/src/Symfony/Component/Locale/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/OptionsResolver/composer.json b/src/Symfony/Component/OptionsResolver/composer.json index 4812585a5277f..f13d246e95936 100644 --- a/src/Symfony/Component/OptionsResolver/composer.json +++ b/src/Symfony/Component/OptionsResolver/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Process/composer.json b/src/Symfony/Component/Process/composer.json index 1681ef6c1f97b..427e63b87fce4 100644 --- a/src/Symfony/Component/Process/composer.json +++ b/src/Symfony/Component/Process/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/PropertyAccess/composer.json b/src/Symfony/Component/PropertyAccess/composer.json index 3b85c0308edaa..318604274a3df 100644 --- a/src/Symfony/Component/PropertyAccess/composer.json +++ b/src/Symfony/Component/PropertyAccess/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index d29f645424d3e..341bfc98712c0 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -37,7 +37,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index 7192d5720293d..468b7203b69f5 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -44,7 +44,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index cff1e49cfa4fe..ab537b2955270 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Stopwatch/composer.json b/src/Symfony/Component/Stopwatch/composer.json index 30336fc65ceef..97e214fa2df2e 100644 --- a/src/Symfony/Component/Stopwatch/composer.json +++ b/src/Symfony/Component/Stopwatch/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Templating/composer.json b/src/Symfony/Component/Templating/composer.json index 234e28d63bdc7..b27f56c2f18bf 100644 --- a/src/Symfony/Component/Templating/composer.json +++ b/src/Symfony/Component/Templating/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 52e4c43b403bf..c555b7698c736 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 9c65253c8e56d..55836561640ca 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -38,7 +38,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Yaml/composer.json b/src/Symfony/Component/Yaml/composer.json index e04dabf3fc22c..1a009c16d6a27 100644 --- a/src/Symfony/Component/Yaml/composer.json +++ b/src/Symfony/Component/Yaml/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } From bd0709c0b7217e773788eb1c2f66d587921f648f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bj=C3=B8rnskov?= Date: Tue, 5 Feb 2013 09:33:19 +0100 Subject: [PATCH 007/597] Use REQUEST_TIME_FLOAT if available. This will give a more correct initialization time when using the DataCollectors without a KernelInterface implementation such as Silex. --- .../DataCollector/TimeDataCollector.php | 6 ++- .../DataCollector/TimeDataCollectorTest.php | 45 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php diff --git a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php index 5fd237849903d..b01006064838a 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php @@ -35,8 +35,12 @@ public function __construct(KernelInterface $kernel = null) */ public function collect(Request $request, Response $response, \Exception $exception = null) { + if (null === $this->kernel) { + $requestTime = $request->server->get('REQUEST_TIME_FLOAT', $request->server->get('REQUEST_TIME')); + } + $this->data = array( - 'start_time' => (null !== $this->kernel ? $this->kernel->getStartTime() : $_SERVER['REQUEST_TIME']) * 1000, + 'start_time' => (isset($requestTime) ? $requestTime : $this->kernel->getStartTime()) * 1000, 'events' => array(), ); } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php new file mode 100644 index 0000000000000..ef9886f022146 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\DataCollector; + +use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; + +class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase +{ + protected function setUp() + { + if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + $this->markTestSkipped('The "HttpFoundation" component is not available'); + } + } + + public function testCollectWithoutKernel() + { + $c = new TimeDataCollector; + + $request = new Request(); + $request->server->set('REQUEST_TIME', 1); + + $c->collect($request, new Response()); + + $this->assertEquals(1000, $c->getStartTime()); + + $request->server->set('REQUEST_TIME_FLOAT', 2); + + $c->collect($request, new Response()); + + $this->assertEquals(2000, $c->getStartTime()); + } + +} From fbffdf0b441407394f08e1432ea007fccd6702b9 Mon Sep 17 00:00:00 2001 From: marcosQuesada Date: Sat, 2 Feb 2013 17:53:42 +0100 Subject: [PATCH 008/597] Enabled camelCase format to be used on denormalize method, that way camel_case attribute can be used on object as getCamelCase() --- .../Normalizer/GetSetMethodNormalizer.php | 37 +++++++++++++- .../Normalizer/GetSetMethodNormalizerTest.php | 49 ++++++++++++++++++- 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index 63e7a1dea91ef..ae0805b1232d7 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -38,6 +38,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer implements Normal { protected $callbacks = array(); protected $ignoredAttributes = array(); + protected $camelizedAttributes = array(); /** * Set normalization callbacks @@ -66,6 +67,16 @@ public function setIgnoredAttributes(array $ignoredAttributes) $this->ignoredAttributes = $ignoredAttributes; } + /** + * Set attributes to be camelized on denormalize + * + * @param array $camelizedAttributes + */ + public function setCamelizedAttributes(array $camelizedAttributes) + { + $this->camelizedAttributes = $camelizedAttributes; + } + /** * {@inheritdoc} */ @@ -111,7 +122,7 @@ public function denormalize($data, $class, $format = null, array $context = arra $params = array(); foreach ($constructorParameters as $constructorParameter) { - $paramName = lcfirst($constructorParameter->name); + $paramName = lcfirst($this->formatAttribute($constructorParameter->name)); if (isset($data[$paramName])) { $params[] = $data[$paramName]; @@ -132,7 +143,8 @@ public function denormalize($data, $class, $format = null, array $context = arra } foreach ($data as $attribute => $value) { - $setter = 'set'.$attribute; + $setter = 'set'.$this->formatAttribute($attribute); + if (method_exists($object, $setter)) { $object->$setter($value); } @@ -141,6 +153,27 @@ public function denormalize($data, $class, $format = null, array $context = arra return $object; } + /** + * Format attribute name to access parameters or methods + * As option, if attribute name is found on camelizedAttributes array + * returns attribute name in camelcase format + * + * @param string $attribute + * @return string + */ + protected function formatAttribute($attributeName) + { + if (in_array($attributeName, $this->camelizedAttributes)) { + return preg_replace_callback( + '/(^|_|\.)+(.)/', function ($match) { + return ('.' === $match[1] ? '_' : '').strtoupper($match[2]); + }, $attributeName + ); + } + + return $attributeName; + } + /** * {@inheritDoc} */ diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 063753289401a..ea80f64eed8fb 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -26,8 +26,9 @@ public function testNormalize() $obj = new GetSetDummy; $obj->setFoo('foo'); $obj->setBar('bar'); + $obj->setCamelCase('camelcase'); $this->assertEquals( - array('foo' => 'foo', 'bar' => 'bar', 'fooBar' => 'foobar'), + array('foo' => 'foo', 'bar' => 'bar', 'fooBar' => 'foobar', 'camelCase' => 'camelcase'), $this->normalizer->normalize($obj, 'any') ); } @@ -43,6 +44,39 @@ public function testDenormalize() $this->assertEquals('bar', $obj->getBar()); } + public function testDenormalizeOnCamelCaseFormat() + { + $this->normalizer->setCamelizedAttributes(array('camel_case')); + $obj = $this->normalizer->denormalize( + array('camel_case' => 'camelCase'), + __NAMESPACE__.'\GetSetDummy' + ); + $this->assertEquals('camelCase', $obj->getCamelCase()); + } + + /** + * @dataProvider attributeProvider + */ + public function testFormatAttribute($attribute, $camelizedAttributes, $result) + { + $r = new \ReflectionObject($this->normalizer); + $m = $r->getMethod('formatAttribute'); + $m->setAccessible(true); + + $this->normalizer->setCamelizedAttributes($camelizedAttributes); + $this->assertEquals($m->invoke($this->normalizer, $attribute, $camelizedAttributes), $result); + } + + public function attributeProvider() + { + return array( + array('attribute_test', array('attribute_test'),'AttributeTest'), + array('attribute_test', array('any'),'attribute_test'), + array('attribute', array('attribute'),'Attribute'), + array('attribute', array(), 'attribute'), + ); + } + public function testConstructorDenormalize() { $obj = $this->normalizer->denormalize( @@ -82,7 +116,7 @@ public function testUncallableCallbacks() public function testIgnoredAttributes() { - $this->normalizer->setIgnoredAttributes(array('foo', 'bar')); + $this->normalizer->setIgnoredAttributes(array('foo', 'bar', 'camelCase')); $obj = new GetSetDummy; $obj->setFoo('foo'); @@ -160,6 +194,7 @@ class GetSetDummy { protected $foo; private $bar; + protected $camelCase; public function getFoo() { @@ -186,6 +221,16 @@ public function getFooBar() return $this->foo . $this->bar; } + public function getCamelCase() + { + return $this->camelCase; + } + + public function setCamelCase($camelCase) + { + $this->camelCase = $camelCase; + } + public function otherMethod() { throw new \RuntimeException("Dummy::otherMethod() should not be called"); From 5ca04b02fd858e4d275f3f07351c74442bca620a Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 5 Feb 2013 21:55:33 +0000 Subject: [PATCH 009/597] [Console] Cleaned up the unit tests. --- .../Console/Tests/ApplicationTest.php | 144 +++++---- .../Console/Tests/Command/CommandTest.php | 96 +++--- .../Console/Tests/Command/HelpCommandTest.php | 28 +- .../Console/Tests/Command/ListCommandTest.php | 18 +- .../Console/Tests/Input/ArgvInputTest.php | 303 ++++++++++-------- .../Console/Tests/Input/ArrayInputTest.php | 111 ++++--- .../Console/Tests/Input/InputArgumentTest.php | 71 ++-- .../Tests/Input/InputDefinitionTest.php | 183 +++++++---- .../Console/Tests/Input/InputOptionTest.php | 84 ++--- .../Console/Tests/Input/InputTest.php | 92 +++--- .../Console/Tests/Output/OutputTest.php | 54 +++- .../Console/Tests/Output/StreamOutputTest.php | 17 +- 12 files changed, 715 insertions(+), 486 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 23edd490b3658..2d2da94542212 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -129,14 +129,6 @@ public function testHasGet() $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns a command by name'); $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias'); - try { - $application->get('foofoo'); - $this->fail('->get() throws an \InvalidArgumentException if the command does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->get() throws an \InvalidArgumentException if the command does not exist'); - $this->assertEquals('The command "foofoo" does not exist.', $e->getMessage(), '->get() throws an \InvalidArgumentException if the command does not exist'); - } - $application = new Application(); $application->add($foo = new \FooCommand()); // simulate --help @@ -145,7 +137,17 @@ public function testHasGet() $p->setAccessible(true); $p->setValue($application, true); $command = $application->get('foo:bar'); - $this->assertEquals('Symfony\Component\Console\Command\HelpCommand', get_class($command), '->get() returns the help command if --help is provided as the input'); + $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $command, '->get() returns the help command if --help is provided as the input'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The command "foofoo" does not exist. + */ + public function testGetInvalidCommand() + { + $application = new Application(); + $application->get('foofoo'); } public function testGetNamespaces() @@ -164,84 +166,90 @@ public function testFindNamespace() $this->assertEquals('foo', $application->findNamespace('f'), '->findNamespace() finds a namespace given an abbreviation'); $application->add(new \Foo2Command()); $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); - try { - $application->findNamespace('f'); - $this->fail('->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous'); - $this->assertEquals('The namespace "f" is ambiguous (foo, foo1).', $e->getMessage(), '->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous'); - } + } - try { - $application->findNamespace('bar'); - $this->fail('->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace'); - $this->assertEquals('There are no commands defined in the "bar" namespace.', $e->getMessage(), '->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace'); - } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The namespace "f" is ambiguous (foo, foo1). + */ + public function testFindAmbiguousNamespace() + { + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo2Command()); + $application->findNamespace('f'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage There are no commands defined in the "bar" namespace. + */ + public function testFindInvalidNamespace() + { + $application = new Application(); + $application->findNamespace('bar'); } public function testFind() { $application = new Application(); $application->add(new \FooCommand()); - $this->assertEquals('FooCommand', get_class($application->find('foo:bar')), '->find() returns a command if its name exists'); - $this->assertEquals('Symfony\Component\Console\Command\HelpCommand', get_class($application->find('h')), '->find() returns a command if its name exists'); - $this->assertEquals('FooCommand', get_class($application->find('f:bar')), '->find() returns a command if the abbreviation for the namespace exists'); - $this->assertEquals('FooCommand', get_class($application->find('f:b')), '->find() returns a command if the abbreviation for the namespace and the command name exist'); - $this->assertEquals('FooCommand', get_class($application->find('a')), '->find() returns a command if the abbreviation exists for an alias'); + $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists'); + $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $application->find('h'), '->find() returns a command if its name exists'); + $this->assertInstanceOf('FooCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); + $this->assertInstanceOf('FooCommand', $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); + $this->assertInstanceOf('FooCommand', $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); + } + + /** + * @dataProvider provideAmbiguousAbbreviations + */ + public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage) + { + $this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage); + + $application = new Application(); + $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); - try { - $application->find('f'); - $this->fail('->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace'); - $this->assertRegExp('/Command "f" is not defined./', $e->getMessage(), '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace'); - } - - try { - $application->find('a'); - $this->fail('->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias'); - $this->assertEquals('Command "a" is ambiguous (afoobar, afoobar1 and 1 more).', $e->getMessage(), '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias'); - } + $application->find($abbreviation); + } - try { - $application->find('foo:b'); - $this->fail('->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command'); - $this->assertEquals('Command "foo:b" is ambiguous (foo:bar, foo:bar1).', $e->getMessage(), '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command'); - } + public function provideAmbiguousAbbreviations() + { + return array( + array('f', 'Command "f" is not defined.'), + array('a', 'Command "a" is ambiguous (afoobar, afoobar1 and 1 more).'), + array('foo:b', 'Command "foo:b" is ambiguous (foo:bar, foo:bar1).') + ); } - public function testFindAlternativeExceptionMessage() + /** + * @dataProvider provideInvalidCommandNamesSingle + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Did you mean this + */ + public function testFindAlternativeExceptionMessageSingle($name) { $application = new Application(); $application->add(new \FooCommand()); + $application->find($name); + } - // Command + singular - try { - $application->find('foo:baR'); - $this->fail('->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - $this->assertRegExp('/Did you mean this/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - } - - // Namespace + singular - try { - $application->find('foO:bar'); - $this->fail('->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - $this->assertRegExp('/Did you mean this/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - } + public function provideInvalidCommandNamesSingle() + { + return array( + array('foo:baR'), + array('foO:bar') + ); + } + public function testFindAlternativeExceptionMessageMultiple() + { + $application = new Application(); + $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 166ce7879ea30..acbe2ea10ce38 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -35,17 +35,19 @@ public static function setUpBeforeClass() public function testConstructor() { - try { - $command = new Command(); - $this->fail('__construct() throws a \LogicException if the name is null'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '__construct() throws a \LogicException if the name is null'); - $this->assertEquals('The command name cannot be empty.', $e->getMessage(), '__construct() throws a \LogicException if the name is null'); - } $command = new Command('foo:bar'); $this->assertEquals('foo:bar', $command->getName(), '__construct() takes the command name as its first argument'); } + /** + * @expectedException \LogicException + * @expectedExceptionMessage The command name cannot be empty. + */ + public function testCommandNameCannotBeEmpty() + { + new Command(); + } + public function testSetApplication() { $application = new Application(); @@ -92,22 +94,25 @@ public function testGetNamespaceGetNameSetName() $ret = $command->setName('foobar:bar'); $this->assertEquals($command, $ret, '->setName() implements a fluent interface'); $this->assertEquals('foobar:bar', $command->getName(), '->setName() sets the command name'); + } + + /** + * @dataProvider provideInvalidCommandNames + */ + public function testInvalidCommandNames($name) + { + $this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name)); + + $command = new \TestCommand(); + $command->setName($name); + } - try { - $command->setName(''); - $this->fail('->setName() throws an \InvalidArgumentException if the name is empty'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setName() throws an \InvalidArgumentException if the name is empty'); - $this->assertEquals('Command name "" is invalid.', $e->getMessage(), '->setName() throws an \InvalidArgumentException if the name is empty'); - } - - try { - $command->setName('foo:'); - $this->fail('->setName() throws an \InvalidArgumentException if the name is empty'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setName() throws an \InvalidArgumentException if the name is empty'); - $this->assertEquals('Command name "foo:" is invalid.', $e->getMessage(), '->setName() throws an \InvalidArgumentException if the name is empty'); - } + public function provideInvalidCommandNames() + { + return array( + array(''), + array('foo:') + ); } public function testGetSetDescription() @@ -193,32 +198,43 @@ public function testMergeApplicationDefinition() $this->assertEquals(3, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments and options'); } - public function testRun() + public function testRunInteractive() { - $command = new \TestCommand(); - $tester = new CommandTester($command); - try { - $tester->execute(array('--bar' => true)); - $this->fail('->run() throws a \InvalidArgumentException when the input does not validate the current InputDefinition'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->run() throws a \InvalidArgumentException when the input does not validate the current InputDefinition'); - $this->assertEquals('The "--bar" option does not exist.', $e->getMessage(), '->run() throws a \InvalidArgumentException when the input does not validate the current InputDefinition'); - } + $tester = new CommandTester(new \TestCommand()); $tester->execute(array(), array('interactive' => true)); + $this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive'); + } + + public function testRunNonInteractive() + { + $tester = new CommandTester(new \TestCommand()); $tester->execute(array(), array('interactive' => false)); + $this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive'); + } + /** + * @expectedException \LogicException + * @expectedExceptionMessage You must override the execute() method in the concrete command class. + */ + public function testExecuteMethodNeedsToBeOverriden() + { $command = new Command('foo'); - try { - $command->run(new StringInput(''), new NullOutput()); - $this->fail('->run() throws a \LogicException if the execute() method has not been overridden and no code has been provided'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->run() throws a \LogicException if the execute() method has not been overridden and no code has been provided'); - $this->assertEquals('You must override the execute() method in the concrete command class.', $e->getMessage(), '->run() throws a \LogicException if the execute() method has not been overridden and no code has been provided'); - } + $command->run(new StringInput(''), new NullOutput()); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "--bar" option does not exist. + */ + public function testRunWithInvalidOption() + { + $command = new \TestCommand(); + $tester = new CommandTester($command); + $tester->execute(array('--bar' => true)); } public function testRunReturnsAlwaysInteger() @@ -251,7 +267,7 @@ public function testSetCodeWithNonClosureCallable() } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid callable provided to Command::setCode. */ public function testSetCodeWithNonCallable() diff --git a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php index b62973d9d637e..f9b72e6ae385e 100644 --- a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php @@ -18,33 +18,51 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase { - public function testExecute() + public function testExecuteForCommandAlias() { $command = new HelpCommand(); - - $application = new Application(); - $command->setApplication($application); + $command->setApplication(new Application()); $commandTester = new CommandTester($command); $commandTester->execute(array('command_name' => 'li')); + $this->assertRegExp('/list \[--xml\] \[--raw\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); + } + public function testExecuteForCommand() + { $command = new HelpCommand(); - $commandTester = new CommandTester($command); $command->setCommand(new ListCommand()); $commandTester->execute(array()); + $this->assertRegExp('/list \[--xml\] \[--raw\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + } + public function testExecuteForCommandWithXmlOption() + { + $command = new HelpCommand(); + $commandTester = new CommandTester($command); $command->setCommand(new ListCommand()); $commandTester->execute(array('--xml' => true)); + $this->assertRegExp('/getDisplay(), '->execute() returns an XML help text if --xml is passed'); + } + public function testExecuteForApplicationCommand() + { $application = new Application(); $commandTester = new CommandTester($application->get('help')); $commandTester->execute(array('command_name' => 'list')); + $this->assertRegExp('/list \[--xml\] \[--raw\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + } + public function testExecuteForApplicationCommandWithXmlOption() + { + $application = new Application(); + $commandTester = new CommandTester($application->get('help')); $commandTester->execute(array('command_name' => 'list', '--xml' => true)); + $this->assertRegExp('/getDisplay(), '->execute() returns an XML help text if --xml is passed'); } } diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index fb0eaccb0c65d..cad313652c0aa 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -16,23 +16,35 @@ class ListCommandTest extends \PHPUnit_Framework_TestCase { - public function testExecute() + public function testExecuteListsCommands() { $application = new Application(); - $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName()), array('decorated' => false)); + $this->assertRegExp('/help Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands'); + } + public function testExecuteListsCommandsWithXmlOption() + { + $application = new Application(); + $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), '--xml' => true)); + $this->assertRegExp('//', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed'); + } + public function testExecuteListsCommandsWithRawOption() + { + $application = new Application(); + $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), '--raw' => true)); $output = <<assertEquals(str_replace("\n", PHP_EOL, $output), $commandTester->getDisplay(), 'boo'); + + $this->assertEquals(str_replace("\n", PHP_EOL, $output), $commandTester->getDisplay()); } } diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php index fc7ab21834da2..38cc038ea70a3 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -29,7 +29,7 @@ public function testConstructor() $this->assertEquals(array('foo'), $p->getValue($input), '__construct() automatically get its input from the argv server variable'); } - public function testParser() + public function testParseArguments() { $input = new ArgvInput(array('cli.php', 'foo')); $input->bind(new InputDefinition(array(new InputArgument('name')))); @@ -37,142 +37,185 @@ public function testParser() $input->bind(new InputDefinition(array(new InputArgument('name')))); $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() is stateless'); + } - $input = new ArgvInput(array('cli.php', '--foo')); - $input->bind(new InputDefinition(array(new InputOption('foo')))); - $this->assertEquals(array('foo' => true), $input->getOptions(), '->parse() parses long options without a value'); - - $input = new ArgvInput(array('cli.php', '--foo=bar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options with a required value (with a = separator)'); - - $input = new ArgvInput(array('cli.php', '--foo', 'bar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options with a required value (with a space separator)'); - - try { - $input = new ArgvInput(array('cli.php', '--foo')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->fail('->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - $this->assertEquals('The "--foo" option requires a value.', $e->getMessage(), '->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - } - - $input = new ArgvInput(array('cli.php', '-f')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f')))); - $this->assertEquals(array('foo' => true), $input->getOptions(), '->parse() parses short options without a value'); - - $input = new ArgvInput(array('cli.php', '-fbar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options with a required value (with no separator)'); - - $input = new ArgvInput(array('cli.php', '-f', 'bar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options with a required value (with a space separator)'); - - $input = new ArgvInput(array('cli.php', '-f', '')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); - $this->assertEquals(array('foo' => ''), $input->getOptions(), '->parse() parses short options with an optional empty value'); - - $input = new ArgvInput(array('cli.php', '-f', '', 'foo')); - $input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); - $this->assertEquals(array('foo' => ''), $input->getOptions(), '->parse() parses short options with an optional empty value followed by an argument'); - - $input = new ArgvInput(array('cli.php', '-f', '', '-b')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')))); - $this->assertEquals(array('foo' => '', 'bar' => true), $input->getOptions(), '->parse() parses short options with an optional empty value followed by an option'); - - $input = new ArgvInput(array('cli.php', '-f', '-b', 'foo')); - $input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')))); - $this->assertEquals(array('foo' => null, 'bar' => true), $input->getOptions(), '->parse() parses short options with an optional value which is not present'); - - try { - $input = new ArgvInput(array('cli.php', '-f')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->fail('->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - $this->assertEquals('The "--foo" option requires a value.', $e->getMessage(), '->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - } - - try { - $input = new ArgvInput(array('cli.php', '-ffoo')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE)))); - $this->fail('->parse() throws a \RuntimeException if a value is passed to an option which does not take one'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if a value is passed to an option which does not take one'); - $this->assertEquals('The "-o" option does not exist.', $e->getMessage(), '->parse() throws a \RuntimeException if a value is passed to an option which does not take one'); - } - - try { - $input = new ArgvInput(array('cli.php', 'foo', 'bar')); - $input->bind(new InputDefinition()); - $this->fail('->parse() throws a \RuntimeException if too many arguments are passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if too many arguments are passed'); - $this->assertEquals('Too many arguments.', $e->getMessage(), '->parse() throws a \RuntimeException if too many arguments are passed'); - } - - try { - $input = new ArgvInput(array('cli.php', '--foo')); - $input->bind(new InputDefinition()); - $this->fail('->parse() throws a \RuntimeException if an unknown long option is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if an unknown long option is passed'); - $this->assertEquals('The "--foo" option does not exist.', $e->getMessage(), '->parse() throws a \RuntimeException if an unknown long option is passed'); - } - - try { - $input = new ArgvInput(array('cli.php', '-f')); - $input->bind(new InputDefinition()); - $this->fail('->parse() throws a \RuntimeException if an unknown short option is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if an unknown short option is passed'); - $this->assertEquals('The "-f" option does not exist.', $e->getMessage(), '->parse() throws a \RuntimeException if an unknown short option is passed'); - } - - $input = new ArgvInput(array('cli.php', '-fb')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b')))); - $this->assertEquals(array('foo' => true, 'bar' => true), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one'); - - $input = new ArgvInput(array('cli.php', '-fb', 'bar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_REQUIRED)))); - $this->assertEquals(array('foo' => true, 'bar' => 'bar'), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and the last one has a required value'); - - $input = new ArgvInput(array('cli.php', '-fb', 'bar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)))); - $this->assertEquals(array('foo' => true, 'bar' => 'bar'), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and the last one has an optional value'); + /** + * @dataProvider provideOptions + */ + public function testParseOptions($input, $options, $expectedOptions, $message) + { + $input = new ArgvInput($input); + $input->bind(new InputDefinition($options)); - $input = new ArgvInput(array('cli.php', '-fbbar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)))); - $this->assertEquals(array('foo' => true, 'bar' => 'bar'), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and the last one has an optional value with no separator'); + $this->assertEquals($expectedOptions, $input->getOptions(), $message); + } - $input = new ArgvInput(array('cli.php', '-fbbar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)))); - $this->assertEquals(array('foo' => 'bbar', 'bar' => null), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and one of them takes a value'); + public function provideOptions() + { + return array( + array( + array('cli.php', '--foo'), + array(new InputOption('foo')), + array('foo' => true), + '->parse() parses long options without a value' + ), + array( + array('cli.php', '--foo=bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses long options with a required value (with a = separator)' + ), + array( + array('cli.php', '--foo', 'bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses long options with a required value (with a space separator)' + ), + array( + array('cli.php', '-f'), + array(new InputOption('foo', 'f')), + array('foo' => true), + '->parse() parses short options without a value' + ), + array( + array('cli.php', '-fbar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses short options with a required value (with no separator)' + ), + array( + array('cli.php', '-f', 'bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses short options with a required value (with a space separator)' + ), + array( + array('cli.php', '-f', ''), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)), + array('foo' => ''), + '->parse() parses short options with an optional empty value' + ), + array( + array('cli.php', '-f', '', 'foo'), + array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)), + array('foo' => ''), + '->parse() parses short options with an optional empty value followed by an argument' + ), + array( + array('cli.php', '-f', '', '-b'), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')), + array('foo' => '', 'bar' => true), + '->parse() parses short options with an optional empty value followed by an option' + ), + array( + array('cli.php', '-f', '-b', 'foo'), + array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')), + array('foo' => null, 'bar' => true), + '->parse() parses short options with an optional value which is not present' + ), + array( + array('cli.php', '-fb'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b')), + array('foo' => true, 'bar' => true), + '->parse() parses short options when they are aggregated as a single one' + ), + array( + array('cli.php', '-fb', 'bar'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_REQUIRED)), + array('foo' => true, 'bar' => 'bar'), + '->parse() parses short options when they are aggregated as a single one and the last one has a required value' + ), + array( + array('cli.php', '-fb', 'bar'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), + array('foo' => true, 'bar' => 'bar'), + '->parse() parses short options when they are aggregated as a single one and the last one has an optional value' + ), + array( + array('cli.php', '-fbbar'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), + array('foo' => true, 'bar' => 'bar'), + '->parse() parses short options when they are aggregated as a single one and the last one has an optional value with no separator' + ), + array( + array('cli.php', '-fbbar'), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), + array('foo' => 'bbar', 'bar' => null), + '->parse() parses short options when they are aggregated as a single one and one of them takes a value' + ) + ); + } + + /** + * @dataProvider provideInvalidInput + */ + public function testInvalidInput($argv, $definition, $expectedExceptionMessage) + { + $this->setExpectedException('RuntimeException', $expectedExceptionMessage); + + $input = new ArgvInput($argv); + $input->bind($definition); + } - try { - $input = new ArgvInput(array('cli.php', 'foo', 'bar', 'baz', 'bat')); - $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::IS_ARRAY)))); - $this->assertEquals(array('name' => array('foo', 'bar', 'baz', 'bat')), $input->getArguments(), '->parse() parses array arguments'); - } catch (\RuntimeException $e) { - $this->assertNotEquals('Too many arguments.', $e->getMessage(), '->parse() parses array arguments'); - } + public function provideInvalidInput() + { + return array( + array( + array('cli.php', '--foo'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), + 'The "--foo" option requires a value.' + ), + array( + array('cli.php', '-f'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), + 'The "--foo" option requires a value.' + ), + array( + array('cli.php', '-ffoo'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE))), + 'The "-o" option does not exist.' + ), + array( + array('cli.php', 'foo', 'bar'), + new InputDefinition(), + 'Too many arguments.' + ), + array( + array('cli.php', '--foo'), + new InputDefinition(), + 'The "--foo" option does not exist.' + ), + array( + array('cli.php', '-f'), + new InputDefinition(), + 'The "-f" option does not exist.' + ), + array( + array('cli.php', '-1'), + new InputDefinition(array(new InputArgument('number'))), + 'The "-1" option does not exist.' + ) + ); + } + + public function testParseArrayArgument() + { + $input = new ArgvInput(array('cli.php', 'foo', 'bar', 'baz', 'bat')); + $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::IS_ARRAY)))); + + $this->assertEquals(array('name' => array('foo', 'bar', 'baz', 'bat')), $input->getArguments(), '->parse() parses array arguments'); + } + public function testParseArrayOption() + { $input = new ArgvInput(array('cli.php', '--name=foo', '--name=bar', '--name=baz')); $input->bind(new InputDefinition(array(new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY)))); - $this->assertEquals(array('name' => array('foo', 'bar', 'baz')), $input->getOptions()); - try { - $input = new ArgvInput(array('cli.php', '-1')); - $input->bind(new InputDefinition(array(new InputArgument('number')))); - $this->fail('->parse() throws a \RuntimeException if an unknown option is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() parses arguments with leading dashes as options without having encountered a double-dash sequence'); - $this->assertEquals('The "-1" option does not exist.', $e->getMessage(), '->parse() parses arguments with leading dashes as options without having encountered a double-dash sequence'); - } + $this->assertEquals(array('name' => array('foo', 'bar', 'baz')), $input->getOptions()); + } + public function testParseNegativeNumberAfterDoubleDash() + { $input = new ArgvInput(array('cli.php', '--', '-1')); $input->bind(new InputDefinition(array(new InputArgument('number')))); $this->assertEquals(array('number' => '-1'), $input->getArguments(), '->parse() parses arguments with leading dashes as arguments after having encountered a double-dash sequence'); @@ -181,9 +224,13 @@ public function testParser() $input->bind(new InputDefinition(array(new InputArgument('number'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses arguments with leading dashes as options before having encountered a double-dash sequence'); $this->assertEquals(array('number' => '-1'), $input->getArguments(), '->parse() parses arguments with leading dashes as arguments after having encountered a double-dash sequence'); + } + public function testParseEmptyStringArgument() + { $input = new ArgvInput(array('cli.php', '-f', 'bar', '')); $input->bind(new InputDefinition(array(new InputArgument('empty'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); + $this->assertEquals(array('empty' => ''), $input->getArguments(), '->parse() parses empty string arguments'); } diff --git a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php index 82f477ef8e31e..e1838a721e926 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php @@ -38,53 +38,86 @@ public function testHasParameterOption() $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters'); } - public function testParse() + public function testParseArguments() { $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); - $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() parses required arguments'); - - try { - $input = new ArrayInput(array('foo' => 'foo'), new InputDefinition(array(new InputArgument('name')))); - $this->fail('->parse() throws an \InvalidArgumentException exception if an invalid argument is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid argument is passed'); - $this->assertEquals('The "foo" argument does not exist.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if an invalid argument is passed'); - } - $input = new ArrayInput(array('--foo' => 'bar'), new InputDefinition(array(new InputOption('foo')))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options'); + $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() parses required arguments'); + } - $input = new ArrayInput(array('--foo' => 'bar'), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options with a default value'); + /** + * @dataProvider provideOptions + */ + public function testParseOptions($input, $options, $expectedOptions, $message) + { + $input = new ArrayInput($input, new InputDefinition($options)); - $input = new ArrayInput(array('--foo' => null), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')))); - $this->assertEquals(array('foo' => 'default'), $input->getOptions(), '->parse() parses long options with a default value'); + $this->assertEquals($expectedOptions, $input->getOptions(), $message); + } - try { - $input = new ArrayInput(array('--foo' => null), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->fail('->parse() throws an \InvalidArgumentException exception if a required option is passed without a value'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if a required option is passed without a value'); - $this->assertEquals('The "--foo" option requires a value.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if a required option is passed without a value'); - } + public function provideOptions() + { + return array( + array( + array('--foo' => 'bar'), + array(new InputOption('foo')), + array('foo' => 'bar'), + '->parse() parses long options' + ), + array( + array('--foo' => 'bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')), + array('foo' => 'bar'), + '->parse() parses long options with a default value' + ), + array( + array('--foo' => null), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')), + array('foo' => 'default'), + '->parse() parses long options with a default value' + ), + array( + array('-f' => 'bar'), + array(new InputOption('foo', 'f')), + array('foo' => 'bar'), + '->parse() parses short options' + ) + ); + } - try { - $input = new ArrayInput(array('--foo' => 'foo'), new InputDefinition()); - $this->fail('->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - $this->assertEquals('The "--foo" option does not exist.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - } + /** + * @dataProvider provideInvalidInput + */ + public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage) + { + $this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage); - $input = new ArrayInput(array('-f' => 'bar'), new InputDefinition(array(new InputOption('foo', 'f')))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options'); + new ArrayInput($parameters, $definition); + } - try { - $input = new ArrayInput(array('-o' => 'foo'), new InputDefinition()); - $this->fail('->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - $this->assertEquals('The "-o" option does not exist.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - } + public function provideInvalidInput() + { + return array( + array( + array('foo' => 'foo'), + new InputDefinition(array(new InputArgument('name'))), + 'The "foo" argument does not exist.' + ), + array( + array('--foo' => null), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), + 'The "--foo" option requires a value.' + ), + array( + array('--foo' => 'foo'), + new InputDefinition(), + 'The "--foo" option does not exist.' + ), + array( + array('-o' => 'foo'), + new InputDefinition(), + 'The "-o" option does not exist.' + ) + ); } } diff --git a/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php b/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php index 1d3144f6288ef..3bfc796696a9a 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php @@ -19,8 +19,10 @@ public function testConstructor() { $argument = new InputArgument('foo'); $this->assertEquals('foo', $argument->getName(), '__construct() takes a name as its first argument'); + } - // mode argument + public function testModes() + { $argument = new InputArgument('foo'); $this->assertFalse($argument->isRequired(), '__construct() gives a "InputArgument::OPTIONAL" mode by default'); @@ -32,21 +34,24 @@ public function testConstructor() $argument = new InputArgument('foo', InputArgument::REQUIRED); $this->assertTrue($argument->isRequired(), '__construct() can take "InputArgument::REQUIRED" as its mode'); + } + + /** + * @dataProvider provideInvalidModes + */ + public function testInvalidModes($mode) + { + $this->setExpectedException('InvalidArgumentException', sprintf('Argument mode "%s" is not valid.', $mode)); + + new InputArgument('foo', $mode); + } - try { - $argument = new InputArgument('foo', 'ANOTHER_ONE'); - $this->fail('__construct() throws an \InvalidArgumentException if the mode is not valid'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the mode is not valid'); - $this->assertEquals('Argument mode "ANOTHER_ONE" is not valid.', $e->getMessage()); - } - try { - $argument = new InputArgument('foo', -1); - $this->fail('__construct() throws an \InvalidArgumentException if the mode is not valid'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the mode is not valid'); - $this->assertEquals('Argument mode "-1" is not valid.', $e->getMessage()); - } + public function provideInvalidModes() + { + return array( + array('ANOTHER_ONE'), + array(-1) + ); } public function testIsArray() @@ -82,23 +87,25 @@ public function testSetDefault() $argument = new InputArgument('foo', InputArgument::OPTIONAL | InputArgument::IS_ARRAY); $argument->setDefault(array(1, 2)); $this->assertEquals(array(1, 2), $argument->getDefault(), '->setDefault() changes the default value'); + } - try { - $argument = new InputArgument('foo', InputArgument::REQUIRED); - $argument->setDefault('default'); - $this->fail('->setDefault() throws a \LogicException if you give a default value for a required argument'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException exception if an invalid option is passed'); - $this->assertEquals('Cannot set a default value except for InputArgument::OPTIONAL mode.', $e->getMessage()); - } - - try { - $argument = new InputArgument('foo', InputArgument::IS_ARRAY); - $argument->setDefault('default'); - $this->fail('->setDefault() throws a \LogicException if you give a default value which is not an array for a IS_ARRAY option'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException if you give a default value which is not an array for a IS_ARRAY option'); - $this->assertEquals('A default value for an array argument must be an array.', $e->getMessage()); - } + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot set a default value except for InputArgument::OPTIONAL mode. + */ + public function testSetDefaultWithRequiredArgument() + { + $argument = new InputArgument('foo', InputArgument::REQUIRED); + $argument->setDefault('default'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage A default value for an array argument must be an array. + */ + public function testSetDefaultWithArrayArgument() + { + $argument = new InputArgument('foo', InputArgument::IS_ARRAY); + $argument->setDefault('default'); } } diff --git a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php index c322ed42bca68..76316bd863f68 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php @@ -26,7 +26,7 @@ public static function setUpBeforeClass() self::$fixtures = __DIR__.'/../Fixtures/'; } - public function testConstructor() + public function testConstructorArguments() { $this->initializeArguments(); @@ -35,7 +35,10 @@ public function testConstructor() $definition = new InputDefinition(array($this->foo, $this->bar)); $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '__construct() takes an array of InputArgument objects as its first argument'); + } + public function testConstructorOptions() + { $this->initializeOptions(); $definition = new InputDefinition(); @@ -77,36 +80,45 @@ public function testAddArgument() $this->assertEquals(array('foo' => $this->foo), $definition->getArguments(), '->addArgument() adds a InputArgument object'); $definition->addArgument($this->bar); $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '->addArgument() adds a InputArgument object'); + } - // arguments must have different names - try { - $definition->addArgument($this->foo1); - $this->fail('->addArgument() throws a \LogicException if another argument is already registered with the same name'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->addArgument() throws a \LogicException if another argument is already registered with the same name'); - $this->assertEquals('An argument with name "foo" already exists.', $e->getMessage()); - } + /** + * @expectedException \LogicException + * @expectedExceptionMessage An argument with name "foo" already exists. + */ + public function testArgumentsMustHaveDifferentNames() + { + $this->initializeArguments(); - // cannot add a parameter after an array parameter + $definition = new InputDefinition(); + $definition->addArgument($this->foo); + $definition->addArgument($this->foo1); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot add an argument after an array argument. + */ + public function testArrayArgumentHasToBeLast() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); $definition->addArgument(new InputArgument('fooarray', InputArgument::IS_ARRAY)); - try { - $definition->addArgument(new InputArgument('anotherbar')); - $this->fail('->addArgument() throws a \LogicException if there is an array parameter already registered'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->addArgument() throws a \LogicException if there is an array parameter already registered'); - $this->assertEquals('Cannot add an argument after an array argument.', $e->getMessage()); - } - - // cannot add a required argument after an optional one + $definition->addArgument(new InputArgument('anotherbar')); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot add a required argument after an optional one. + */ + public function testRequiredArgumentCannotFollowAnOptionalOne() + { + $this->initializeArguments(); + $definition = new InputDefinition(); $definition->addArgument($this->foo); - try { - $definition->addArgument($this->foo2); - $this->fail('->addArgument() throws a \LogicException if you try to add a required argument after an optional one'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->addArgument() throws a \LogicException if you try to add a required argument after an optional one'); - $this->assertEquals('Cannot add a required argument after an optional one.', $e->getMessage()); - } + $definition->addArgument($this->foo2); } public function testGetArgument() @@ -116,13 +128,19 @@ public function testGetArgument() $definition = new InputDefinition(); $definition->addArguments(array($this->foo)); $this->assertEquals($this->foo, $definition->getArgument('foo'), '->getArgument() returns a InputArgument by its name'); - try { - $definition->getArgument('bar'); - $this->fail('->getArgument() throws an \InvalidArgumentException if the InputArgument name does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->getArgument() throws an \InvalidArgumentException if the InputArgument name does not exist'); - $this->assertEquals('The "bar" argument does not exist.', $e->getMessage()); - } + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "bar" argument does not exist. + */ + public function testGetInvalidArgument() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArguments(array($this->foo)); + $definition->getArgument('bar'); } public function testHasArgument() @@ -131,6 +149,7 @@ public function testHasArgument() $definition = new InputDefinition(); $definition->addArguments(array($this->foo)); + $this->assertTrue($definition->hasArgument('foo'), '->hasArgument() returns true if a InputArgument exists for the given name'); $this->assertFalse($definition->hasArgument('bar'), '->hasArgument() returns false if a InputArgument exists for the given name'); } @@ -181,13 +200,19 @@ public function testSetOptions() $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->setOptions() sets the array of InputOption objects'); $definition->setOptions(array($this->bar)); $this->assertEquals(array('bar' => $this->bar), $definition->getOptions(), '->setOptions() clears all InputOption objects'); - try { - $definition->getOptionForShortcut('f'); - $this->fail('->setOptions() clears all InputOption objects'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOptions() clears all InputOption objects'); - $this->assertEquals('The "-f" option does not exist.', $e->getMessage()); - } + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "-f" option does not exist. + */ + public function testSetOptionsClearsOptions() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $definition->setOptions(array($this->bar)); + $definition->getOptionForShortcut('f'); } public function testAddOptions() @@ -209,20 +234,32 @@ public function testAddOption() $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->addOption() adds a InputOption object'); $definition->addOption($this->bar); $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '->addOption() adds a InputOption object'); - try { - $definition->addOption($this->foo2); - $this->fail('->addOption() throws a \LogicException if the another option is already registered with the same name'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->addOption() throws a \LogicException if the another option is already registered with the same name'); - $this->assertEquals('An option named "foo" already exists.', $e->getMessage()); - } - try { - $definition->addOption($this->foo1); - $this->fail('->addOption() throws a \LogicException if the another option is already registered with the same shortcut'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->addOption() throws a \LogicException if the another option is already registered with the same shortcut'); - $this->assertEquals('An option with shortcut "f" already exists.', $e->getMessage()); - } + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage An option named "foo" already exists. + */ + public function testAddDuplicateOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(); + $definition->addOption($this->foo); + $definition->addOption($this->foo2); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage An option with shortcut "f" already exists. + */ + public function testAddDuplicateShortcutOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(); + $definition->addOption($this->foo); + $definition->addOption($this->foo1); } public function testGetOption() @@ -231,13 +268,18 @@ public function testGetOption() $definition = new InputDefinition(array($this->foo)); $this->assertEquals($this->foo, $definition->getOption('foo'), '->getOption() returns a InputOption by its name'); - try { - $definition->getOption('bar'); - $this->fail('->getOption() throws an \InvalidArgumentException if the option name does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->getOption() throws an \InvalidArgumentException if the option name does not exist'); - $this->assertEquals('The "--bar" option does not exist.', $e->getMessage()); - } + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "--bar" option does not exist. + */ + public function testGetInvalidOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $definition->getOption('bar'); } public function testHasOption() @@ -264,13 +306,18 @@ public function testGetOptionForShortcut() $definition = new InputDefinition(array($this->foo)); $this->assertEquals($this->foo, $definition->getOptionForShortcut('f'), '->getOptionForShortcut() returns a InputOption by its shortcut'); - try { - $definition->getOptionForShortcut('l'); - $this->fail('->getOption() throws an \InvalidArgumentException if the shortcut does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->getOption() throws an \InvalidArgumentException if the shortcut does not exist'); - $this->assertEquals('The "-l" option does not exist.', $e->getMessage()); - } + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "-l" option does not exist. + */ + public function testGetOptionForInvalidShortcut() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $definition->getOptionForShortcut('l'); } public function testGetOptionDefaults() diff --git a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php index 1e0de35e3f755..b50c090484070 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php @@ -21,24 +21,29 @@ public function testConstructor() $this->assertEquals('foo', $option->getName(), '__construct() takes a name as its first argument'); $option = new InputOption('--foo'); $this->assertEquals('foo', $option->getName(), '__construct() removes the leading -- of the option name'); + } - try { - $option = new InputOption('foo', 'f', InputOption::VALUE_IS_ARRAY); - $this->fail('__construct() throws an \InvalidArgumentException if VALUE_IS_ARRAY option is used when an option does not accept a value'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if VALUE_IS_ARRAY option is used when an option does not accept a value'); - $this->assertEquals('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.', $e->getMessage()); - } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value. + */ + public function testArrayModeWithoutValue() + { + new InputOption('foo', 'f', InputOption::VALUE_IS_ARRAY); + } - // shortcut argument + public function testShortcut() + { $option = new InputOption('foo', 'f'); $this->assertEquals('f', $option->getShortcut(), '__construct() can take a shortcut as its second argument'); $option = new InputOption('foo', '-f'); $this->assertEquals('f', $option->getShortcut(), '__construct() removes the leading - of the shortcut'); $option = new InputOption('foo'); $this->assertNull($option->getShortcut(), '__construct() makes the shortcut null by default'); + } - // mode argument + public function testModes() + { $option = new InputOption('foo', 'f'); $this->assertFalse($option->acceptValue(), '__construct() gives a "InputOption::VALUE_NONE" mode by default'); $this->assertFalse($option->isValueRequired(), '__construct() gives a "InputOption::VALUE_NONE" mode by default'); @@ -63,21 +68,24 @@ public function testConstructor() $this->assertTrue($option->acceptValue(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); $this->assertFalse($option->isValueRequired(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); $this->assertTrue($option->isValueOptional(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); + } + + /** + * @dataProvider provideInvalidModes + */ + public function testInvalidModes($mode) + { + $this->setExpectedException('InvalidArgumentException', sprintf('Option mode "%s" is not valid.', $mode)); + + new InputOption('foo', 'f', $mode); + } - try { - $option = new InputOption('foo', 'f', 'ANOTHER_ONE'); - $this->fail('__construct() throws an \InvalidArgumentException if the mode is not valid'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the mode is not valid'); - $this->assertEquals('Option mode "ANOTHER_ONE" is not valid.', $e->getMessage()); - } - try { - $option = new InputOption('foo', 'f', -1); - $this->fail('__construct() throws an \InvalidArgumentException if the mode is not valid'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the mode is not valid'); - $this->assertEquals('Option mode "-1" is not valid.', $e->getMessage()); - } + public function provideInvalidModes() + { + return array( + array('ANOTHER_ONE'), + array(-1) + ); } /** @@ -147,24 +155,26 @@ public function testSetDefault() $option = new InputOption('foo', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY); $option->setDefault(array(1, 2)); $this->assertEquals(array(1, 2), $option->getDefault(), '->setDefault() changes the default value'); + } + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot set a default value when using InputOption::VALUE_NONE mode. + */ + public function testDefaultValueWithValueNoneMode() + { $option = new InputOption('foo', 'f', InputOption::VALUE_NONE); - try { - $option->setDefault('default'); - $this->fail('->setDefault() throws a \LogicException if you give a default value for a VALUE_NONE option'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException if you give a default value for a VALUE_NONE option'); - $this->assertEquals('Cannot set a default value when using InputOption::VALUE_NONE mode.', $e->getMessage()); - } + $option->setDefault('default'); + } + /** + * @expectedException \LogicException + * @expectedExceptionMessage A default value for an array option must be an array. + */ + public function testDefaultValueWithIsArrayMode() + { $option = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY); - try { - $option->setDefault('default'); - $this->fail('->setDefault() throws a \LogicException if you give a default value which is not an array for a VALUE_IS_ARRAY option'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException if you give a default value which is not an array for a VALUE_IS_ARRAY option'); - $this->assertEquals('A default value for an array option must be an array.', $e->getMessage()); - } + $option->setDefault('default'); } public function testEquals() diff --git a/src/Symfony/Component/Console/Tests/Input/InputTest.php b/src/Symfony/Component/Console/Tests/Input/InputTest.php index 2863ea4f34618..0b3e38fb6f4ce 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputTest.php @@ -36,22 +36,26 @@ public function testOptions() $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')))); $this->assertEquals('default', $input->getOption('bar'), '->getOption() returns the default value for optional options'); $this->assertEquals(array('name' => 'foo', 'bar' => 'default'), $input->getOptions(), '->getOptions() returns all option values, even optional ones'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" option does not exist. + */ + public function testSetInvalidOption() + { + $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')))); + $input->setOption('foo', 'bar'); + } - try { - $input->setOption('foo', 'bar'); - $this->fail('->setOption() throws a \InvalidArgumentException if the option does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws a \InvalidArgumentException if the option does not exist'); - $this->assertEquals('The "foo" option does not exist.', $e->getMessage()); - } - - try { - $input->getOption('foo'); - $this->fail('->getOption() throws a \InvalidArgumentException if the option does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws a \InvalidArgumentException if the option does not exist'); - $this->assertEquals('The "foo" option does not exist.', $e->getMessage()); - } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" option does not exist. + */ + public function testGetInvalidOption() + { + $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')))); + $input->getOption('foo'); } public function testArguments() @@ -66,45 +70,45 @@ public function testArguments() $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); $this->assertEquals('default', $input->getArgument('bar'), '->getArgument() returns the default value for optional arguments'); $this->assertEquals(array('name' => 'foo', 'bar' => 'default'), $input->getArguments(), '->getArguments() returns all argument values, even optional ones'); + } - try { - $input->setArgument('foo', 'bar'); - $this->fail('->setArgument() throws a \InvalidArgumentException if the argument does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws a \InvalidArgumentException if the option does not exist'); - $this->assertEquals('The "foo" argument does not exist.', $e->getMessage()); - } - - try { - $input->getArgument('foo'); - $this->fail('->getArgument() throws a \InvalidArgumentException if the argument does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws a \InvalidArgumentException if the option does not exist'); - $this->assertEquals('The "foo" argument does not exist.', $e->getMessage()); - } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" argument does not exist. + */ + public function testSetInvalidArgument() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); + $input->setArgument('foo', 'bar'); } - public function testValidate() + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" argument does not exist. + */ + public function testGetInvalidArgument() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); + $input->getArgument('foo'); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage Not enough arguments. + */ + public function testValidateWithMissingArguments() { $input = new ArrayInput(array()); $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); + $input->validate(); + } - try { - $input->validate(); - $this->fail('->validate() throws a \RuntimeException if not enough arguments are given'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->validate() throws a \RuntimeException if not enough arguments are given'); - $this->assertEquals('Not enough arguments.', $e->getMessage()); - } - + public function testValidate() + { $input = new ArrayInput(array('name' => 'foo')); $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); - try { - $input->validate(); - } catch (\RuntimeException $e) { - $this->fail('->validate() does not throw a \RuntimeException if enough arguments are given'); - } + $this->assertNull($input->validate()); } public function testSetGetInteractive() diff --git a/src/Symfony/Component/Console/Tests/Output/OutputTest.php b/src/Symfony/Component/Console/Tests/Output/OutputTest.php index aa4a2046b8bf9..be58b72d3c248 100644 --- a/src/Symfony/Component/Console/Tests/Output/OutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/OutputTest.php @@ -37,43 +37,69 @@ public function testSetGetVerbosity() $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '->setVerbosity() sets the verbosity'); } - public function testWrite() + public function testWriteWithVerbosityQuiet() { - $fooStyle = new OutputFormatterStyle('yellow', 'red', array('blink')); $output = new TestOutput(Output::VERBOSITY_QUIET); $output->writeln('foo'); $this->assertEquals('', $output->output, '->writeln() outputs nothing if verbosity is set to VERBOSITY_QUIET'); + } + public function testWriteAnArrayOfMessages() + { $output = new TestOutput(); $output->writeln(array('foo', 'bar')); $this->assertEquals("foo\nbar\n", $output->output, '->writeln() can take an array of messages to output'); + } + /** + * @dataProvider provideWriteArguments + */ + public function testWriteRawMessage($message, $type, $expectedOutput) + { $output = new TestOutput(); - $output->writeln('foo', Output::OUTPUT_RAW); - $this->assertEquals("foo\n", $output->output, '->writeln() outputs the raw message if OUTPUT_RAW is specified'); + $output->writeln($message, $type); + $this->assertEquals($expectedOutput, $output->output); + } - $output = new TestOutput(); - $output->writeln('foo', Output::OUTPUT_PLAIN); - $this->assertEquals("foo\n", $output->output, '->writeln() strips decoration tags if OUTPUT_PLAIN is specified'); + public function provideWriteArguments() + { + return array( + array('foo', Output::OUTPUT_RAW, "foo\n"), + array('foo', Output::OUTPUT_PLAIN, "foo\n"), + ); + } + public function testWriteWithDecorationTurnedOff() + { $output = new TestOutput(); $output->setDecorated(false); $output->writeln('foo'); $this->assertEquals("foo\n", $output->output, '->writeln() strips decoration tags if decoration is set to false'); + } + public function testWriteDecoratedMessage() + { + $fooStyle = new OutputFormatterStyle('yellow', 'red', array('blink')); $output = new TestOutput(); $output->getFormatter()->setStyle('FOO', $fooStyle); $output->setDecorated(true); $output->writeln('foo'); $this->assertEquals("\033[33;41;5mfoo\033[0m\n", $output->output, '->writeln() decorates the output'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Unknown output type given (24) + */ + public function testWriteWithInvalidOutputType() + { + $output = new TestOutput(); + $output->writeln('foo', 24); + } - try { - $output->writeln('foo', 24); - $this->fail('->writeln() throws an \InvalidArgumentException when the type does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->writeln() throws an \InvalidArgumentException when the type does not exist'); - $this->assertEquals('Unknown output type given (24)', $e->getMessage()); - } + public function testWriteWithInvalidStyle() + { + $output = new TestOutput(); $output->clear(); $output->write('foo'); diff --git a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php index b151a486df27c..2fd4f612142e8 100644 --- a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php @@ -30,19 +30,20 @@ protected function tearDown() public function testConstructor() { - try { - $output = new StreamOutput('foo'); - $this->fail('__construct() throws an \InvalidArgumentException if the first argument is not a stream'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the first argument is not a stream'); - $this->assertEquals('The StreamOutput class needs a stream as its first argument.', $e->getMessage()); - } - $output = new StreamOutput($this->stream, Output::VERBOSITY_QUIET, true); $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); $this->assertTrue($output->isDecorated(), '__construct() takes the decorated flag as its second argument'); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The StreamOutput class needs a stream as its first argument. + */ + public function testStreamIsRequired() + { + new StreamOutput('foo'); + } + public function testGetStream() { $output = new StreamOutput($this->stream); From ed58e362f77cad12969ac5a3d78a994728332fc2 Mon Sep 17 00:00:00 2001 From: Bilal Amarni Date: Thu, 7 Feb 2013 17:01:11 +0100 Subject: [PATCH 010/597] [HttpKernel] CLI - don't always display errors --- src/Symfony/Component/HttpKernel/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 46440a3468717..1587ba8039a55 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -105,7 +105,7 @@ public function init() ErrorHandler::register($this->errorReportingLevel); if ('cli' !== php_sapi_name()) { ExceptionHandler::register(); - } else { + } elseif (!ini_get('log_errors') || ini_get('error_log')) { ini_set('display_errors', 1); } } From bf9a483b3e1a00121fae55bd6e0f1ecbf4fffb71 Mon Sep 17 00:00:00 2001 From: Lee McDermott Date: Thu, 7 Feb 2013 22:33:28 +0000 Subject: [PATCH 011/597] CSS3, HTML5 cleanuos --- .../Resources/views/Collector/config.html.twig | 8 ++++---- .../Resources/views/Collector/events.html.twig | 2 +- .../Resources/views/Collector/exception.css.twig | 4 ---- .../Resources/views/Collector/exception.html.twig | 4 ++-- .../Resources/views/Collector/logger.html.twig | 12 ++++++------ .../Resources/views/Collector/memory.html.twig | 2 +- .../Resources/views/Collector/request.html.twig | 4 ++-- .../Resources/views/Collector/router.html.twig | 2 +- .../Resources/views/Collector/time.html.twig | 10 +++++----- .../Resources/views/Profiler/admin.html.twig | 6 +++--- .../Resources/views/Profiler/base.html.twig | 12 ++++++------ .../Resources/views/Profiler/base_js.html.twig | 2 +- .../Resources/views/Profiler/body.css.twig | 2 -- .../Resources/views/Profiler/header.html.twig | 6 +++--- .../Resources/views/Profiler/layout.html.twig | 4 ++-- .../Resources/views/Profiler/profiler.css.twig | 8 -------- .../Resources/views/Profiler/search.html.twig | 12 ++++++------ .../Resources/views/Profiler/toolbar.css.twig | 6 +----- .../Resources/views/Profiler/toolbar.html.twig | 4 ++-- .../Resources/views/Profiler/toolbar_js.html.twig | 2 +- 20 files changed, 47 insertions(+), 65 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index dc4eb861b9daa..9e8558a8b0c31 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -4,7 +4,7 @@ {# Symfony Logo #} {% set icon %} - Symfony + Symfony {{ collector.symfonyversion }} {% endset %} @@ -21,7 +21,7 @@ {# PHP Information #} {% set icon %} - PHP + PHP {% endset %} {% set text %} @@ -46,7 +46,7 @@ {# Environment #} {% set debug_status_class %}sf-toolbar-status sf-toolbar-status-{{ collector.debug ? 'green' : 'red' }}{% endset %} {% set icon %} - Environment + Environment {{ token }} @@ -84,7 +84,7 @@ {% block menu %} - Configuration + Configuration Config {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig index 50bd06f960699..6072ff69f2fe3 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig @@ -4,7 +4,7 @@ {% block menu %} - Events + Events Events {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig index bfd9094f30483..1224081bd600a 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig @@ -29,8 +29,6 @@ margin: 10px 0 20px; } .sf-reset .block-exception { - -moz-border-radius: 16px; - -webkit-border-radius: 16px; border-radius: 16px; margin-bottom: 20px; background-color: #f6f6f6; @@ -86,8 +84,6 @@ .sf-reset .error-count span { display: inline-block; background-color: #aacd4e; - -moz-border-radius: 6px; - -webkit-border-radius: 6px; border-radius: 6px; padding: 4px; color: white; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig index 273749ffd6db3..121a9ee5d6964 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig @@ -2,7 +2,7 @@ {% block head %} {% if collector.hasexception %} - {% endif %} @@ -11,7 +11,7 @@ {% block menu %} - Exception + Exception Exception {% if collector.hasexception %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig index fbba52f36f1b6..7523bf2714908 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig @@ -5,7 +5,7 @@ {% block toolbar %} {% if collector.counterrors or collector.countdeprecations %} {% set icon %} - Logs + Logs {% if collector.counterrors %} {% set status_color = "red" %} {% else %} @@ -34,7 +34,7 @@ {% block menu %} - Logger + Logger Logs {% if collector.counterrors or collector.countdeprecations %} {% set error_count = collector.counterrors + collector.countdeprecations %} @@ -55,7 +55,7 @@ Filter
- +
@@ -94,8 +94,8 @@ DEPRECATION - {{ log.message }} {% set id = 'sf-call-stack-' ~ log_index %} - - + + + + {% for index, call in log.context.stack if index > 1 %} {% if index == 2 %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig index 2b6dc69978af7..7567eb935f28e 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig @@ -3,7 +3,7 @@ {% block toolbar %} {% set icon %} - Memory Usage + Memory Usage {{ '%.1f'|format(collector.memory / 1024 / 1024) }} MB {% endset %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig index 4fc3dd9d2f2ac..b1c19e6a66ce2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig @@ -15,7 +15,7 @@ {% set request_status_code_color = (400 > collector.statuscode) ? ((200 == collector.statuscode) ? 'green' : 'yellow') : 'red'%} {% set request_route = collector.route ? collector.route : 'NONE' %} {% set icon %} - Request + Request {{ collector.statuscode }} {{ request_handler }} on {{ request_route }} @@ -45,7 +45,7 @@ {% block menu %} - Request + Request Request {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig index 1e1f3287d5899..782465dc61b80 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig @@ -5,7 +5,7 @@ {% block menu %} - Routing + Routing Routing {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig index b8853213f3bfc..f273651ead6ad 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig @@ -18,7 +18,7 @@ {% block toolbar %} {% set duration = collector.events|length ? '%.0f ms'|format(collector.duration) : 'n/a' %} {% set icon %} - Time + Time {{ duration }} {% endset %} {% set text %} @@ -32,7 +32,7 @@ {% block menu %} - Timeline + Timeline Timeline {% endblock %} @@ -50,7 +50,7 @@ {% block panelContent %}
- + @@ -62,7 +62,7 @@ - +
Total time
Threshold ms ms
@@ -93,7 +93,7 @@ {% endfor %} {% endif %} -