diff --git a/.github/build-packages.php b/.github/build-packages.php
index ec629998f600d..02a2239732be2 100644
--- a/.github/build-packages.php
+++ b/.github/build-packages.php
@@ -43,16 +43,20 @@
echo "Missing \"dev-master\" branch-alias in composer.json extra.\n";
exit(1);
}
- $package->version = str_replace('-dev', '.999', $package->extra->{'branch-alias'}->{'dev-master'});
+ $package->version = str_replace('-dev', '.x-dev', $package->extra->{'branch-alias'}->{'dev-master'});
$package->dist['type'] = 'tar';
$package->dist['url'] = 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__))."/$dir/package.tar";
$packages[$package->name][$package->version] = $package;
$versions = file_get_contents('https://packagist.org/packages/'.$package->name.'.json');
- $versions = json_decode($versions);
+ $versions = json_decode($versions)->package->versions;
- foreach ($versions->package->versions as $v => $package) {
+ if ($package->version === str_replace('-dev', '.x-dev', $versions->{'dev-master'}->extra->{'branch-alias'}->{'dev-master'})) {
+ unset($versions->{'dev-master'});
+ }
+
+ foreach ($versions as $v => $package) {
$packages[$package->name] += array($v => $package);
}
}
diff --git a/.php_cs b/.php_cs.dist
similarity index 79%
rename from .php_cs
rename to .php_cs.dist
index 77701dd97db39..5f37bb77f694c 100644
--- a/.php_cs
+++ b/.php_cs.dist
@@ -1,15 +1,17 @@
setUsingLinter(false)
- ->setUsingCache(true)
- ->fixers(array(
- 'long_array_syntax',
- 'php_unit_construct',
- 'php_unit_dedicate_assert',
+return PhpCsFixer\Config::create()
+ ->setRules(array(
+ '@Symfony' => true,
+ '@Symfony:risky' => true,
+ 'array_syntax' => array('syntax' => 'long'),
+ 'no_unreachable_default_argument_value' => false,
+ 'braces' => array('allow_single_line_closure' => true),
+ 'heredoc_to_nowdoc' => false,
))
- ->finder(
- Symfony\CS\Finder\DefaultFinder::create()
+ ->setRiskyAllowed(true)
+ ->setFinder(
+ PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude(array(
// directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code
diff --git a/.travis.yml b/.travis.yml
index 423d9260b6a9b..7769d6a768655 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,7 +20,7 @@ env:
matrix:
include:
# Use the newer stack for HHVM as HHVM does not support Precise anymore since a long time and so Precise has an outdated version
- - php: hhvm-stable
+ - php: hhvm-3.15
sudo: required
dist: trusty
group: edge
@@ -86,16 +86,17 @@ install:
- if [[ ! $skip && $deps ]]; then export SYMFONY_DEPRECATIONS_HELPER=weak; fi
- if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi
- if [[ ! $skip ]]; then composer update; fi
- - if [[ ! $skip ]]; then COMPOSER_ROOT_VERSION= ./phpunit install; fi
+ - if [[ ! $skip ]]; then ./phpunit install; fi
- if [[ ! $skip && ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
script:
+ - REPORT=' && echo -e "\\e[32mOK\\e[0m {}\\n\\n" || (echo -e "\\e[41mKO\\e[0m {}\\n\\n" && $(exit 1))'
- if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi
- - if [[ ! $deps && ! $PHP = hhvm* ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi
+ - if [[ ! $deps && ! $PHP = hhvm* ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'"$REPORT"; fi
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi
- if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group benchmark,intl-data; fi
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi
- - if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi
- - if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi
+ - if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY"$REPORT"; fi
+ - if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'"$REPORT"; fi
# Test the PhpUnit bridge using the original phpunit script
- if [[ $deps = low ]]; then (cd src/Symfony/Bridge/PhpUnit && phpenv global 5.3 && php --version && composer update && phpunit); fi
diff --git a/CHANGELOG-3.1.md b/CHANGELOG-3.1.md
index 228cbff557b8e..fc198328e6002 100644
--- a/CHANGELOG-3.1.md
+++ b/CHANGELOG-3.1.md
@@ -7,6 +7,44 @@ in 3.1 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.1.0...v3.1.1
+* 3.1.8 (2016-12-13)
+
+ * bug #20714 [FrameworkBundle] Fix unresolved parameters from default configs in debug:config (chalasr)
+ * bug #20442 [FrameworkBundle] Bundle commands are not available via find() (julienfalque)
+ * bug #20840 [WebProfilerBundle] add dependency on Twig (xabbuh)
+ * bug #20828 [Validator] Fix init of YamlFileLoader::$classes for empty files (nicolas-grekas)
+ * bug #20745 [Validator] add class name to the cache key (Simperfit)
+ * bug #20530 [Serializer] Remove AbstractObjectNormalizer::isAttributeToNormalize (dunglas)
+ * bug #19141 Throw less misleading exception when property access not found (bramtweedegolf)
+ * bug #20539 Cast result to int before adding to it (alcaeus)
+ * bug #20831 [Twig] Fix deprecations with Twig 1.29 (nicolas-grekas)
+ * bug #20816 [FrameworkBundle] Removed kernel.debug from the cache pool namespace seed (Sander Toonen)
+ * bug #20646 Maintain the selected panel when redirecting to another profile (javiereguiluz)
+ * bug #20767 [Cache] Fix dumping SplDoublyLinkedList iter mode (nicolas-grekas)
+ * bug #20736 [Console] fixed PHP7 Errors when not using Dispatcher (keradus)
+ * bug #20756 [HttpKernel] Regression test for missing controller arguments (iltar)
+ * bug #20755 [HttpKernel] Regression test for missing controller arguments (iltar)
+ * bug #20732 fix the inline level for dumped multi-line strings (xabbuh)
+ * bug #20418 [Form][DX] FileType "multiple" fixes (yceruto)
+ * bug #19902 [DependencyInjection] PhpDumper.php: hasReference() shouldn't search references in lazy service. (antanas-arvasevicius)
+ * bug #20704 [Console] Fix wrong handling of multiline arg/opt descriptions (ogizanagi)
+ * bug #20712 [TwigBundle] Fix twig loader registered twice (ogizanagi)
+ * bug #20716 [WebProfilerBundle] Fix dump block is unfairly restrained (ogizanagi)
+ * bug #20671 [Config] ConfigCache::isFresh() should return false when unserialize() fails (nicolas-grekas)
+ * bug #20676 [ClassLoader] Use only forward slashes in generated class map (nicolas-grekas)
+ * bug #20664 [Validator] ensure the proper context for nested validations (xabbuh)
+ * bug #20661 bug #20653 [WebProfilerBundle] Profiler includes ghost panels (jzawadzki)
+ * bug #20374 [FrameworkBundle] Improve performance of ControllerNameParser (enumag)
+ * bug #20474 [Routing] Fail properly when a route parameter name cannot be used as a PCRE subpattern name (fancyweb)
+ * bug #20566 [DI] Initialize properties before method calls (ro0NL)
+ * bug #20609 [DI] Fixed custom services definition BC break introduced in ec7e70fb… (kiler129)
+ * bug #20598 [DI] Aliases should preserve the aliased invalid behavior (nicolas-grekas)
+ * bug #20600 [Process] Fix process continuing after reached timeout using getIterator() (chalasr)
+ * bug #20602 [HttpKernel] Revert BC breaking change of Request::isMethodSafe() (nicolas-grekas)
+ * bug #20499 [Doctrine][Form] support large integers (xabbuh)
+ * bug #20576 [Process] Do feat test before enabling TTY mode (nicolas-grekas)
+ * bug #20577 [FrameworkBundle] Mark cache.default_*_provider services private (nicolas-grekas)
+
* 3.1.7 (2016-11-21)
* bug #20550 [YAML] Fix processing timestamp strings with timezone (myesain)
diff --git a/CHANGELOG-3.2.md b/CHANGELOG-3.2.md
index 39dd7fa8598f5..cea91c29475e1 100644
--- a/CHANGELOG-3.2.md
+++ b/CHANGELOG-3.2.md
@@ -7,6 +7,69 @@ in 3.2 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.2.0...v3.2.1
+* 3.2.2 (2017-01-12)
+
+ * bug #21257 [Profiler][Form] Fix form profiler errors profiler_dump (ogizanagi)
+ * bug #21243 [FrameworkBundle] Fix class_exists() checks in PhpArrayAdapter-related cache warmers (nicolas-grekas, mpajunen)
+ * bug #21218 [Form] DateTimeToLocalizedStringTransformer does not use timezone when using date only (magnetik)
+ * bug #20605 [Ldap] Always have a valid connection when using the EntryManager (bobvandevijver)
+ * bug #21104 [FrameworkBundle] fix IPv6 address handling in server commands (xabbuh)
+ * bug #20793 [Validator] Fix caching of constraints derived from non-serializable parents (uwej711)
+ * bug #19586 [TwigBundle] Fix bug where namespaced paths don't take parent bundles in account (wesleylancel)
+ * bug #21237 [FrameworkBundle] Fix relative paths used as cache keys (nicolas-grekas)
+ * bug #21183 [Validator] respect groups when merging constraints (xabbuh)
+ * bug #21179 [TwigBundle] Fixing regression in TwigEngine exception handling (Bertalan Attila)
+ * bug #21220 [DI] Fix missing new line after private alias (ogizanagi)
+ * bug #21211 Classloader tmpname (lyrixx)
+ * bug #21205 [TwigBundle] fixed usage when Templating is not installed (fabpot)
+ * bug #21155 [Validator] Check cascasdedGroups for being countable (scaytrase)
+ * bug #21200 [Filesystem] Check that directory is writable after created it in dumpFile() (chalasr)
+ * bug #21186 [Bridge/PhpUnit] Relax expectedDeprecation for forward compat (nicolas-grekas)
+ * bug #21184 [FrameworkBundle] Remove Response* from classes to compile (nicolas-grekas)
+ * bug #21165 [Serializer] int is valid when float is expected when deserializing JSON (dunglas)
+ * bug #21167 [Cache] Remove silenced warning tiggered by PhpArrayAdapter (nicolas-grekas)
+ * bug #21166 [Cache] Fix order of writes in ChainAdapter (nicolas-grekas)
+ * bug #21113 [FrameworkBundle][HttpKernel] Fix resources loading for bundles with custom structure (chalasr)
+ * bug #20995 [DependencyInjection] Fix the priority order of compiler pass trait (francoispluchino)
+ * bug #21084 [Yaml] handle empty lines inside unindented collection (xabbuh)
+ * bug #21143 [PhpUnitBridge] Set COMPOSER_ROOT_VERSION while installing (nicolas-grekas)
+ * bug #20925 [HttpFoundation] Validate/cast cookie expire time (ro0NL)
+ * bug #21138 [PhpUnitBridge] skip tests with failure and error states too (xabbuh)
+ * bug #21135 [PhpUnitBridge] hide stack trace of expected deprecation failures (xabbuh)
+ * bug #21117 [Yaml] add missing indicator character (xabbuh)
+ * bug #21121 [PhpUnitBridge] respect skipped and incomplete tests (xabbuh)
+ * bug #21032 [SecurityBundle] Made collection of user provider unique when injecting them to the RemberMeService (lyrixx)
+ * bug #21078 [Console] Escape default value when dumping help (lyrixx)
+ * bug #21076 [Console] OS X Can't call cli_set_process_title php without superuser (ogizanagi)
+ * bug #20900 [Console] Descriptors should use Helper::strlen (ogizanagi)
+ * bug #21025 [Cache] remove is_writable check on filesystem cache (4rthem)
+ * bug #21064 [Debug] Wrap call to ->log in a try catch block (lyrixx)
+ * bug #21069 [Debug] Fixed cast of stream (lyrixx)
+ * bug #21010 [Debug] UndefinedMethodFatalErrorHandler - Handle anonymous classes (SpacePossum)
+ * bug #20991 [cache] Bump RedisAdapter default timeout to 5s (Nicofuma)
+ * bug #20959 [FrameworkBundle] Ignore AnnotationException exceptions in the AnnotationsCacheWarmer (fancyweb)
+ * bug #20795 [FrameworkBundle] Allow multiple transitions with the same name (Padam87)
+ * bug #20859 Avoid warning in PHP 7.2 because of non-countable data (wouterj)
+ * bug #21053 [Validator] override property constraints in child class (xabbuh)
+ * bug #21034 [FrameworkBundle] Make TemplateController working without the Templating component (dunglas)
+ * bug #20970 [Console] Fix question formatting using SymfonyStyle::ask() (chalasr, ogizanagi)
+ * bug #20999 [HttpKernel] Continuation of #20599 for 3.1 (ro0NL)
+ * bug #20975 [Form] fix group sequence based validation (xabbuh)
+ * bug #20599 [WebProfilerBundle] Display multiple HTTP headers in WDT (ro0NL)
+ * bug #20799 [TwigBundle] do not try to register incomplete definitions (xabbuh)
+ * bug #20961 [Validator] phpize default option values (xabbuh)
+ * bug #20934 [FrameworkBundle] Fix PHP form templates on translatable attributes (ro0NL)
+ * bug #20957 [FrameworkBundle] test for the Validator component to be present (xabbuh)
+ * bug #20936 [DependencyInjection] Fix on-invalid attribute type in xsd (ogizanagi)
+ * bug #20931 [VarDumper] Fix dumping by-ref variadics (nicolas-grekas)
+ * bug #20749 [FrameworkBundle] Smarter default for framework.annotations (ogizanagi)
+ * bug #20734 [Security] AbstractVoter->supportsAttribute gives false positive if attribute is zero (0) (martynas-foodpanda)
+ * bug #14082 [config] Fix issue when key removed and left value only (zerustech)
+ * bug #20910 [HttpFoundation] Fix cookie to string conversion for raw cookies (ro0NL)
+ * bug #20909 Fix misresolved parameters in debug:config on 3.2 (chalasr)
+ * bug #20904 [TwigBundle] Config is now a hard dependency (dunglas)
+ * bug #20847 [Console] fixed BC issue with static closures (araines)
+
* 3.2.1 (2016-12-13)
* bug #20891 Add support for REDIS_URL environment variables. (robinvdvleuten)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ae18925cb6e20..7902d9aff3a77 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -5,6 +5,7 @@ Symfony is an open source, community-driven project.
If you'd like to contribute, please read the following documents:
+* [Reviewing issues/pull requests][0]
* [Reporting a Bug][1]
* [Submitting a Patch][2]
* [Symfony Core Team][3]
@@ -14,6 +15,7 @@ If you'd like to contribute, please read the following documents:
* [Coding Standards][7]
* [Conventions][8]
+[0]: https://symfony.com/doc/current/contributing/community/reviews.html
[1]: https://symfony.com/doc/current/contributing/code/bugs.html
[2]: https://symfony.com/doc/current/contributing/code/patches.html
[3]: https://symfony.com/doc/current/contributing/code/core_team.html
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index c5fb26e0e91d8..24f9845d0b517 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -28,16 +28,17 @@ Symfony is the result of the work of many people who made the code better
- Lukas Kahwe Smith (lsmith)
- Martin Hasoň (hason)
- Jeremy Mikola (jmikola)
- - Jean-François Simon (jfsimon)
- Grégoire Pineau (lyrixx)
+ - Jean-François Simon (jfsimon)
- Benjamin Eberlei (beberlei)
- Igor Wiedler (igorw)
- Eriksen Costa (eriksencosta)
- Jules Pietri (heah)
- - Sarah Khalil (saro0h)
- Maxime Steinhausser (ogizanagi)
+ - Sarah Khalil (saro0h)
- Jonathan Wage (jwage)
- Diego Saint Esteben (dosten)
+ - Robin Chalas (chalas_r)
- Alexandre Salomé (alexandresalome)
- William Durand (couac)
- ornicar
@@ -45,7 +46,6 @@ Symfony is the result of the work of many people who made the code better
- stealth35 (stealth35)
- Alexander Mols (asm89)
- Bulat Shakirzyanov (avalanche123)
- - Robin Chalas (chalas_r)
- Saša Stamenković (umpirsky)
- Henrik Bjørnskov (henrikbjorn)
- Miha Vrhovnik
@@ -53,9 +53,9 @@ Symfony is the result of the work of many people who made the code better
- Ener-Getick (energetick)
- Konstantin Kudryashov (everzet)
- Bilal Amarni (bamarni)
+ - Iltar van der Berg (kjarli)
- Florin Patan (florinpatan)
- Peter Rehm (rpet)
- - Iltar van der Berg (kjarli)
- Kevin Bond (kbond)
- Andrej Hudec (pulzarraider)
- Gábor Egyed (1ed)
@@ -77,16 +77,16 @@ Symfony is the result of the work of many people who made the code better
- Titouan Galopin (tgalopin)
- Daniel Holmes (dholmes)
- Pierre du Plessis (pierredup)
+ - Toni Uebernickel (havvg)
- Bart van den Burg (burgov)
- Jordan Alliot (jalliot)
- John Wards (johnwards)
- - Toni Uebernickel (havvg)
+ - Roland Franssen (ro0)
- Fran Moreno (franmomu)
+ - Jáchym Toušek (enumag)
- Antoine Hérault (herzult)
- Paráda József (paradajozsef)
- - Roland Franssen (ro0)
- Dariusz Ruminski
- - Jáchym Toušek (enumag)
- Arnaud Le Blanc (arnaud-lb)
- Jérôme Tamarelle (gromnan)
- Michal Piotrowski (eventhorizon)
@@ -114,6 +114,7 @@ Symfony is the result of the work of many people who made the code better
- Eric GELOEN (gelo)
- David Buchmann (dbu)
- Tugdual Saunier (tucksaun)
+ - Maxime STEINHAUSSER
- Théo FIDRY (theofidry)
- Robert Schönthal (digitalkaoz)
- Florian Lonqueu-Brochard (florianlb)
@@ -134,6 +135,7 @@ Symfony is the result of the work of many people who made the code better
- jwdeitch
- Tobias Nyholm (tobias)
- Joel Wurtz (brouznouf)
+ - Yonel Ceruto González (yonelceruto)
- Philipp Wahala (hifi)
- Vyacheslav Pavlov
- Javier Spagnoletti (phansys)
@@ -146,7 +148,6 @@ Symfony is the result of the work of many people who made the code better
- Clemens Tolboom
- Helmer Aaviksoo
- Hiromi Hishida (77web)
- - Yonel Ceruto González (yonelceruto)
- Richard van Laak (rvanlaak)
- Matthieu Ouellette-Vachon (maoueh)
- Michał Pipa (michal.pipa)
@@ -168,7 +169,6 @@ Symfony is the result of the work of many people who made the code better
- Andreas Hucks (meandmymonkey)
- Noel Guilbert (noel)
- Lars Strojny (lstrojny)
- - Maxime STEINHAUSSER
- Stepan Anchugov (kix)
- bronze1man
- sun (sun)
@@ -263,6 +263,7 @@ Symfony is the result of the work of many people who made the code better
- Hidde Wieringa (hiddewie)
- Chris Smith (cs278)
- Florian Klein (docteurklein)
+ - Julien Falque (julienfalque)
- Oleg Voronkovich
- Manuel Kiessling (manuelkiessling)
- Daniel Wehner
@@ -331,10 +332,13 @@ Symfony is the result of the work of many people who made the code better
- Loïc Chardonnet (gnusat)
- Marek Kalnik (marekkalnik)
- Vyacheslav Salakhutdinov (megazoll)
+ - Jerzy Zawadzki (jzawadzki)
- Hassan Amouhzi
- Tamas Szijarto
- Pavel Volokitin (pvolok)
+ - Nicolas Dewez (nicolas_dewez)
- Endre Fejes
+ - Victor Bocharsky (bocharsky_bw)
- Tobias Naumann (tna)
- Daniel Beyer
- Shein Alexey
@@ -427,7 +431,6 @@ Symfony is the result of the work of many people who made the code better
- Roy Van Ginneken (rvanginneken)
- ondrowan
- Barry vd. Heuvel (barryvdh)
- - Jerzy Zawadzki (jzawadzki)
- Evan S Kaufman (evanskaufman)
- mcben
- Jérôme Vieilledent (lolautruche)
@@ -437,9 +440,7 @@ Symfony is the result of the work of many people who made the code better
- Markus Lanthaler (lanthaler)
- Remi Collet
- Vicent Soria Durá (vicentgodella)
- - Nicolas Dewez (nicolas_dewez)
- Anthony Ferrara
- - Victor Bocharsky (bocharsky_bw)
- Ioan Negulescu
- Jakub Škvára (jskvara)
- Andrew Udvare (audvare)
@@ -484,6 +485,7 @@ Symfony is the result of the work of many people who made the code better
- Ziumin
- Jeremy Benoist
- Lenar Lõhmus
+ - Sander Toonen (xatoo)
- Benjamin Laugueux (yzalis)
- Zach Badgett (zachbadgett)
- Aurélien Fredouelle
@@ -521,6 +523,7 @@ Symfony is the result of the work of many people who made the code better
- Maxime Douailin
- Jean Pasdeloup (pasdeloup)
- Javier López (loalf)
+ - Andreas Braun
- Reinier Kip
- Geoffrey Brier (geoffrey-brier)
- Dustin Dobervich (dustin10)
@@ -548,8 +551,10 @@ Symfony is the result of the work of many people who made the code better
- umpirski
- Chris Heng (gigablah)
- Ulumuddin Yunus (joenoez)
+ - Adam Prager (padam87)
- Luc Vieillescazes (iamluc)
- Johann Saunier (prophet777)
+ - Samuel ROZE (sroze)
- Michael Devery (mickadoo)
- Antoine Corcy
- Artur Eshenbrener
@@ -589,6 +594,7 @@ Symfony is the result of the work of many people who made the code better
- yclian
- twifty
- Peter Ward
+ - Julien DIDIER (juliendidier)
- Dominik Ritter (dritter)
- Sebastian Grodzicki (sgrodzicki)
- Martin Hujer (martinhujer)
@@ -613,6 +619,7 @@ Symfony is the result of the work of many people who made the code better
- michaelwilliams
- 1emming
- Leevi Graham (leevigraham)
+ - Nykopol (nykopol)
- Jordan Deitch
- Casper Valdemar Poulsen
- Josiah (josiah)
@@ -696,9 +703,9 @@ Symfony is the result of the work of many people who made the code better
- abdul malik ikhsan (samsonasik)
- Henry Snoek (snoek09)
- Simone Di Maulo (toretto460)
- - Sander Toonen (xatoo)
- Christian Morgan
- Alexander Miehe (engerim)
+ - Jérôme Parmentier (lctrs)
- Morgan Auchede (mauchede)
- Don Pinkster
- Maksim Muruev
@@ -769,13 +776,13 @@ Symfony is the result of the work of many people who made the code better
- fabios
- Sander Coolen (scoolen)
- Nicolas Le Goff (nlegoff)
- - Andreas Braun
- Ben Oman
- Manuele Menozzi
- Anton Babenko (antonbabenko)
- Irmantas Šiupšinskas (irmantas)
- Danilo Silva
- Zachary Tong (polyfractal)
+ - Amrouche Hamza
- Hryhorii Hrebiniuk
- Dennis Fridrich (dfridrich)
- mcfedr (mcfedr)
@@ -808,10 +815,10 @@ Symfony is the result of the work of many people who made the code better
- Ville Mattila
- Boris Vujicic (boris.vujicic)
- Max Beutel
+ - Antanas Arvasevicius
- nacho
- Piotr Antosik (antek88)
- Artem Lopata
- - Samuel ROZE (sroze)
- Sergey Novikov (s12v)
- Marcos Quesada (marcos_quesada)
- Matthew Vickery (mattvick)
@@ -842,6 +849,7 @@ Symfony is the result of the work of many people who made the code better
- Thomas Royer (cydonia7)
- DerManoMann
- Olaf Klischat
+ - orlovv
- Jhonny Lidfors (jhonny)
- Julien Bianchi (jubianchi)
- Robert Meijers
@@ -877,6 +885,7 @@ Symfony is the result of the work of many people who made the code better
- Taras Girnyk
- Eduardo García Sanz (coma)
- James Gilliland
+ - fduch (fduch)
- Rhodri Pugh (rodnaph)
- David de Boer (ddeboer)
- Klaus Purer
@@ -910,6 +919,7 @@ Symfony is the result of the work of many people who made the code better
- Alberto Aldegheri
- heccjj
- Alexandre Melard
+ - Thomas Calvet
- Sergey Yuferev
- Tobias Stöckler
- Mario Young
@@ -950,6 +960,7 @@ Symfony is the result of the work of many people who made the code better
- Sebastian Utz
- Adrien Gallou (agallou)
- Karol Sójko (karolsojko)
+ - Grzegorz Zdanowski (kiler129)
- sl_toto (sl_toto)
- Walter Dal Mut (wdalmut)
- Albin Kerouaton
@@ -997,9 +1008,11 @@ Symfony is the result of the work of many people who made the code better
- Ahmed TAILOULOUTE (ahmedtai)
- Maxime Veber (nek-)
- Sullivan SENECHAL
+ - Dariusz Ruminski
- Tadcka
- Beth Binkovitz
- Romain Geissler
+ - Adrien Moiruad
- Tomaz Ahlin
- Benjamin Cremer (bcremer)
- Marcus Stöhr (dafish)
@@ -1015,7 +1028,6 @@ Symfony is the result of the work of many people who made the code better
- Max Romanovsky (maxromanovsky)
- Mathieu Morlon
- Daniel Tschinder
- - Nykopol (nykopol)
- Rafał Muszyński (rafmus90)
- Timothy Anido (xanido)
- Rick Prent
@@ -1061,6 +1073,7 @@ Symfony is the result of the work of many people who made the code better
- kor3k kor3k (kor3k)
- Stelian Mocanita (stelian)
- Flavian (2much)
+ - Arthur de Moulins (4rthem)
- mike
- Keith Maika
- Mephistofeles
@@ -1093,7 +1106,6 @@ Symfony is the result of the work of many people who made the code better
- Adrian Olek (adrianolek)
- Przemysław Piechota (kibao)
- Leonid Terentyev (li0n)
- - Adam Prager (padam87)
- ryunosuke
- victoria
- Francisco Facioni (fran6co)
@@ -1254,11 +1266,11 @@ Symfony is the result of the work of many people who made the code better
- Jan Eichhorn (exeu)
- Grégory Pelletier (ip512)
- John Nickell (jrnickell)
- - Julien DIDIER (juliendidier)
- Martin Mayer (martin)
- Grzegorz Łukaszewicz (newicz)
- Götz Gottwald
- Veres Lajos
+ - Michael Babker
- grifx
- Robert Campbell
- Matt Lehner
@@ -1299,6 +1311,7 @@ Symfony is the result of the work of many people who made the code better
- Alex
- Klaas Naaijkens
- Daniel González Cerviño
+ - ShinDarth
- Rafał
- Adria Lopez (adlpz)
- Rosio (ben-rosio)
@@ -1319,7 +1332,6 @@ Symfony is the result of the work of many people who made the code better
- Jelle Bekker (jbekker)
- Ian Jenkins (jenkoian)
- Jorge Martin (jorgemartind)
- - Julien Falque (julienfalque)
- Kevin Herrera (kherge)
- Luis Ramón López López (lrlopez)
- Muriel (metalmumu)
@@ -1341,6 +1353,7 @@ Symfony is the result of the work of many people who made the code better
- Saem Ghani
- Stefan Oderbolz
- Curtis
+ - Gabriel Moreira
- Alexey Popkov
- Joseph Deray
- Damian Sromek
@@ -1362,6 +1375,7 @@ Symfony is the result of the work of many people who made the code better
- Wotre
- goohib
- Xavier HAUSHERR
+ - Edwin Hageman
- Mantas Urnieža
- Cas
- Dusan Kasan
@@ -1393,6 +1407,7 @@ Symfony is the result of the work of many people who made the code better
- Dariusz Czech
- Anonymous User
- Eric J. Duran
+ - Alexandru Bucur
- cmfcmf
- Drew Butler
- Steve Müller
@@ -1477,11 +1492,13 @@ Symfony is the result of the work of many people who made the code better
- Daniel Basten (axhm3a)
- Bill Hance (billhance)
- Bernd Matzner (bmatzner)
+ - Bram Tweedegolf (bram_tweedegolf)
- Choong Wei Tjeng (choonge)
- Kousuke Ebihara (co3k)
- Loïc Vernet (coil)
- Christoph Schaefer (cvschaefer)
- Damon Jones (damon__jones)
+ - Łukasz Giza (destroyer)
- Daniel Londero (dlondero)
- Sebastian Landwehr (dword123)
- Adel ELHAIBA (eadel)
@@ -1497,6 +1514,7 @@ Symfony is the result of the work of many people who made the code better
- Arash Tabriziyan (ghost098)
- ibasaw (ibasaw)
- Vladislav Krupenkin (ideea)
+ - Imangazaliev Muhammad (imangazaliev)
- joris de wit (jdewit)
- Jérémy CROMBEZ (jeremy)
- Jose Manuel Gonzalez (jgonzalez)
@@ -1506,10 +1524,10 @@ Symfony is the result of the work of many people who made the code better
- JuntaTom (juntatom)
- Ismail Faizi (kanafghan)
- Sébastien Armand (khepin)
+ - Pierre-Chanel Gauthier (kmecnin)
- Krzysztof Menżyk (krymen)
- samuel laulhau (lalop)
- Laurent Bachelier (laurentb)
- - Jérôme Parmentier (lctrs)
- Florent Viel (luxifer)
- Matthieu Moquet (mattketmo)
- Moritz Borgmann (mborgmann)
diff --git a/LICENSE b/LICENSE
index 12a74531e40a4..17d16a13367dd 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2016 Fabien Potencier
+Copyright (c) 2004-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index ecd3b61781c8b..33bc7fb640361 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,14 @@ please read the [Contributing Code][3] part of the documentation. If you're subm
a pull request, please follow the guidelines in the [Submitting a Patch][4] section
and use [Pull Request Template][5].
+Community Reviews
+-----------------
+
+If you don't feel ready to contribute code or patches, reviewing issues and pull
+requests can be a great start to get involved and give back. In fact, people who
+"triage" issues are the backbone to Symfony's success!
+More information can be found in the [Community Reviews][8] guide.
+
Running Symfony Tests
----------------------
@@ -46,3 +54,4 @@ Information on how to run the Symfony test suite can be found in the
[5]: https://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request
[6]: https://symfony.com/doc/master/contributing/code/tests.html
[7]: https://symfony.com/doc/current/book/installation.html#installing-the-symfony-installer
+[8]: https://symfony.com/doc/current/contributing/community/reviews.html
diff --git a/UPGRADE-3.2.md b/UPGRADE-3.2.md
index e977a845cf045..d5abb758542e8 100644
--- a/UPGRADE-3.2.md
+++ b/UPGRADE-3.2.md
@@ -94,6 +94,11 @@ HttpFoundation
- `isInvalid`/`isSuccessful`/`isRedirection`/`isClientError`/`isServerError`
- `isOk`/`isForbidden`/`isNotFound`/`isRedirect`/`isEmpty`
+ * Checking only for cacheable HTTP methods with `Request::isMethodSafe()` is deprecated
+ since version 3.2 and will throw an exception in 4.0. Disable checking only for
+ cacheable methods by calling the method with `false` as first argument or use
+ `Request::isMethodCacheable()` instead.
+
HttpKernel
----------
@@ -128,8 +133,36 @@ Serializer
TwigBridge
----------
- * Deprecated the possibility to inject the Form Twig Renderer into the form
- extension. Inject it into the `TwigRendererEngine` instead.
+ * Injecting the Form `TwigRenderer` into the `FormExtension` is deprecated and has no more effect.
+ Upgrade Twig to `^1.30`, inject the `Twig_Environment` into the `TwigRendererEngine` and load
+ the `TwigRenderer` using the `Twig_FactoryRuntimeLoader` instead.
+
+ Before:
+
+ ```php
+ use Symfony\Bridge\Twig\Extension\FormExtension;
+ use Symfony\Bridge\Twig\Form\TwigRenderer;
+ use Symfony\Bridge\Twig\Form\TwigRendererEngine;
+
+ // ...
+ $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'));
+ $rendererEngine->setEnvironment($twig);
+ $twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager)));
+ ```
+
+ After:
+
+ ```php
+ $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
+ $twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
+ TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
+ return new TwigRenderer($rendererEngine, $csrfTokenManager);
+ },
+ )));
+ $twig->addExtension(new FormExtension());
+ ```
+
+ * Deprecated the `TwigRendererEngineInterface` interface, it will be removed in 4.0.
Validator
---------
diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md
index 76b6b51bd7b3c..cc7584de70471 100644
--- a/UPGRADE-4.0.md
+++ b/UPGRADE-4.0.md
@@ -151,6 +151,9 @@ HttpFoundation
- `isInvalid`/`isSuccessful`/`isRedirection`/`isClientError`/`isServerError`
- `isOk`/`isForbidden`/`isNotFound`/`isRedirect`/`isEmpty`
+ * The ability to check only for cacheable HTTP methods using `Request::isMethodSafe()` is
+ not supported anymore, use `Request::isMethodCacheable()` instead.
+
HttpKernel
----------
@@ -183,8 +186,36 @@ Translation
TwigBridge
----------
- * The possibility to inject the Form Twig Renderer into the form extension
- has been removed. Inject it into the `TwigRendererEngine` instead.
+ * Removed the possibility to inject the Form `TwigRenderer` into the `FormExtension`.
+ Upgrade Twig to `^1.30`, inject the `Twig_Environment` into the `TwigRendererEngine` and load
+ the `TwigRenderer` using the `Twig_FactoryRuntimeLoader` instead.
+
+ Before:
+
+ ```php
+ use Symfony\Bridge\Twig\Extension\FormExtension;
+ use Symfony\Bridge\Twig\Form\TwigRenderer;
+ use Symfony\Bridge\Twig\Form\TwigRendererEngine;
+
+ // ...
+ $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'));
+ $rendererEngine->setEnvironment($twig);
+ $twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager)));
+ ```
+
+ After:
+
+ ```php
+ $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
+ $twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
+ TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
+ return new TwigRenderer($rendererEngine, $csrfTokenManager);
+ },
+ )));
+ $twig->addExtension(new FormExtension());
+ ```
+
+ * Removed the `TwigRendererEngineInterface` interface.
Validator
---------
@@ -219,7 +250,7 @@ Validator
```
* The default value of the strict option of the `Choice` Constraint has been
- changed to `true` as of 4.0. If you need the the previous behaviour ensure to
+ changed to `true` as of 4.0. If you need the previous behaviour ensure to
set the option to `false`.
Yaml
diff --git a/appveyor.yml b/appveyor.yml
index 63f7319e191ee..d5c663d5a041e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -3,7 +3,7 @@ clone_depth: 1
clone_folder: c:\projects\symfony
cache:
- - c:\projects\symfony\composer.phar
+ - composer.phar
- .phpunit -> phpunit
init:
@@ -46,13 +46,12 @@ install:
- echo curl.cainfo=c:\php\cacert.pem >> php.ini-max
- copy /Y php.ini-max php.ini
- cd c:\projects\symfony
- - IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.1/composer.phar)
+ - IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.3.0/composer.phar)
- php composer.phar self-update
- copy /Y .composer\* %APPDATA%\Composer\
- php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
- php composer.phar update --no-progress --ansi
- - SET COMPOSER_ROOT_VERSION=
- php phpunit install
test_script:
diff --git a/phpunit b/phpunit
index f9243bcbf9e79..1e79197e316d3 100755
--- a/phpunit
+++ b/phpunit
@@ -1,6 +1,8 @@
#!/usr/bin/env php
method('getDatabasePlatform')
->will($this->returnValue(new MySqlPlatform()));
- $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry
->expects($this->any())
->method('getConnectionNames')
@@ -152,7 +152,7 @@ private function createCollector($queries)
->method('getConnection')
->will($this->returnValue($connection));
- $logger = $this->getMock('Doctrine\DBAL\Logging\DebugStack');
+ $logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock();
$logger->queries = $queries;
$collector = new DoctrineDataCollector($registry);
diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php
index 53ad5a0e3a8a7..77d89088d2b1e 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php
@@ -18,7 +18,7 @@ class ContainerAwareLoaderTest extends \PHPUnit_Framework_TestCase
{
public function testShouldSetContainerOnContainerAwareFixture()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$loader = new ContainerAwareLoader($container);
$fixture = new ContainerAwareFixture();
diff --git a/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php b/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php
index 6bf22c185126a..9c6b23ff74618 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php
@@ -20,7 +20,7 @@ class DoctrineParserCacheTest extends \PHPUnit_Framework_TestCase
{
public function testFetch()
{
- $doctrineCacheMock = $this->getMock('Doctrine\Common\Cache\Cache');
+ $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$parserCache = new DoctrineParserCache($doctrineCacheMock);
$doctrineCacheMock->expects($this->once())
@@ -34,7 +34,7 @@ public function testFetch()
public function testFetchUnexisting()
{
- $doctrineCacheMock = $this->getMock('Doctrine\Common\Cache\Cache');
+ $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$parserCache = new DoctrineParserCache($doctrineCacheMock);
$doctrineCacheMock
@@ -47,7 +47,7 @@ public function testFetchUnexisting()
public function testSave()
{
- $doctrineCacheMock = $this->getMock('Doctrine\Common\Cache\Cache');
+ $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$parserCache = new DoctrineParserCache($doctrineCacheMock);
$expression = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParsedExpression')
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php
index 6444fd1bf0de3..f20340b04e883 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php
@@ -66,14 +66,14 @@ class DoctrineChoiceLoaderTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->factory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface');
- $this->om = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
- $this->repository = $this->getMock('Doctrine\Common\Persistence\ObjectRepository');
+ $this->factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
+ $this->om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
+ $this->repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$this->class = 'stdClass';
$this->idReader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader')
->disableOriginalConstructor()
->getMock();
- $this->objectLoader = $this->getMock('Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface');
+ $this->objectLoader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface')->getMock();
$this->obj1 = (object) array('name' => 'A');
$this->obj2 = (object) array('name' => 'B');
$this->obj3 = (object) array('name' => 'C');
@@ -117,7 +117,7 @@ public function testLoadChoiceList()
*/
public function testLegacyLoadChoiceList()
{
- $factory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface');
+ $factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$loader = new DoctrineChoiceLoader(
$factory,
$this->om,
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
index 0cb900f6d04c4..f6b96bb2005e0 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
@@ -86,10 +86,10 @@ public function requiredProvider()
private function getGuesser(ClassMetadata $classMetadata)
{
- $em = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
+ $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata));
- $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry->expects($this->once())->method('getManagers')->will($this->returnValue(array($em)));
return new DoctrineOrmTypeGuesser($registry);
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/MergeDoctrineCollectionListenerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/MergeDoctrineCollectionListenerTest.php
index 8c4ec7a2153f4..8ee44b5735276 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/MergeDoctrineCollectionListenerTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/MergeDoctrineCollectionListenerTest.php
@@ -31,7 +31,7 @@ protected function setUp()
{
$this->collection = new ArrayCollection(array('test'));
$this->dispatcher = new EventDispatcher();
- $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
+ $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$this->form = $this->getBuilder()
->getForm();
}
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
index 57df4195bcec4..16bf4e11ab9c0 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
@@ -32,7 +32,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
protected function getExtensions()
{
- $manager = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$manager->expects($this->any())
->method('getManager')
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
index f5752fb70750e..e87713f561af4 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
@@ -1274,7 +1274,7 @@ public function testLoaderCachingWithParameters()
protected function createRegistryMock($name, $em)
{
- $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry->expects($this->any())
->method('getManager')
->with($this->equalTo($name))
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
index 6acc47fe904e0..ddfd506c84546 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
@@ -20,7 +20,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
*/
public function testLog($sql, $params, $logParams)
{
- $logger = $this->getMock('Psr\\Log\\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@@ -52,7 +52,7 @@ public function getLogFixtures()
public function testLogNonUtf8()
{
- $logger = $this->getMock('Psr\\Log\\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@@ -75,7 +75,7 @@ public function testLogNonUtf8()
public function testLogNonUtf8Array()
{
- $logger = $this->getMock('Psr\\Log\\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@@ -106,7 +106,7 @@ public function testLogNonUtf8Array()
public function testLogLongString()
{
- $logger = $this->getMock('Psr\\Log\\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@@ -134,7 +134,7 @@ public function testLogLongString()
public function testLogUTF8LongString()
{
- $logger = $this->getMock('Psr\\Log\\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
index 3a3a8456e20ab..3f224649f5d83 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
@@ -150,12 +150,12 @@ public function testSupportProxy()
public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided()
{
- $repository = $this->getMock('\Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface');
+ $repository = $this->getMockBuilder('\Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')->getMock();
$repository->expects($this->once())
->method('loadUserByUsername')
->with('name')
->willReturn(
- $this->getMock('\Symfony\Component\Security\Core\User\UserInterface')
+ $this->getMockBuilder('\Symfony\Component\Security\Core\User\UserInterface')->getMock()
);
$provider = new EntityUserProvider(
@@ -171,7 +171,7 @@ public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided(
*/
public function testLoadUserByUserNameShouldDeclineInvalidInterface()
{
- $repository = $this->getMock('\Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $repository = $this->getMockBuilder('\Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$provider = new EntityUserProvider(
$this->getManager($this->getObjectManager($repository)),
@@ -183,7 +183,7 @@ public function testLoadUserByUserNameShouldDeclineInvalidInterface()
private function getManager($em, $name = null)
{
- $manager = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$manager->expects($this->any())
->method('getManager')
->with($this->equalTo($name))
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
index 21d3950313590..a54f8d438610a 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
@@ -71,7 +71,7 @@ protected function setUp()
protected function createRegistryMock(ObjectManager $em = null)
{
- $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry->expects($this->any())
->method('getManager')
->with($this->equalTo(self::EM_NAME))
@@ -100,7 +100,7 @@ protected function createEntityManagerMock($repositoryMock)
->will($this->returnValue($repositoryMock))
;
- $classMetadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata');
+ $classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$classMetadata
->expects($this->any())
->method('hasField')
diff --git a/src/Symfony/Bridge/Monolog/LICENSE b/src/Symfony/Bridge/Monolog/LICENSE
index 12a74531e40a4..17d16a13367dd 100644
--- a/src/Symfony/Bridge/Monolog/LICENSE
+++ b/src/Symfony/Bridge/Monolog/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2016 Fabien Potencier
+Copyright (c) 2004-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
index 713171cbb95d7..5e9e8dfd92546 100644
--- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
+++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
@@ -45,7 +45,7 @@ public function testIsHandling()
*/
public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = array())
{
- $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
+ $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$output
->expects($this->atLeastOnce())
->method('getVerbosity')
@@ -59,7 +59,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map
// check that the handler actually outputs the record if it handles it
$levelName = Logger::getLevelName($level);
- $realOutput = $this->getMock('Symfony\Component\Console\Output\Output', array('doWrite'));
+ $realOutput = $this->getMockBuilder('Symfony\Component\Console\Output\Output')->setMethods(array('doWrite'))->getMock();
$realOutput->setVerbosity($verbosity);
$realOutput
->expects($isHandling ? $this->once() : $this->never())
@@ -103,7 +103,7 @@ public function provideVerbosityMappingTests()
public function testVerbosityChanged()
{
- $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
+ $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$output
->expects($this->at(0))
->method('getVerbosity')
@@ -133,7 +133,7 @@ public function testGetFormatter()
public function testWritingAndFormatting()
{
- $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
+ $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$output
->expects($this->any())
->method('getVerbosity')
@@ -188,12 +188,12 @@ public function testLogsFromListeners()
$logger->addInfo('After terminate message.');
});
- $event = new ConsoleCommandEvent(new Command('foo'), $this->getMock('Symfony\Component\Console\Input\InputInterface'), $output);
+ $event = new ConsoleCommandEvent(new Command('foo'), $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $output);
$dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
$this->assertContains('Before command message.', $out = $output->fetch());
$this->assertContains('After command message.', $out);
- $event = new ConsoleTerminateEvent(new Command('foo'), $this->getMock('Symfony\Component\Console\Input\InputInterface'), $output, 0);
+ $event = new ConsoleTerminateEvent(new Command('foo'), $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $output, 0);
$dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
$this->assertContains('Before terminate message.', $out = $output->fetch());
$this->assertContains('After terminate message.', $out);
diff --git a/src/Symfony/Bridge/PhpUnit/LICENSE b/src/Symfony/Bridge/PhpUnit/LICENSE
index 39fa189d2b5fc..207646a052dcd 100644
--- a/src/Symfony/Bridge/PhpUnit/LICENSE
+++ b/src/Symfony/Bridge/PhpUnit/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2014-2016 Fabien Potencier
+Copyright (c) 2014-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php
index 0d873732636a9..3ebe6e0839ba3 100644
--- a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php
+++ b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php
@@ -34,6 +34,8 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
*/
public function __construct(array $mockedNamespaces = array())
{
+ \PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1;
+
$warn = false;
foreach ($mockedNamespaces as $type => $namespaces) {
if (!is_array($namespaces)) {
@@ -174,11 +176,14 @@ public function endTest(\PHPUnit_Framework_Test $test, $time)
{
if ($this->expectedDeprecations) {
restore_error_handler();
- try {
- $prefix = "@expectedDeprecation:\n ";
- $test->assertStringMatchesFormat($prefix.implode("\n ", $this->expectedDeprecations), $prefix.implode("\n ", $this->gatheredDeprecations));
- } catch (\PHPUnit_Framework_AssertionFailedError $e) {
- $test->getTestResultObject()->addFailure($test, $e, $time);
+
+ if (!in_array($test->getStatus(), array(\PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED, \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE, \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE, \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR), true)) {
+ try {
+ $prefix = "@expectedDeprecation:\n";
+ $test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n");
+ } catch (\PHPUnit_Framework_AssertionFailedError $e) {
+ $test->getTestResultObject()->addFailure($test, $e, $time);
+ }
}
$this->expectedDeprecations = $this->gatheredDeprecations = array();
diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
index a832b68b48e6e..49a610ed14a6e 100755
--- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
+++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
@@ -53,7 +53,10 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
}
passthru("$COMPOSER require --no-update symfony/phpunit-bridge \">=3.2@dev\"");
- passthru("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", $exit);
+ $prevRoot = getenv('COMPOSER_ROOT_VERSION');
+ putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION");
+ $exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", array(), $p, getcwd(), null, array('bypass_shell' => true)));
+ putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
if ($exit) {
exit($exit);
}
diff --git a/src/Symfony/Bridge/ProxyManager/LICENSE b/src/Symfony/Bridge/ProxyManager/LICENSE
index 12a74531e40a4..17d16a13367dd 100644
--- a/src/Symfony/Bridge/ProxyManager/LICENSE
+++ b/src/Symfony/Bridge/ProxyManager/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2016 Fabien Potencier
+Copyright (c) 2004-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php
index 8b2402b045f28..12bef7b72dc08 100644
--- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php
+++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php
@@ -37,7 +37,7 @@ protected function setUp()
public function testInstantiateProxy()
{
$instance = new \stdClass();
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$definition = new Definition('stdClass');
$instantiator = function () use ($instance) {
return $instance;
diff --git a/src/Symfony/Bridge/Twig/CHANGELOG.md b/src/Symfony/Bridge/Twig/CHANGELOG.md
index 685e1c9b083f0..dee3db5a37655 100644
--- a/src/Symfony/Bridge/Twig/CHANGELOG.md
+++ b/src/Symfony/Bridge/Twig/CHANGELOG.md
@@ -5,8 +5,37 @@ CHANGELOG
-----
* added `AppVariable::getToken()`
- * Deprecated the possibility to inject the Form Twig Renderer into the form
- extension. Inject it on TwigRendererEngine instead.
+ * Deprecated the possibility to inject the Form `TwigRenderer` into the `FormExtension`.
+ * [BC BREAK] Registering the `FormExtension` without configuring a runtime loader for the `TwigRenderer`
+ doesn't work anymore.
+
+ Before:
+
+ ```php
+ use Symfony\Bridge\Twig\Extension\FormExtension;
+ use Symfony\Bridge\Twig\Form\TwigRenderer;
+ use Symfony\Bridge\Twig\Form\TwigRendererEngine;
+
+ // ...
+ $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'));
+ $rendererEngine->setEnvironment($twig);
+ $twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager)));
+ ```
+
+ After:
+
+ ```php
+ // ...
+ $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
+ // require Twig 1.30+
+ $twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
+ TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
+ return new TwigRenderer($rendererEngine, $csrfTokenManager);
+ },
+ )));
+ $twig->addExtension(new FormExtension());
+ ```
+ * Deprecated the `TwigRendererEngineInterface` interface.
2.7.0
-----
diff --git a/src/Symfony/Bridge/Twig/LICENSE b/src/Symfony/Bridge/Twig/LICENSE
index 12a74531e40a4..17d16a13367dd 100644
--- a/src/Symfony/Bridge/Twig/LICENSE
+++ b/src/Symfony/Bridge/Twig/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2016 Fabien Potencier
+Copyright (c) 2004-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php b/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php
index f9333bf683d1a..1284cf52a20b7 100644
--- a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php
+++ b/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php
@@ -42,7 +42,7 @@ public function __construct(Scope $parent = null)
/**
* Opens a new child scope.
*
- * @return Scope
+ * @return self
*/
public function enter()
{
@@ -52,7 +52,7 @@ public function enter()
/**
* Closes current scope and returns parent one.
*
- * @return Scope|null
+ * @return self|null
*/
public function leave()
{
@@ -67,7 +67,7 @@ public function leave()
* @param string $key
* @param mixed $value
*
- * @return Scope Current scope
+ * @return $this
*
* @throws \LogicException
*/
diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
index c54ad28ea875a..d4d0b135ee1d6 100644
--- a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
@@ -45,7 +45,7 @@ public function testEnvironment()
public function testGetSession()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request->method('getSession')->willReturn($session = new Session());
$this->setRequestStack($request);
@@ -69,10 +69,10 @@ public function testGetRequest()
public function testGetToken()
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->appVariable->setTokenStorage($tokenStorage);
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$tokenStorage->method('getToken')->willReturn($token);
$this->assertEquals($token, $this->appVariable->getToken());
@@ -80,7 +80,7 @@ public function testGetToken()
public function testGetUser()
{
- $this->setTokenStorage($user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'));
+ $this->setTokenStorage($user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock());
$this->assertEquals($user, $this->appVariable->getUser());
}
@@ -94,7 +94,7 @@ public function testGetUserWithUsernameAsTokenUser()
public function testGetTokenWithNoToken()
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->appVariable->setTokenStorage($tokenStorage);
$this->assertNull($this->appVariable->getToken());
@@ -102,7 +102,7 @@ public function testGetTokenWithNoToken()
public function testGetUserWithNoToken()
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->appVariable->setTokenStorage($tokenStorage);
$this->assertNull($this->appVariable->getUser());
@@ -158,7 +158,7 @@ public function testGetSessionWithRequestStackNotSet()
protected function setRequestStack($request)
{
- $requestStackMock = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+ $requestStackMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStackMock->method('getCurrentRequest')->willReturn($request);
$this->appVariable->setRequestStack($requestStackMock);
@@ -166,10 +166,10 @@ protected function setRequestStack($request)
protected function setTokenStorage($user)
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->appVariable->setTokenStorage($tokenStorage);
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$tokenStorage->method('getToken')->willReturn($token);
$token->method('getUser')->willReturn($user);
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php
index 92803be90e662..1d864eadd9faf 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php
@@ -64,7 +64,7 @@ public function getDumpTags()
public function testDump($context, $args, $expectedOutput, $debug = true)
{
$extension = new DumpExtension(new VarCloner());
- $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array(
+ $twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
'debug' => $debug,
'cache' => false,
'optimizations' => 0,
@@ -120,7 +120,7 @@ public function testCustomDumper()
''
);
$extension = new DumpExtension(new VarCloner(), $dumper);
- $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array(
+ $twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
'debug' => true,
'cache' => false,
'optimizations' => 0,
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php
index 7ebaa4c2bad51..614b59f5823ec 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php
@@ -47,7 +47,7 @@ protected function setUp()
'bootstrap_3_horizontal_layout.html.twig',
'custom_widgets.html.twig',
), $environment);
- $this->renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
+ $this->renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php
index f7919a44f964c..aceda8153d434 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php
@@ -43,7 +43,7 @@ protected function setUp()
'bootstrap_3_layout.html.twig',
'custom_widgets.html.twig',
), $environment);
- $this->renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
+ $this->renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
index f9eb355db31b8..34058749bca77 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
@@ -47,7 +47,7 @@ protected function setUp()
'form_div_layout.html.twig',
'custom_widgets.html.twig',
), $environment);
- $this->renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
+ $this->renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php
index a2726af4390c4..8d4396a54c4dd 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php
@@ -44,7 +44,7 @@ protected function setUp()
'form_table_layout.html.twig',
'custom_widgets.html.twig',
), $environment);
- $this->renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
+ $this->renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php
index a583f661d3514..dc88f172dcdd3 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php
@@ -52,7 +52,7 @@ public function testUnknownFragmentRenderer()
protected function getFragmentHandler($return)
{
- $strategy = $this->getMock('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface');
+ $strategy = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface')->getMock();
$strategy->expects($this->once())->method('getName')->will($this->returnValue('inline'));
$strategy->expects($this->once())->method('render')->will($return);
@@ -74,7 +74,7 @@ protected function renderTemplate(FragmentHandler $renderer, $template = '{{ ren
$twig = new \Twig_Environment($loader, array('debug' => true, 'cache' => false));
$twig->addExtension(new HttpKernelExtension());
- $loader = $this->getMock('Twig_RuntimeLoaderInterface');
+ $loader = $this->getMockBuilder('Twig_RuntimeLoaderInterface')->getMock();
$loader->expects($this->any())->method('load')->will($this->returnValueMap(array(
array('Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)),
)));
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
index 9733cd7b8ace6..9f06b50ba0514 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
@@ -20,8 +20,8 @@ class RoutingExtensionTest extends \PHPUnit_Framework_TestCase
*/
public function testEscaping($template, $mustBeEscaped)
{
- $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0));
- $twig->addExtension(new RoutingExtension($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')));
+ $twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0));
+ $twig->addExtension(new RoutingExtension($this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()));
$nodes = $twig->parse($twig->tokenize(new \Twig_Source($template, '')));
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php b/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php
index 12ae07f8d48b0..a6c397ffd4d90 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php
@@ -17,7 +17,7 @@ trait RuntimeLoaderProvider
{
protected function registerTwigRuntimeLoader(\Twig_Environment $environment, TwigRenderer $renderer)
{
- $loader = $this->getMock('Twig_RuntimeLoaderInterface');
+ $loader = $this->getMockBuilder('Twig_RuntimeLoaderInterface')->getMock();
$loader->expects($this->any())->method('load')->will($this->returnValueMap(array(
array('Symfony\Bridge\Twig\Form\TwigRenderer', $renderer),
)));
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php
index daca220e493e0..fe3a6a0d07b21 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php
@@ -53,7 +53,7 @@ public function getTimingTemplates()
protected function getStopwatch($events = array())
{
$events = is_array($events) ? $events : array($events);
- $stopwatch = $this->getMock('Symfony\Component\Stopwatch\Stopwatch');
+ $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
$i = -1;
foreach ($events as $eventName) {
diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php
index 5d669cde7ac94..8507dda94432a 100644
--- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php
@@ -19,7 +19,7 @@ public function testNoVar()
{
$node = new DumpNode('bar', null, 7);
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
@@ -43,7 +43,7 @@ public function testIndented()
{
$node = new DumpNode('bar', null, 7);
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
@@ -70,7 +70,7 @@ public function testOneVar()
));
$node = new DumpNode('bar', $vars, 7);
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
@@ -98,7 +98,7 @@ public function testMultiVars()
));
$node = new DumpNode('bar', $vars, 7);
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php
index dff1d5f5ae090..8e229946514d2 100644
--- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php
@@ -41,7 +41,7 @@ public function testCompile()
$node = new FormThemeNode($form, $resources, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php
index 31ab934f37ec8..f7ffbece9abaa 100644
--- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php
@@ -23,7 +23,7 @@ public function testCompileWidget()
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@@ -46,7 +46,7 @@ public function testCompileWidgetWithVariables()
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@@ -66,7 +66,7 @@ public function testCompileLabelWithLabel()
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@@ -86,7 +86,7 @@ public function testCompileLabelWithNullLabel()
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@@ -108,7 +108,7 @@ public function testCompileLabelWithEmptyStringLabel()
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@@ -129,7 +129,7 @@ public function testCompileLabelWithDefaultLabel()
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@@ -153,7 +153,7 @@ public function testCompileLabelWithAttributes()
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@@ -182,7 +182,7 @@ public function testCompileLabelWithLabelAndAttributes()
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@@ -210,7 +210,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@@ -247,7 +247,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
index 4c00cdab50ade..ec729674e0031 100644
--- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
@@ -24,7 +24,7 @@ public function testCompileStrict()
$vars = new \Twig_Node_Expression_Name('foo', 0);
$node = new TransNode($body, null, null, $vars);
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true));
$compiler = new \Twig_Compiler($env);
$this->assertEquals(
@@ -49,7 +49,7 @@ protected function getVariableGetterWithoutStrictCheck($name)
protected function getVariableGetterWithStrictCheck($name)
{
if (\Twig_Environment::MAJOR_VERSION >= 2) {
- return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : $this->notFound("%s", 0))', $name, $name, $name, $name);
+ return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%s" does not exist.\', 0, $this->getSourceContext()); })())', $name, $name, $name, $name);
}
if (PHP_VERSION_ID >= 70000) {
diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php
index f9cf08bc28017..86dc25266c72d 100644
--- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php
@@ -22,7 +22,7 @@ class TranslationDefaultDomainNodeVisitorTest extends \PHPUnit_Framework_TestCas
/** @dataProvider getDefaultDomainAssignmentTestData */
public function testDefaultDomainAssignment(\Twig_Node $node)
{
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag
@@ -48,7 +48,7 @@ public function testDefaultDomainAssignment(\Twig_Node $node)
/** @dataProvider getDefaultDomainAssignmentTestData */
public function testNewModuleWithoutDefaultDomainTag(\Twig_Node $node)
{
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag
diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php
index 16736031e087d..571b5bba31745 100644
--- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php
@@ -18,7 +18,7 @@ class TranslationNodeVisitorTest extends \PHPUnit_Framework_TestCase
/** @dataProvider getMessagesExtractionTestData */
public function testMessagesExtraction(\Twig_Node $node, array $expectedMessages)
{
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$visitor = new TranslationNodeVisitor();
$visitor->enable();
$visitor->enterNode($node, $env);
diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
index 6b6a92abf1434..6dea9fd693702 100644
--- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
@@ -21,7 +21,7 @@ class FormThemeTokenParserTest extends \PHPUnit_Framework_TestCase
*/
public function testCompile($source, $expected)
{
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env->addTokenParser(new FormThemeTokenParser());
$stream = $env->tokenize(new \Twig_Source($source, ''));
$parser = new \Twig_Parser($env);
diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
index 23869da436d68..4362e9131acb6 100644
--- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
@@ -22,14 +22,14 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase
*/
public function testExtract($template, $messages)
{
- $loader = $this->getMock('Twig_LoaderInterface');
+ $loader = $this->getMockBuilder('Twig_LoaderInterface')->getMock();
$twig = new \Twig_Environment($loader, array(
'strict_variables' => true,
'debug' => true,
'cache' => false,
'autoescape' => false,
));
- $twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));
+ $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()));
$extractor = new TwigExtractor($twig);
$extractor->setPrefix('prefix');
@@ -77,8 +77,8 @@ public function getExtractData()
*/
public function testExtractSyntaxError($resources)
{
- $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
- $twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));
+ $twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
+ $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()));
$extractor = new TwigExtractor($twig);
@@ -120,7 +120,7 @@ public function testExtractWithFiles($resource)
'cache' => false,
'autoescape' => false,
));
- $twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));
+ $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()));
$extractor = new TwigExtractor($twig);
$catalogue = new MessageCatalogue('en');
diff --git a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php
index e7047c354d080..b3eebb55c9871 100644
--- a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php
@@ -71,7 +71,7 @@ protected function getTwig()
'index' => 'foo',
'error' => '{{ foo }',
)));
- $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
+ $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
return new TwigEngine($twig, $parser);
}
diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json
index fd73a7ea3d346..aa5b70fc1dfb4 100644
--- a/src/Symfony/Bridge/Twig/composer.json
+++ b/src/Symfony/Bridge/Twig/composer.json
@@ -22,7 +22,7 @@
"require-dev": {
"symfony/asset": "~2.8|~3.0",
"symfony/finder": "~2.8|~3.0",
- "symfony/form": "~3.0.4",
+ "symfony/form": "~3.1.9|^3.2.2",
"symfony/http-kernel": "~3.2",
"symfony/polyfill-intl-icu": "~1.0",
"symfony/routing": "~2.8|~3.0",
diff --git a/src/Symfony/Bundle/DebugBundle/LICENSE b/src/Symfony/Bundle/DebugBundle/LICENSE
index 39fa189d2b5fc..207646a052dcd 100644
--- a/src/Symfony/Bundle/DebugBundle/LICENSE
+++ b/src/Symfony/Bundle/DebugBundle/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2014-2016 Fabien Potencier
+Copyright (c) 2014-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
index 2c0a435617d4a..a6fb4ed095d2b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
+++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
@@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
+use Doctrine\Common\Annotations\AnnotationException;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\Reader;
use Psr\Cache\CacheItemPoolInterface;
@@ -35,8 +36,8 @@ class AnnotationsCacheWarmer implements CacheWarmerInterface
/**
* @param Reader $annotationReader
- * @param string $phpArrayFile The PHP file where annotations are cached.
- * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered annotations are cached.
+ * @param string $phpArrayFile The PHP file where annotations are cached
+ * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered annotations are cached
*/
public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPoolInterface $fallbackPool)
{
@@ -66,19 +67,27 @@ public function warmUp($cacheDir)
$arrayPool = new ArrayAdapter(0, false);
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayPool));
- $throwingAutoloader = function ($class) { throw new \ReflectionException(sprintf('Class %s does not exist', $class)); };
- spl_autoload_register($throwingAutoloader);
+ spl_autoload_register(array($adapter, 'throwOnRequiredClass'));
try {
foreach ($annotatedClasses as $class) {
try {
$this->readAllComponents($reader, $class);
} catch (\ReflectionException $e) {
// ignore failing reflection
+ } catch (AnnotationException $e) {
+ /*
+ * Ignore any AnnotationException to not break the cache warming process if an Annotation is badly
+ * configured or could not be found / read / etc.
+ *
+ * In particular cases, an Annotation in your code can be used and defined only for a specific
+ * environment but is always added to the annotations.map file by some Symfony default behaviors,
+ * and you always end up with a not found Annotation.
+ */
}
}
} finally {
- spl_autoload_unregister($throwingAutoloader);
+ spl_autoload_unregister(array($adapter, 'throwOnRequiredClass'));
}
$values = $arrayPool->getValues();
diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php
index 23e6142be4993..c017f51268b3d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php
+++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php
@@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
+use Doctrine\Common\Annotations\AnnotationException;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
@@ -36,9 +37,9 @@ class SerializerCacheWarmer implements CacheWarmerInterface
private $fallbackPool;
/**
- * @param LoaderInterface[] $loaders The serializer metadata loaders.
- * @param string $phpArrayFile The PHP file where metadata are cached.
- * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached.
+ * @param LoaderInterface[] $loaders The serializer metadata loaders
+ * @param string $phpArrayFile The PHP file where metadata are cached
+ * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached
*/
public function __construct(array $loaders, $phpArrayFile, CacheItemPoolInterface $fallbackPool)
{
@@ -64,10 +65,21 @@ public function warmUp($cacheDir)
$metadataFactory = new CacheClassMetadataFactory(new ClassMetadataFactory(new LoaderChain($this->loaders)), $arrayPool);
- foreach ($this->extractSupportedLoaders($this->loaders) as $loader) {
- foreach ($loader->getMappedClasses() as $mappedClass) {
- $metadataFactory->getMetadataFor($mappedClass);
+ spl_autoload_register(array($adapter, 'throwOnRequiredClass'));
+ try {
+ foreach ($this->extractSupportedLoaders($this->loaders) as $loader) {
+ foreach ($loader->getMappedClasses() as $mappedClass) {
+ try {
+ $metadataFactory->getMetadataFor($mappedClass);
+ } catch (\ReflectionException $e) {
+ // ignore failing reflection
+ } catch (AnnotationException $e) {
+ // ignore failing annotations
+ }
+ }
}
+ } finally {
+ spl_autoload_unregister(array($adapter, 'throwOnRequiredClass'));
}
$values = $arrayPool->getValues();
diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php
index d450cc1f85237..81291d772fbf0 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php
+++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php
@@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
+use Doctrine\Common\Annotations\AnnotationException;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
@@ -38,8 +39,8 @@ class ValidatorCacheWarmer implements CacheWarmerInterface
/**
* @param ValidatorBuilderInterface $validatorBuilder
- * @param string $phpArrayFile The PHP file where metadata are cached.
- * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached.
+ * @param string $phpArrayFile The PHP file where metadata are cached
+ * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached
*/
public function __construct(ValidatorBuilderInterface $validatorBuilder, $phpArrayFile, CacheItemPoolInterface $fallbackPool)
{
@@ -66,9 +67,7 @@ public function warmUp($cacheDir)
$loaders = $this->validatorBuilder->getLoaders();
$metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), new Psr6Cache($arrayPool));
- $throwingAutoloader = function ($class) { throw new \ReflectionException(sprintf('Class %s does not exist', $class)); };
- spl_autoload_register($throwingAutoloader);
-
+ spl_autoload_register(array($adapter, 'throwOnRequiredClass'));
try {
foreach ($this->extractSupportedLoaders($loaders) as $loader) {
foreach ($loader->getMappedClasses() as $mappedClass) {
@@ -78,15 +77,17 @@ public function warmUp($cacheDir)
}
} catch (\ReflectionException $e) {
// ignore failing reflection
+ } catch (AnnotationException $e) {
+ // ignore failing annotations
}
}
}
} finally {
- spl_autoload_unregister($throwingAutoloader);
+ spl_autoload_unregister(array($adapter, 'throwOnRequiredClass'));
}
$values = $arrayPool->getValues();
- $adapter->warmUp($values);
+ $adapter->warmUp(array_filter($values));
foreach ($values as $k => $v) {
$item = $this->fallbackPool->getItem($k);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php
index 33073b0a91044..921dba0dde977 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php
@@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$configs = $container->resolveEnvPlaceholders($container->getParameterBag()->resolveValue($configs));
$processor = new Processor();
- $config = $processor->processConfiguration($configuration, $configs);
+ $config = $container->resolveEnvPlaceholders($container->getParameterBag()->resolveValue($processor->processConfiguration($configuration, $configs)));
if (null === $path = $input->getArgument('path')) {
$io->title(
@@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io->title(sprintf('Current configuration for "%s.%s"', $extensionAlias, $path));
- $io->writeln(Yaml::dump($container->getParameterBag()->resolveValue($config), 10));
+ $io->writeln(Yaml::dump($config, 10));
}
private function compileContainer()
@@ -130,7 +130,7 @@ private function compileContainer()
*
* @return mixed
*/
- private function getConfigForPath(array $config = array(), $path, $alias)
+ private function getConfigForPath(array $config, $path, $alias)
{
$steps = explode('.', $path);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php
index ccfa5dde6b7e8..72584377d7abf 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php
@@ -54,7 +54,9 @@ protected function isOtherServerProcessRunning($address)
return true;
}
- list($hostname, $port) = explode(':', $address);
+ $pos = strrpos($address, ':');
+ $hostname = substr($address, 0, $pos);
+ $port = substr($address, $pos + 1);
$fp = @fsockopen($hostname, $port, $errno, $errstr, 5);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php
index d222bc7ea37a2..1d4c44c6b4714 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php
@@ -36,8 +36,13 @@ class TemplateController implements ContainerAwareInterface
*/
public function templateAction($template, $maxAge = null, $sharedAge = null, $private = null)
{
- /** @var $response \Symfony\Component\HttpFoundation\Response */
- $response = $this->container->get('templating')->renderResponse($template);
+ if ($this->container->has('templating')) {
+ $response = $this->container->get('templating')->renderResponse($template);
+ } elseif ($this->container->has('twig')) {
+ $response = new Response($this->container->get('twig')->render($template));
+ } else {
+ throw new \LogicException('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.');
+ }
if ($maxAge) {
$response->setMaxAge($maxAge);
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php
index df02d65259a8d..db1430eb49b13 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php
@@ -36,7 +36,6 @@ public function process(ContainerBuilder $container)
}
$seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment');
- $aliases = $container->getAliases();
$attributes = array(
'provider',
'namespace',
@@ -57,9 +56,9 @@ public function process(ContainerBuilder $container)
$tags[0]['namespace'] = $this->getNamespace($seed, $id);
}
if (isset($tags[0]['clearer'])) {
- $clearer = strtolower($tags[0]['clearer']);
- while (isset($aliases[$clearer])) {
- $clearer = (string) $aliases[$clearer];
+ $clearer = $tags[0]['clearer'];
+ while ($container->hasAlias($clearer)) {
+ $clearer = (string) $container->getAlias($clearer);
}
} else {
$clearer = null;
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
index adb825b7c3dfd..4a8fef38d3093 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
+use Doctrine\Common\Annotations\Annotation;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
@@ -295,11 +296,33 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->end()
->end()
->arrayNode('transitions')
- ->useAttributeAsKey('name')
+ ->beforeNormalization()
+ ->always()
+ ->then(function ($transitions) {
+ // It's an indexed array, we let the validation occurs
+ if (isset($transitions[0])) {
+ return $transitions;
+ }
+
+ foreach ($transitions as $name => $transition) {
+ if (array_key_exists('name', $transition)) {
+ continue;
+ }
+ $transition['name'] = $name;
+ $transitions[$name] = $transition;
+ }
+
+ return $transitions;
+ })
+ ->end()
->isRequired()
->requiresAtLeastOneElement()
->prototype('array')
->children()
+ ->scalarNode('name')
+ ->isRequired()
+ ->cannotBeEmpty()
+ ->end()
->arrayNode('from')
->beforeNormalization()
->ifString()
@@ -602,7 +625,7 @@ private function addAnnotationsSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('annotations')
->info('annotation configuration')
- ->canBeDisabled()
+ ->{class_exists(Annotation::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->children()
->scalarNode('cache')->defaultValue('php_array')->end()
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 61a7d7a9170d3..e6eb049e2ce83 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -206,9 +206,6 @@ public function load(array $configs, ContainerBuilder $container)
'Symfony\\Component\\EventDispatcher\\Event',
'Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher',
- 'Symfony\\Component\\HttpFoundation\\Response',
- 'Symfony\\Component\\HttpFoundation\\ResponseHeaderBag',
-
'Symfony\\Component\\HttpKernel\\EventListener\\ResponseListener',
'Symfony\\Component\\HttpKernel\\EventListener\\RouterListener',
'Symfony\\Component\\HttpKernel\\Bundle\\Bundle',
@@ -408,13 +405,13 @@ private function registerWorkflowConfiguration(array $workflows, ContainerBuilde
$type = $workflow['type'];
$transitions = array();
- foreach ($workflow['transitions'] as $transitionName => $transition) {
+ foreach ($workflow['transitions'] as $transition) {
if ($type === 'workflow') {
- $transitions[] = new Definition(Workflow\Transition::class, array($transitionName, $transition['from'], $transition['to']));
+ $transitions[] = new Definition(Workflow\Transition::class, array($transition['name'], $transition['from'], $transition['to']));
} elseif ($type === 'state_machine') {
foreach ($transition['from'] as $from) {
foreach ($transition['to'] as $to) {
- $transitions[] = new Definition(Workflow\Transition::class, array($transitionName, $from, $to));
+ $transitions[] = new Definition(Workflow\Transition::class, array($transition['name'], $from, $to));
}
}
}
@@ -845,12 +842,11 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
$dirs[] = dirname(dirname($r->getFileName())).'/Resources/translations';
}
$rootDir = $container->getParameter('kernel.root_dir');
- foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
- $reflection = new \ReflectionClass($class);
- if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) {
+ foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
+ if (is_dir($dir = $bundle['path'].'/Resources/translations')) {
$dirs[] = $dir;
}
- if (is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $bundle))) {
+ if (is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) {
$dirs[] = $dir;
}
}
@@ -913,6 +909,10 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
return;
}
+ if (!class_exists('Symfony\Component\Validator\Validation')) {
+ throw new LogicException('Validation support cannot be enabled as the Validator component is not installed.');
+ }
+
$loader->load('validator.xml');
$validatorBuilder = $container->getDefinition('validator.builder');
@@ -969,11 +969,8 @@ private function getValidatorMappingFiles(ContainerBuilder $container)
$container->addResource(new FileResource($files[0][0]));
}
- $bundles = $container->getParameter('kernel.bundles');
- foreach ($bundles as $bundle) {
- $reflection = new \ReflectionClass($bundle);
- $dirname = dirname($reflection->getFileName());
-
+ foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
+ $dirname = $bundle['path'];
if (is_file($file = $dirname.'/Resources/config/validation.xml')) {
$files[0][] = $file;
$container->addResource(new FileResource($file));
@@ -1146,10 +1143,8 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
$serializerLoaders[] = $annotationLoader;
}
- $bundles = $container->getParameter('kernel.bundles');
- foreach ($bundles as $bundle) {
- $reflection = new \ReflectionClass($bundle);
- $dirname = dirname($reflection->getFileName());
+ foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
+ $dirname = $bundle['path'];
if (is_file($file = $dirname.'/Resources/config/serialization.xml')) {
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($file));
diff --git a/src/Symfony/Bundle/FrameworkBundle/LICENSE b/src/Symfony/Bundle/FrameworkBundle/LICENSE
index 12a74531e40a4..17d16a13367dd 100644
--- a/src/Symfony/Bundle/FrameworkBundle/LICENSE
+++ b/src/Symfony/Bundle/FrameworkBundle/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2016 Fabien Potencier
+Copyright (c) 2004-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_attributes.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_attributes.html.php
index 2be960d0e179c..56b3dd92846d3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_attributes.html.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_attributes.html.php
@@ -1,6 +1,6 @@
id="escape($id) ?>" name="escape($full_name) ?>" disabled="disabled"
$v): ?>
-
+
escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
escape($k), $view->escape($k)) ?>
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_container_attributes.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_container_attributes.html.php
index dc2e5ebea84e6..c4dff7b61f4e0 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_container_attributes.html.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_container_attributes.html.php
@@ -1,6 +1,6 @@
id="escape($id) ?>"
$v): ?>
-
+
escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
escape($k), $view->escape($k)) ?>
diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php
index bf6e795d80cc8..31fd9a368ff72 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php
@@ -24,6 +24,8 @@ class TemplateLocator implements FileLocatorInterface
protected $locator;
protected $cache;
+ private $cacheHits = array();
+
/**
* Constructor.
*
@@ -71,12 +73,15 @@ public function locate($template, $currentPath = null, $first = true)
$key = $this->getCacheKey($template);
+ if (isset($this->cacheHits[$key])) {
+ return $this->cacheHits[$key];
+ }
if (isset($this->cache[$key])) {
- return $this->cache[$key];
+ return $this->cacheHits[$key] = realpath($this->cache[$key]) ?: $this->cache[$key];
}
try {
- return $this->cache[$key] = $this->locator->locate($template->getPath(), $currentPath);
+ return $this->cacheHits[$key] = $this->locator->locate($template->getPath(), $currentPath);
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException(sprintf('Unable to find template "%s" : "%s".', $template, $e->getMessage()), 0, $e);
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php
index 0e3fe47ce5ff8..23b4732afcb3a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php
@@ -51,6 +51,39 @@ public function testWarmUp()
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author', $values);
}
+ public function testWarmUpWithAnnotations()
+ {
+ $validatorBuilder = new ValidatorBuilder();
+ $validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/categories.yml');
+ $validatorBuilder->enableAnnotationMapping();
+
+ $file = sys_get_temp_dir().'/cache-validator-with-annotations.php';
+ @unlink($file);
+
+ $fallbackPool = new ArrayAdapter();
+
+ $warmer = new ValidatorCacheWarmer($validatorBuilder, $file, $fallbackPool);
+ $warmer->warmUp(dirname($file));
+
+ $this->assertFileExists($file);
+
+ $values = require $file;
+
+ $this->assertInternalType('array', $values);
+ $this->assertCount(1, $values);
+ $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category', $values);
+
+ // Simple check to make sure that at least one constraint is actually cached, in this case the "id" property Type.
+ $this->assertContains('"int"', $values['Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category']);
+
+ $values = $fallbackPool->getValues();
+
+ $this->assertInternalType('array', $values);
+ $this->assertCount(2, $values);
+ $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category', $values);
+ $this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.SubCategory', $values);
+ }
+
public function testWarmUpWithoutLoader()
{
$validatorBuilder = new ValidatorBuilder();
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php
index e42babd362404..30b3242a5c003 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php
@@ -63,7 +63,7 @@ private function getContainer()
{
$routeCollection = new RouteCollection();
$routeCollection->add('foo', new Route('foo'));
- $router = $this->getMock('Symfony\Component\Routing\RouterInterface');
+ $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router
->expects($this->any())
->method('getRouteCollection')
@@ -74,7 +74,7 @@ private function getContainer()
->disableOriginalConstructor()
->getMock();
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
->method('has')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php
index 3dc64a300e8c6..1caa5df9d9f23 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php
@@ -62,7 +62,7 @@ private function getContainer()
$routeCollection = new RouteCollection();
$routeCollection->add('foo', new Route('foo'));
$requestContext = new RequestContext();
- $router = $this->getMock('Symfony\Component\Routing\RouterInterface');
+ $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router
->expects($this->any())
->method('getRouteCollection')
@@ -78,7 +78,7 @@ private function getContainer()
->disableOriginalConstructor()
->getMock();
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
->method('has')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php
index 27f61c4383f24..60f81565d36de 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php
@@ -64,7 +64,7 @@ public function testDebugDefaultDirectory()
public function testDebugCustomDirectory()
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel->expects($this->once())
->method('getBundle')
->with($this->equalTo($this->translationDir))
@@ -82,7 +82,7 @@ public function testDebugCustomDirectory()
*/
public function testDebugInvalidDirectory()
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel->expects($this->once())
->method('getBundle')
->with($this->equalTo('dir'))
@@ -130,7 +130,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
->method('getFallbackLocales')
->will($this->returnValue(array('en')));
- $extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface');
+ $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$extractor
->expects($this->any())
->method('extract')
@@ -140,7 +140,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
})
);
- $loader = $this->getMock('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader');
+ $loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
$loader
->expects($this->any())
->method('loadMessages')
@@ -151,7 +151,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
);
if (null === $kernel) {
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundle')
@@ -166,7 +166,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
->method('getRootDir')
->will($this->returnValue($this->translationDir));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->any())
->method('get')
@@ -182,7 +182,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
private function getBundle($path)
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle
->expects($this->any())
->method('getPath')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
index c876ee415de3c..3dcbd03ff0d0f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
@@ -100,7 +100,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
->method('getFallbackLocales')
->will($this->returnValue(array('en')));
- $extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface');
+ $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$extractor
->expects($this->any())
->method('extract')
@@ -112,7 +112,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
})
);
- $loader = $this->getMock('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader');
+ $loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
$loader
->expects($this->any())
->method('loadMessages')
@@ -122,7 +122,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
})
);
- $writer = $this->getMock('Symfony\Component\Translation\Writer\TranslationWriter');
+ $writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
$writer
->expects($this->any())
->method('getFormats')
@@ -131,7 +131,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
);
if (null === $kernel) {
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundle')
@@ -146,7 +146,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
->method('getRootDir')
->will($this->returnValue($this->translationDir));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->any())
->method('get')
@@ -163,7 +163,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
private function getBundle($path)
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle
->expects($this->any())
->method('getPath')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
index a944da863f6d0..fc60fd3bdd71c 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
@@ -22,7 +22,7 @@ class ApplicationTest extends TestCase
{
public function testBundleInterfaceImplementation()
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$kernel = $this->getKernel(array($bundle), true);
@@ -117,10 +117,10 @@ public function testBundleCommandsHaveRightContainer()
private function getKernel(array $bundles, $useDispatcher = false)
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
if ($useDispatcher) {
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$dispatcher
->expects($this->atLeastOnce())
->method('dispatch')
@@ -145,7 +145,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
->will($this->returnValue(array()))
;
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundles')
@@ -162,7 +162,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
private function createBundleMock(array $commands)
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
$bundle
->expects($this->once())
->method('registerCommands')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
index 894e7ae3285d3..2fe271663e2d3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
@@ -147,7 +147,7 @@ private function createParser()
'FabpotFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')),
);
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundle')
@@ -178,7 +178,7 @@ private function createParser()
private function getBundle($namespace, $name)
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle->expects($this->any())->method('getName')->will($this->returnValue($name));
$bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php
index b511f90d17adb..6c79a33657279 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php
@@ -179,12 +179,12 @@ protected function createControllerResolver(LoggerInterface $logger = null, Cont
protected function createMockParser()
{
- return $this->getMock('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser', array(), array(), '', false);
+ return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser')->disableOriginalConstructor()->getMock();
}
protected function createMockContainer()
{
- return $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
}
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php
index 2821e7faf837e..80908a9e5b91f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php
@@ -40,12 +40,12 @@ public function testForward()
$requestStack = new RequestStack();
$requestStack->push($request);
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
return new Response($request->getRequestFormat().'--'.$request->getLocale());
}));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($requestStack));
$container->expects($this->at(1))->method('get')->will($this->returnValue($kernel));
@@ -91,7 +91,7 @@ public function testGetUserWithEmptyTokenStorage()
*/
public function testGetUserWithEmptyContainer()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
->method('has')
@@ -111,13 +111,13 @@ public function testGetUserWithEmptyContainer()
*/
private function getContainerWithTokenStorage($token = null)
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage')->getMock();
$tokenStorage
->expects($this->once())
->method('getToken')
->will($this->returnValue($token));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
->method('has')
@@ -135,7 +135,7 @@ private function getContainerWithTokenStorage($token = null)
public function testJson()
{
- $container = $this->getMock(ContainerInterface::class);
+ $container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$container
->expects($this->once())
->method('has')
@@ -152,14 +152,14 @@ public function testJson()
public function testJsonWithSerializer()
{
- $container = $this->getMock(ContainerInterface::class);
+ $container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$container
->expects($this->once())
->method('has')
->with('serializer')
->will($this->returnValue(true));
- $serializer = $this->getMock(SerializerInterface::class);
+ $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
$serializer
->expects($this->once())
->method('serialize')
@@ -182,14 +182,14 @@ public function testJsonWithSerializer()
public function testJsonWithSerializerContextOverride()
{
- $container = $this->getMock(ContainerInterface::class);
+ $container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$container
->expects($this->once())
->method('has')
->with('serializer')
->will($this->returnValue(true));
- $serializer = $this->getMock(SerializerInterface::class);
+ $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
$serializer
->expects($this->once())
->method('serialize')
@@ -215,8 +215,8 @@ public function testJsonWithSerializerContextOverride()
public function testFile()
{
/* @var ContainerInterface $container */
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$container->set('kernel', $kernel);
$controller = new TestController();
@@ -235,7 +235,7 @@ public function testFile()
public function testFileAsInline()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$controller = new TestController();
$controller->setContainer($container);
@@ -253,7 +253,7 @@ public function testFileAsInline()
public function testFileWithOwnFileName()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$controller = new TestController();
$controller->setContainer($container);
@@ -272,7 +272,7 @@ public function testFileWithOwnFileName()
public function testFileWithOwnFileNameAsInline()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$controller = new TestController();
$controller->setContainer($container);
@@ -334,10 +334,10 @@ public function testFileWhichDoesNotExist()
public function testIsGranted()
{
- $authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');
+ $authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock();
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(true);
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($authorizationChecker));
@@ -352,10 +352,10 @@ public function testIsGranted()
*/
public function testdenyAccessUnlessGranted()
{
- $authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');
+ $authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock();
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false);
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($authorizationChecker));
@@ -370,7 +370,7 @@ public function testRenderViewTwig()
$twig = $this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock();
$twig->expects($this->once())->method('render')->willReturn('bar');
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(false));
$container->expects($this->at(1))->method('has')->will($this->returnValue(true));
$container->expects($this->at(2))->method('get')->will($this->returnValue($twig));
@@ -386,7 +386,7 @@ public function testRenderTwig()
$twig = $this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock();
$twig->expects($this->once())->method('render')->willReturn('bar');
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(false));
$container->expects($this->at(1))->method('has')->will($this->returnValue(true));
$container->expects($this->at(2))->method('get')->will($this->returnValue($twig));
@@ -401,7 +401,7 @@ public function testStreamTwig()
{
$twig = $this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock();
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(false));
$container->expects($this->at(1))->method('has')->will($this->returnValue(true));
$container->expects($this->at(2))->method('get')->will($this->returnValue($twig));
@@ -414,10 +414,10 @@ public function testStreamTwig()
public function testRedirectToRoute()
{
- $router = $this->getMock('Symfony\Component\Routing\RouterInterface');
+ $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router->expects($this->once())->method('generate')->willReturn('/foo');
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($router));
$controller = new TestController();
@@ -432,10 +432,10 @@ public function testRedirectToRoute()
public function testAddFlash()
{
$flashBag = new FlashBag();
- $session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session');
+ $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->getMock();
$session->expects($this->once())->method('getFlashBag')->willReturn($flashBag);
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($session));
@@ -455,10 +455,10 @@ public function testCreateAccessDeniedException()
public function testIsCsrfTokenValid()
{
- $tokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface');
+ $tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
$tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true);
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($tokenManager));
@@ -470,10 +470,10 @@ public function testIsCsrfTokenValid()
public function testGenerateUrl()
{
- $router = $this->getMock('Symfony\Component\Routing\RouterInterface');
+ $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router->expects($this->once())->method('generate')->willReturn('/foo');
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($router));
$controller = new TestController();
@@ -494,10 +494,10 @@ public function testRedirect()
public function testRenderViewTemplating()
{
- $templating = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
+ $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
$templating->expects($this->once())->method('render')->willReturn('bar');
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->willReturn(true);
$container->expects($this->at(1))->method('get')->will($this->returnValue($templating));
@@ -509,10 +509,10 @@ public function testRenderViewTemplating()
public function testRenderTemplating()
{
- $templating = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
+ $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
$templating->expects($this->once())->method('renderResponse')->willReturn(new Response('bar'));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->willReturn(true);
$container->expects($this->at(1))->method('get')->will($this->returnValue($templating));
@@ -524,9 +524,9 @@ public function testRenderTemplating()
public function testStreamTemplating()
{
- $templating = $this->getMock('Symfony\Component\Routing\RouterInterface');
+ $templating = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->willReturn(true);
$container->expects($this->at(1))->method('get')->will($this->returnValue($templating));
@@ -545,12 +545,12 @@ public function testCreateNotFoundException()
public function testCreateForm()
{
- $form = $this->getMock('Symfony\Component\Form\FormInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\FormInterface')->getMock();
- $formFactory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
+ $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$formFactory->expects($this->once())->method('create')->willReturn($form);
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory));
$controller = new TestController();
@@ -561,12 +561,12 @@ public function testCreateForm()
public function testCreateFormBuilder()
{
- $formBuilder = $this->getMock('Symfony\Component\Form\FormBuilderInterface');
+ $formBuilder = $this->getMockBuilder('Symfony\Component\Form\FormBuilderInterface')->getMock();
- $formFactory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
+ $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder);
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory));
$controller = new TestController();
@@ -577,9 +577,9 @@ public function testCreateFormBuilder()
public function testGetDoctrine()
{
- $doctrine = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $doctrine = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($doctrine));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
index eaca189330599..14b6e4428e550 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
@@ -66,14 +66,14 @@ public function testRoute($permanent, $ignoreAttributes, $expectedCode, $expecte
$request->attributes = new ParameterBag($attributes);
- $router = $this->getMock('Symfony\Component\Routing\RouterInterface');
+ $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router
->expects($this->once())
->method('generate')
->with($this->equalTo($route), $this->equalTo($expectedAttributes))
->will($this->returnValue($url));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
@@ -230,7 +230,7 @@ public function testPathQueryParams($expectedUrl, $path, $queryString)
private function createRequestObject($scheme, $host, $port, $baseUrl, $queryString = '')
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request
->expects($this->any())
->method('getScheme')
@@ -257,7 +257,7 @@ private function createRequestObject($scheme, $host, $port, $baseUrl, $queryStri
private function createRedirectController($httpPort = null, $httpsPort = null)
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
if (null !== $httpPort) {
$container
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php
new file mode 100644
index 0000000000000..04e6447ee93ea
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php
@@ -0,0 +1,69 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\TemplateController;
+use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
+use Symfony\Component\HttpFoundation\Response;
+
+/**
+ * @author Kévin Dunglas
+ */
+class TemplateControllerTest extends TestCase
+{
+ public function testTwig()
+ {
+ $twig = $this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock();
+ $twig->expects($this->once())->method('render')->willReturn('bar');
+
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
+ $container->expects($this->at(0))->method('has')->will($this->returnValue(false));
+ $container->expects($this->at(1))->method('has')->will($this->returnValue(true));
+ $container->expects($this->at(2))->method('get')->will($this->returnValue($twig));
+
+ $controller = new TemplateController();
+ $controller->setContainer($container);
+
+ $this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent());
+ }
+
+ public function testTemplating()
+ {
+ $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
+ $templating->expects($this->once())->method('renderResponse')->willReturn(new Response('bar'));
+
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
+ $container->expects($this->at(0))->method('has')->willReturn(true);
+ $container->expects($this->at(1))->method('get')->will($this->returnValue($templating));
+
+ $controller = new TemplateController();
+ $controller->setContainer($container);
+
+ $this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent());
+ }
+
+ /**
+ * @expectedException \LogicException
+ * @expectedExceptionMessage You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.
+ */
+ public function testNoTwigNorTemplating()
+ {
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
+ $container->expects($this->at(0))->method('has')->willReturn(false);
+ $container->expects($this->at(1))->method('has')->willReturn(false);
+
+ $controller = new TemplateController();
+ $controller->setContainer($container);
+
+ $controller->templateAction('mytemplate')->getContent();
+ }
+}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php
index 204fdf09b653e..73172d54a3058 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php
@@ -24,11 +24,8 @@ public function testThatCacheWarmersAreProcessedInPriorityOrder()
'my_cache_warmer_service3' => array(0 => array()),
);
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('findTaggedServiceIds', 'getDefinition', 'hasDefinition')
- );
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
$container->expects($this->atLeastOnce())
->method('findTaggedServiceIds')
@@ -56,11 +53,8 @@ public function testThatCacheWarmersAreProcessedInPriorityOrder()
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$container->expects($this->never())->method('findTaggedServiceIds');
$container->expects($this->never())->method('getDefinition');
@@ -76,11 +70,8 @@ public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
public function testThatCacheWarmersMightBeNotDefined()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$container->expects($this->atLeastOnce())
->method('findTaggedServiceIds')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php
index 0629d1ebafd1f..88901dda70bd2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php
@@ -20,14 +20,11 @@ public function testThatConstraintValidatorServicesAreProcessed()
'my_constraint_validator_service2' => array(),
);
- $validatorFactoryDefinition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('findTaggedServiceIds', 'getDefinition', 'hasDefinition')
- );
+ $validatorFactoryDefinition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
- $validatorDefinition1 = $this->getMock('Symfony\Component\DependencyInjection\Definition', array('getClass'));
- $validatorDefinition2 = $this->getMock('Symfony\Component\DependencyInjection\Definition', array('getClass'));
+ $validatorDefinition1 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->setMethods(array('getClass'))->getMock();
+ $validatorDefinition2 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->setMethods(array('getClass'))->getMock();
$validatorDefinition1->expects($this->atLeastOnce())
->method('getClass')
@@ -67,11 +64,8 @@ public function testThatConstraintValidatorServicesAreProcessed()
public function testThatCompilerPassIsIgnoredIfThereIsNoConstraintValidatorFactoryDefinition()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$container->expects($this->never())->method('findTaggedServiceIds');
$container->expects($this->never())->method('getDefinition');
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php
index 48c753b6e2d45..19353d8bcb2ee 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php
@@ -24,11 +24,8 @@ public function testThatCheckersAreProcessedInPriorityOrder()
'checker_3' => array(0 => array()),
);
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('findTaggedServiceIds', 'getDefinition', 'hasDefinition')
- );
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
$container->expects($this->atLeastOnce())
->method('findTaggedServiceIds')
@@ -52,10 +49,7 @@ public function testThatCheckersAreProcessedInPriorityOrder()
public function testThatCheckersCanBeMissing()
{
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('findTaggedServiceIds')
- );
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container->expects($this->atLeastOnce())
->method('findTaggedServiceIds')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php
index 77f894faa9d68..5de27ba4916d5 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php
@@ -17,9 +17,9 @@ class LoggingTranslatorPassTest extends \PHPUnit_Framework_TestCase
{
public function testProcess()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
- $parameterBag = $this->getMock('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
+ $parameterBag = $this->getMockBuilder('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface')->getMock();
$container->expects($this->exactly(2))
->method('hasAlias')
@@ -60,7 +60,7 @@ public function testProcess()
public function testThatCompilerPassIsIgnoredIfThereIsNotLoggerDefinition()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
$container->expects($this->once())
->method('hasAlias')
->will($this->returnValue(false));
@@ -71,7 +71,7 @@ public function testThatCompilerPassIsIgnoredIfThereIsNotLoggerDefinition()
public function testThatCompilerPassIsIgnoredIfThereIsNotTranslatorDefinition()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
$container->expects($this->at(0))
->method('hasAlias')
->will($this->returnValue(true));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php
index f2af872e3c1f9..9edb44ebb6e1c 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php
@@ -75,10 +75,7 @@ public function testValidCollector()
private function createContainerMock($services)
{
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'setParameter')
- );
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'setParameter'))->getMock();
$container->expects($this->any())
->method('hasDefinition')
->with($this->equalTo('profiler'))
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php
index fca0f3461ff8a..c0030ba879a45 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php
@@ -30,7 +30,7 @@ public function testServicesAreOrderedAccordingToPriority()
new Reference('n3'),
);
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('findTaggedServiceIds'));
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container
->expects($this->any())
@@ -52,7 +52,7 @@ public function testServicesAreOrderedAccordingToPriority()
public function testReturningEmptyArrayWhenNoService()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('findTaggedServiceIds'));
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container
->expects($this->any())
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php
index 27f1636e8ce9d..16a724b46079a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php
@@ -23,7 +23,7 @@ class SerializerPassTest extends \PHPUnit_Framework_TestCase
{
public function testThrowExceptionWhenNoNormalizers()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('hasDefinition', 'findTaggedServiceIds'));
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds'))->getMock();
$container->expects($this->once())
->method('hasDefinition')
@@ -43,11 +43,8 @@ public function testThrowExceptionWhenNoNormalizers()
public function testThrowExceptionWhenNoEncoders()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$container->expects($this->once())
->method('hasDefinition')
@@ -85,7 +82,7 @@ public function testServicesAreOrderedAccordingToPriority()
new Reference('n3'),
);
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('findTaggedServiceIds'));
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container->expects($this->any())
->method('findTaggedServiceIds')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php
index 83f70514d5456..dcdb0bc5bd377 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php
@@ -18,7 +18,7 @@ class TranslatorPassTest extends \PHPUnit_Framework_TestCase
{
public function testValidCollector()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->at(0))
->method('addMethodCall')
->with('addLoader', array('xliff', new Reference('xliff')));
@@ -26,10 +26,7 @@ public function testValidCollector()
->method('addMethodCall')
->with('addLoader', array('xlf', new Reference('xliff')));
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'findDefinition')
- );
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'findDefinition'))->getMock();
$container->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
@@ -41,7 +38,7 @@ public function testValidCollector()
->will($this->returnValue(array('xliff' => array(array('alias' => 'xliff', 'legacy-alias' => 'xlf')))));
$container->expects($this->once())
->method('findDefinition')
- ->will($this->returnValue($this->getMock('Symfony\Component\DependencyInjection\Definition')));
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock()));
$pass = new TranslatorPass();
$pass->process($container);
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php
index f354007bb982d..02f5e6b672478 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php
@@ -19,19 +19,17 @@ public function testProcess()
{
$pass = new UnusedTagsPass();
- $formatter = $this->getMock('Symfony\Component\DependencyInjection\Compiler\LoggingFormatter');
+ $formatter = $this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\LoggingFormatter')->getMock();
$formatter
->expects($this->at(0))
->method('format')
->with($pass, 'Tag "kenrel.event_subscriber" was defined on service(s) "foo", "bar", but was never used. Did you mean "kernel.event_subscriber"?')
;
- $compiler = $this->getMock('Symfony\Component\DependencyInjection\Compiler\Compiler');
+ $compiler = $this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\Compiler')->getMock();
$compiler->expects($this->once())->method('getLoggingFormatter')->will($this->returnValue($formatter));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder',
- array('findTaggedServiceIds', 'getCompiler', 'findUnusedTags', 'findTags')
- );
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getCompiler', 'findUnusedTags', 'findTags'))->getMock();
$container->expects($this->once())->method('getCompiler')->will($this->returnValue($compiler));
$container->expects($this->once())
->method('findTags')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources/config/validation.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources/config/validation.xml
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources/config/validation.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources/config/validation.yml
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php
new file mode 100644
index 0000000000000..31cec239d894f
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php
@@ -0,0 +1,20 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bundle\FrameworkBundle\Tests;
+
+class CustomPathBundle extends \Symfony\Component\HttpKernel\Bundle\Bundle
+{
+ public function getPath()
+ {
+ return __DIR__.'/..';
+ }
+}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php
new file mode 100644
index 0000000000000..2619a2dd4316a
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php
@@ -0,0 +1,49 @@
+loadFromExtension('framework', array(
+ 'workflows' => array(
+ 'article' => array(
+ 'type' => 'workflow',
+ 'marking_store' => array(
+ 'type' => 'multiple_state',
+ ),
+ 'supports' => array(
+ FrameworkExtensionTest::class,
+ ),
+ 'initial_place' => 'draft',
+ 'places' => array(
+ 'draft',
+ 'wait_for_journalist',
+ 'approved_by_journalist',
+ 'wait_for_spellchecker',
+ 'approved_by_spellchecker',
+ 'published',
+ ),
+ 'transitions' => array(
+ 'request_review' => array(
+ 'from' => 'draft',
+ 'to' => array('wait_for_journalist', 'wait_for_spellchecker'),
+ ),
+ 'journalist_approval' => array(
+ 'from' => 'wait_for_journalist',
+ 'to' => 'approved_by_journalist',
+ ),
+ 'spellchecker_approval' => array(
+ 'from' => 'wait_for_spellchecker',
+ 'to' => 'approved_by_spellchecker',
+ ),
+ 'publish' => array(
+ 'from' => array('approved_by_journalist', 'approved_by_spellchecker'),
+ 'to' => 'published',
+ ),
+ 'publish_editor_in_chief' => array(
+ 'name' => 'publish',
+ 'from' => 'draft',
+ 'to' => 'published',
+ ),
+ ),
+ ),
+ ),
+));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml
new file mode 100644
index 0000000000000..d52aed8c95234
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+ a
+ a
+
+ Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
+ draft
+ wait_for_journalist
+ approved_by_journalist
+ wait_for_spellchecker
+ approved_by_spellchecker
+ published
+
+ draft
+ wait_for_journalist
+ wait_for_spellchecker
+
+
+ wait_for_journalist
+ approved_by_journalist
+
+
+ wait_for_spellchecker
+ approved_by_spellchecker
+
+
+ approved_by_journalist
+ approved_by_spellchecker
+ published
+
+
+ draft
+ published
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml
new file mode 100644
index 0000000000000..36d00de46501c
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml
@@ -0,0 +1,33 @@
+framework:
+ workflows:
+ article:
+ type: workflow
+ marking_store:
+ type: multiple_state
+ supports:
+ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
+ initial_place: draft
+ places:
+ - draft
+ - wait_for_journalist
+ - approved_by_journalist
+ - wait_for_spellchecker
+ - approved_by_spellchecker
+ - published
+ transitions:
+ request_review:
+ from: [draft]
+ to: [wait_for_journalist, wait_for_spellchecker]
+ journalist_approval:
+ from: [wait_for_journalist]
+ to: [approved_by_journalist]
+ spellchecker_approval:
+ from: [wait_for_spellchecker]
+ to: [approved_by_spellchecker]
+ publish:
+ from: [approved_by_journalist, approved_by_spellchecker]
+ to: [published]
+ publish_editor_in_chief:
+ name: publish
+ from: [draft]
+ to: [published]
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 26792c6b1c1d9..4663ee4ba66b7 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -190,6 +190,29 @@ public function testWorkflowCannotHaveBothArgumentsAndService()
$this->createContainerFromFile('workflow_with_arguments_and_service');
}
+ public function testWorkflowMultipleTransitionsWithSameName()
+ {
+ $container = $this->createContainerFromFile('workflow_with_multiple_transitions_with_same_name');
+
+ $this->assertTrue($container->hasDefinition('workflow.article', 'Workflow is registered as a service'));
+ $this->assertTrue($container->hasDefinition('workflow.article.definition', 'Workflow definition is registered as a service'));
+
+ $workflowDefinition = $container->getDefinition('workflow.article.definition');
+
+ $transitions = $workflowDefinition->getArgument(1);
+
+ $this->assertCount(5, $transitions);
+
+ $this->assertSame('request_review', $transitions[0]->getArgument(0));
+ $this->assertSame('journalist_approval', $transitions[1]->getArgument(0));
+ $this->assertSame('spellchecker_approval', $transitions[2]->getArgument(0));
+ $this->assertSame('publish', $transitions[3]->getArgument(0));
+ $this->assertSame('publish', $transitions[4]->getArgument(0));
+
+ $this->assertSame(array('approved_by_journalist', 'approved_by_spellchecker'), $transitions[3]->getArgument(1));
+ $this->assertSame(array('draft'), $transitions[4]->getArgument(1));
+ }
+
public function testRouter()
{
$container = $this->createContainerFromFile('full');
@@ -294,26 +317,26 @@ public function testAssets()
$packages = $container->getDefinition('assets.packages');
// default package
- $defaultPackage = $container->getDefinition($packages->getArgument(0));
+ $defaultPackage = $container->getDefinition((string) $packages->getArgument(0));
$this->assertUrlPackage($container, $defaultPackage, array('http://cdn.example.com'), 'SomeVersionScheme', '%%s?version=%%s');
// packages
$packages = $packages->getArgument(1);
$this->assertCount(5, $packages);
- $package = $container->getDefinition($packages['images_path']);
+ $package = $container->getDefinition((string) $packages['images_path']);
$this->assertPathPackage($container, $package, '/foo', 'SomeVersionScheme', '%%s?version=%%s');
- $package = $container->getDefinition($packages['images']);
+ $package = $container->getDefinition((string) $packages['images']);
$this->assertUrlPackage($container, $package, array('http://images1.example.com', 'http://images2.example.com'), '1.0.0', '%%s?version=%%s');
- $package = $container->getDefinition($packages['foo']);
+ $package = $container->getDefinition((string) $packages['foo']);
$this->assertPathPackage($container, $package, '', '1.0.0', '%%s-%%s');
- $package = $container->getDefinition($packages['bar']);
+ $package = $container->getDefinition((string) $packages['bar']);
$this->assertUrlPackage($container, $package, array('https://bar2.example.com'), 'SomeVersionScheme', '%%s?version=%%s');
- $package = $container->getDefinition($packages['bar_version_strategy']);
+ $package = $container->getDefinition((string) $packages['bar_version_strategy']);
$this->assertEquals('assets.custom_version_strategy', (string) $package->getArgument(1));
}
@@ -323,7 +346,7 @@ public function testAssetsDefaultVersionStrategyAsService()
$packages = $container->getDefinition('assets.packages');
// default package
- $defaultPackage = $container->getDefinition($packages->getArgument(0));
+ $defaultPackage = $container->getDefinition((string) $packages->getArgument(0));
$this->assertEquals('assets.custom_version_strategy', (string) $defaultPackage->getArgument(1));
}
@@ -449,7 +472,8 @@ public function testValidationPaths()
require_once __DIR__.'/Fixtures/TestBundle/TestBundle.php';
$container = $this->createContainerFromFile('validation_annotations', array(
- 'kernel.bundles' => array('TestBundle' => 'Symfony\Bundle\FrameworkBundle\Tests\TestBundle'),
+ 'kernel.bundles' => array('TestBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\TestBundle'),
+ 'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'parent' => null, 'path' => __DIR__.'/Fixtures/TestBundle')),
));
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
@@ -479,6 +503,33 @@ public function testValidationPaths()
$this->assertStringEndsWith('TestBundle/Resources/config/validation.yml', $yamlMappings[0]);
}
+ public function testValidationPathsUsingCustomBundlePath()
+ {
+ require_once __DIR__.'/Fixtures/CustomPathBundle/src/CustomPathBundle.php';
+
+ $container = $this->createContainerFromFile('validation_annotations', array(
+ 'kernel.bundles' => array('CustomPathBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\CustomPathBundle'),
+ 'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'parent' => null, 'path' => __DIR__.'/Fixtures/CustomPathBundle')),
+ ));
+
+ $calls = $container->getDefinition('validator.builder')->getMethodCalls();
+ $xmlMappings = $calls[3][1][0];
+ $this->assertCount(2, $xmlMappings);
+
+ try {
+ // Testing symfony/symfony
+ $this->assertStringEndsWith('Component'.DIRECTORY_SEPARATOR.'Form/Resources/config/validation.xml', $xmlMappings[0]);
+ } catch (\Exception $e) {
+ // Testing symfony/framework-bundle with deps=high
+ $this->assertStringEndsWith('symfony'.DIRECTORY_SEPARATOR.'form/Resources/config/validation.xml', $xmlMappings[0]);
+ }
+ $this->assertStringEndsWith('CustomPathBundle/Resources/config/validation.xml', $xmlMappings[1]);
+
+ $yamlMappings = $calls[4][1][0];
+ $this->assertCount(1, $yamlMappings);
+ $this->assertStringEndsWith('CustomPathBundle/Resources/config/validation.yml', $yamlMappings[0]);
+ }
+
public function testValidationNoStaticMethod()
{
$container = $this->createContainerFromFile('validation_no_static_method');
@@ -740,6 +791,7 @@ protected function createContainer(array $data = array())
{
return new ContainerBuilder(new ParameterBag(array_merge(array(
'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'),
+ 'kernel.bundles_metadata' => array('FrameworkBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..', 'parent' => null)),
'kernel.cache_dir' => __DIR__,
'kernel.debug' => false,
'kernel.environment' => 'test',
@@ -798,7 +850,7 @@ private function assertUrlPackage(ContainerBuilder $container, DefinitionDecorat
private function assertVersionStrategy(ContainerBuilder $container, Reference $reference, $version, $format)
{
- $versionStrategy = $container->getDefinition($reference);
+ $versionStrategy = $container->getDefinition((string) $reference);
if (null === $version) {
$this->assertEquals('assets.empty_version_strategy', (string) $reference);
} else {
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Category.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Category.php
new file mode 100644
index 0000000000000..115320f6670d0
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Category.php
@@ -0,0 +1,17 @@
+ __DIR__.'/../Fixtures/Resources/views/this.is.a.template.format.engine',
+);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php
index 0305d65f6f3c5..5b40325e08eb9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php
@@ -48,6 +48,16 @@ public function testDumpBundleOption()
$this->assertContains('foo', $tester->getDisplay());
}
+ public function testParametersValuesAreResolved()
+ {
+ $tester = $this->createCommandTester();
+ $ret = $tester->execute(array('name' => 'framework'));
+
+ $this->assertSame(0, $ret, 'Returns 0 in case of success');
+ $this->assertContains("locale: '%env(LOCALE)%'", $tester->getDisplay());
+ $this->assertContains('secret: test', $tester->getDisplay());
+ }
+
public function testDumpUndefinedBundleOption()
{
$tester = $this->createCommandTester();
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml
index 377d3e7852064..c1d1288046050 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/config.yml
@@ -1,2 +1,10 @@
imports:
- { resource: ../config/default.yml }
+
+framework:
+ secret: '%secret%'
+ default_locale: '%env(LOCALE)%'
+
+parameters:
+ env(LOCALE): en
+ secret: test
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
index 4727fc4b82f53..9ac000d57a083 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
@@ -228,7 +228,7 @@ public function getNonStringValues()
*/
private function getServiceContainer(RouteCollection $routes)
{
- $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader
->expects($this->any())
@@ -236,7 +236,7 @@ private function getServiceContainer(RouteCollection $routes)
->will($this->returnValue($routes))
;
- $sc = $this->getMock('Symfony\\Component\\DependencyInjection\\Container', array('get'));
+ $sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(array('get'))->getMock();
$sc
->expects($this->once())
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php
index 4eaafddfa4c68..d18427dc4e802 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php
@@ -85,7 +85,7 @@ public function testRenderResponseWithTemplatingEngine()
private function getEngineMock($template, $supports)
{
- $engine = $this->getMock('Symfony\Component\Templating\EngineInterface');
+ $engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock();
$engine->expects($this->once())
->method('supports')
@@ -97,7 +97,7 @@ private function getEngineMock($template, $supports)
private function getFrameworkEngineMock($template, $supports)
{
- $engine = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
+ $engine = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
$engine->expects($this->once())
->method('supports')
@@ -109,7 +109,7 @@ private function getFrameworkEngineMock($template, $supports)
private function getContainerMock($services)
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$i = 0;
foreach ($services as $id => $service) {
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
index 5c00c62e7ff9d..99fd38317efe8 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
@@ -33,7 +33,7 @@ public function testGetUserNoTokenStorage()
public function testGetUserNoToken()
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->container->set('security.token_storage', $tokenStorage);
$this->assertNull($this->globals->getUser());
}
@@ -43,8 +43,8 @@ public function testGetUserNoToken()
*/
public function testGetUser($user, $expectedUser)
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->container->set('security.token_storage', $tokenStorage);
@@ -63,9 +63,9 @@ public function testGetUser($user, $expectedUser)
public function getUserProvider()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$std = new \stdClass();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
return array(
array($user, $user),
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php
index 1a0ff5f548cee..3518267d81b67 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php
@@ -17,7 +17,7 @@ class StopwatchHelperTest extends \PHPUnit_Framework_TestCase
{
public function testDevEnvironment()
{
- $stopwatch = $this->getMock('Symfony\Component\Stopwatch\Stopwatch');
+ $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
$stopwatch->expects($this->once())
->method('start')
->with('foo');
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php
index f680db942b2bd..96d75e3c3e0c0 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php
@@ -38,6 +38,17 @@ public function testLocateATemplate()
$this->assertEquals('/path/to/template', $locator->locate($template));
}
+ public function testLocateATemplateFromCacheDir()
+ {
+ $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine');
+
+ $fileLocator = $this->getFileLocator();
+
+ $locator = new TemplateLocator($fileLocator, __DIR__.'/../../Fixtures');
+
+ $this->assertEquals(realpath(__DIR__.'/../../Fixtures/Resources/views/this.is.a.template.format.engine'), $locator->locate($template));
+ }
+
public function testThrowsExceptionWhenTemplateNotFound()
{
$template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine');
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
index 9c19087264425..3e162d167d23e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
@@ -22,7 +22,7 @@ class TemplateNameParserTest extends TestCase
protected function setUp()
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundle')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
index 9411c1cb4718d..ef01f0e3b815f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
@@ -44,7 +44,7 @@ public function testThatRenderLogsTime()
*/
private function getContainer()
{
- return $this->getMock('Symfony\Component\DependencyInjection\Container');
+ return $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')->getMock();
}
/**
@@ -52,8 +52,8 @@ private function getContainer()
*/
private function getTemplateNameParser()
{
- $templateReference = $this->getMock('Symfony\Component\Templating\TemplateReferenceInterface');
- $templateNameParser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
+ $templateReference = $this->getMockBuilder('Symfony\Component\Templating\TemplateReferenceInterface')->getMock();
+ $templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$templateNameParser->expects($this->any())
->method('parse')
->will($this->returnValue($templateReference));
@@ -111,6 +111,6 @@ private function getStopwatchEvent()
*/
private function getStopwatch()
{
- return $this->getMock('Symfony\Component\Stopwatch\Stopwatch');
+ return $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
}
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
index a2bcbcb9def38..1a215c388c9d7 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
@@ -76,7 +76,7 @@ public function testTransWithCaching()
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
// do it another time as the cache is primed now
- $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$loader->expects($this->never())->method('load');
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir));
@@ -99,7 +99,7 @@ public function testTransWithCaching()
*/
public function testTransWithCachingWithInvalidLocale()
{
- $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
$translator->trans('foo');
@@ -122,7 +122,7 @@ public function testLoadResourcesWithoutCaching()
public function testGetDefaultLocale()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
->method('getParameter')
@@ -150,7 +150,7 @@ protected function getCatalogue($locale, $messages, $resources = array())
protected function getLoader()
{
- $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$loader
->expects($this->at(0))
->method('load')
@@ -208,7 +208,7 @@ protected function getLoader()
protected function getContainer($loader)
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->any())
->method('get')
@@ -249,7 +249,7 @@ public function testWarmup()
$translator->setFallbackLocales(array('fr'));
$translator->warmup($this->tmpDir);
- $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$loader
->expects($this->never())
->method('load');
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php
index b61851bb0c86a..12ee6ac673d97 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php
@@ -21,7 +21,7 @@ public function testGetInstanceCreatesValidator()
{
$class = get_class($this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintValidator'));
- $constraint = $this->getMock('Symfony\\Component\\Validator\\Constraint');
+ $constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
$constraint
->expects($this->once())
->method('validatedBy')
@@ -46,14 +46,14 @@ public function testGetInstanceReturnsService()
$validator = $this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintValidator');
// mock ContainerBuilder b/c it implements TaggedContainerInterface
- $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerBuilder', array('get'));
+ $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')->setMethods(array('get'))->getMock();
$container
->expects($this->once())
->method('get')
->with($service)
->will($this->returnValue($validator));
- $constraint = $this->getMock('Symfony\\Component\\Validator\\Constraint');
+ $constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
$constraint
->expects($this->once())
->method('validatedBy')
@@ -68,7 +68,7 @@ public function testGetInstanceReturnsService()
*/
public function testGetInstanceInvalidValidatorClass()
{
- $constraint = $this->getMock('Symfony\\Component\\Validator\\Constraint');
+ $constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
$constraint
->expects($this->once())
->method('validatedBy')
diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json
index 278fadaf98d10..34c0b2fe691d9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/composer.json
+++ b/src/Symfony/Bundle/FrameworkBundle/composer.json
@@ -17,13 +17,13 @@
],
"require": {
"php": ">=5.5.9",
- "symfony/cache": "~3.2",
+ "symfony/cache": "~3.2.2|~3.3",
"symfony/class-loader": "~3.2",
- "symfony/dependency-injection": "~3.2",
+ "symfony/dependency-injection": "~3.2.1|~3.3",
"symfony/config": "~2.8|~3.0",
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/http-foundation": "~3.1",
- "symfony/http-kernel": "~3.2",
+ "symfony/http-kernel": "~3.2.2|~3.3",
"symfony/polyfill-mbstring": "~1.0",
"symfony/filesystem": "~2.8|~3.0",
"symfony/finder": "~2.8|~3.0",
@@ -39,7 +39,7 @@
"symfony/dom-crawler": "~2.8|~3.0",
"symfony/polyfill-intl-icu": "~1.0",
"symfony/security": "~2.8|~3.0",
- "symfony/form": "~2.8|~3.0",
+ "symfony/form": "~2.8.16|~3.1.9|^3.2.2",
"symfony/expression-language": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0",
"symfony/security-core": "~3.2",
diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php
index fc008a9fbd82c..f20f8c2e70a0d 100644
--- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php
+++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php
@@ -97,7 +97,8 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
if (count($userProviders) === 0) {
throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login) for each firewall that has remember-me enabled.');
}
- $rememberMeServices->replaceArgument(0, $userProviders);
+
+ $rememberMeServices->replaceArgument(0, array_unique($userProviders));
// remember-me listener
$listenerId = 'security.authentication.listener.rememberme.'.$id;
diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
index faa28fc1757aa..7b5774361cbec 100644
--- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
@@ -403,7 +403,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
$config->replaceArgument(8, isset($firewall['access_denied_handler']) ? $firewall['access_denied_handler'] : null);
$config->replaceArgument(9, isset($firewall['access_denied_url']) ? $firewall['access_denied_url'] : null);
- $container->setAlias(new Alias('security.user_checker.'.$id, false), $firewall['user_checker']);
+ $container->setAlias('security.user_checker.'.$id, new Alias($firewall['user_checker'], false));
foreach ($this->factories as $position) {
foreach ($position as $factory) {
diff --git a/src/Symfony/Bundle/SecurityBundle/LICENSE b/src/Symfony/Bundle/SecurityBundle/LICENSE
index 12a74531e40a4..17d16a13367dd 100644
--- a/src/Symfony/Bundle/SecurityBundle/LICENSE
+++ b/src/Symfony/Bundle/SecurityBundle/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2016 Fabien Potencier
+Copyright (c) 2004-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
index bbce61a75813b..cbdb6e8f0f98a 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
@@ -73,7 +73,7 @@ public function testFirewalls()
$arguments = $contextDef->getArguments();
$listeners[] = array_map(function ($ref) { return (string) $ref; }, $arguments['index_0']);
- $configDef = $container->getDefinition($arguments['index_2']);
+ $configDef = $container->getDefinition((string) $arguments['index_2']);
$configs[] = array_values($configDef->getArguments());
}
@@ -234,7 +234,7 @@ public function testAccess()
);
} elseif (3 === $i) {
$this->assertEquals('IS_AUTHENTICATED_ANONYMOUSLY', $attributes[0]);
- $expression = $container->getDefinition($attributes[1])->getArgument(0);
+ $expression = $container->getDefinition((string) $attributes[1])->getArgument(0);
$this->assertEquals("token.getUsername() matches '/^admin/'", $expression);
}
}
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php
index e0d626a8cee40..430390bfc3ff7 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php
@@ -33,8 +33,8 @@ public function testResolveNoToken()
public function testResolveNoUser()
{
- $mock = $this->getMock(UserInterface::class);
- $token = $this->getMock(TokenInterface::class);
+ $mock = $this->getMockBuilder(UserInterface::class)->getMock();
+ $token = $this->getMockBuilder(TokenInterface::class)->getMock();
$tokenStorage = new TokenStorage();
$tokenStorage->setToken($token);
@@ -55,8 +55,8 @@ public function testResolveWrongType()
public function testResolve()
{
- $user = $this->getMock(UserInterface::class);
- $token = $this->getMock(TokenInterface::class);
+ $user = $this->getMockBuilder(UserInterface::class)->getMock();
+ $token = $this->getMockBuilder(TokenInterface::class)->getMock();
$token->expects($this->any())->method('getUser')->willReturn($user);
$tokenStorage = new TokenStorage();
$tokenStorage->setToken($token);
@@ -70,8 +70,8 @@ public function testResolve()
public function testIntegration()
{
- $user = $this->getMock(UserInterface::class);
- $token = $this->getMock(TokenInterface::class);
+ $user = $this->getMockBuilder(UserInterface::class)->getMock();
+ $token = $this->getMockBuilder(TokenInterface::class)->getMock();
$token->expects($this->any())->method('getUser')->willReturn($user);
$tokenStorage = new TokenStorage();
$tokenStorage->setToken($token);
@@ -82,7 +82,7 @@ public function testIntegration()
public function testIntegrationNoUser()
{
- $token = $this->getMock(TokenInterface::class);
+ $token = $this->getMockBuilder(TokenInterface::class)->getMock();
$tokenStorage = new TokenStorage();
$tokenStorage->setToken($token);
diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php
index 9fbfd65950a53..b7ebb2a406512 100644
--- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php
+++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php
@@ -27,8 +27,10 @@ public function process(ContainerBuilder $container)
return;
}
- // register the exception controller only if Twig is enabled
- if ($container->hasParameter('templating.engines')) {
+ // register the exception controller only if Twig is enabled and required dependencies do exist
+ if (!class_exists('Symfony\Component\Debug\Exception\FlattenException') || !interface_exists('Symfony\Component\EventDispatcher\EventSubscriberInterface')) {
+ $container->removeDefinition('twig.exception_listener');
+ } elseif ($container->hasParameter('templating.engines')) {
$engines = $container->getParameter('templating.engines');
if (!in_array('twig', $engines)) {
$container->removeDefinition('twig.exception_listener');
diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php
index 184acc72e0106..abb2fed46d839 100644
--- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php
+++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php
@@ -27,10 +27,29 @@ class ExtensionPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
+ if (!class_exists('Symfony\Component\Asset\Packages')) {
+ $container->removeDefinition('twig.extension.assets');
+ }
+
+ if (!class_exists('Symfony\Component\ExpressionLanguage\Expression')) {
+ $container->removeDefinition('twig.extension.expression');
+ }
+
+ if (!interface_exists('Symfony\Component\Routing\Generator\UrlGeneratorInterface')) {
+ $container->removeDefinition('twig.extension.routing');
+ }
+ if (!interface_exists('Symfony\Component\Translation\TranslatorInterface')) {
+ $container->removeDefinition('twig.extension.trans');
+ }
+
+ if (!class_exists('Symfony\Component\Yaml\Yaml')) {
+ $container->removeDefinition('twig.extension.yaml');
+ }
+
if ($container->has('form.extension')) {
$container->getDefinition('twig.extension.form')->addTag('twig.extension');
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
- $container->getDefinition('twig.loader.filesystem')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
+ $container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
}
if ($container->has('translator')) {
@@ -66,15 +85,15 @@ public function process(ContainerBuilder $container)
}
$composerRootDir = $this->getComposerRootDir($container->getParameter('kernel.root_dir'));
- $loader = $container->getDefinition('twig.loader.filesystem');
- $loader->replaceArgument(2, $composerRootDir);
-
- if (!$container->has('templating')) {
- $loader = $container->getDefinition('twig.loader.native_filesystem');
- $loader->replaceArgument(1, $composerRootDir);
- $loader->addTag('twig.loader');
- $loader->setMethodCalls($container->getDefinition('twig.loader.filesystem')->getMethodCalls());
-
+ $twigLoader = $container->getDefinition('twig.loader.native_filesystem');
+ if ($container->has('templating')) {
+ $loader = $container->getDefinition('twig.loader.filesystem');
+ $loader->setMethodCalls($twigLoader->getMethodCalls());
+ $loader->replaceArgument(2, $composerRootDir);
+
+ $twigLoader->clearTag('twig.loader');
+ } else {
+ $twigLoader->replaceArgument(1, $composerRootDir);
$container->setAlias('twig.loader.filesystem', new Alias('twig.loader.native_filesystem', false));
}
diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php
index 6a4c1f269053c..7d0be74fadb78 100644
--- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php
+++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php
@@ -13,6 +13,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
/**
* Registers Twig runtime services.
diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
index 5296ac542ca87..77d10e84c1464 100644
--- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
+++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
@@ -37,6 +37,18 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('twig.xml');
+ if (class_exists('Symfony\Component\Form\Form')) {
+ $loader->load('form.xml');
+ }
+
+ if (interface_exists('Symfony\Component\Templating\EngineInterface')) {
+ $loader->load('templating.xml');
+ }
+
+ if (!interface_exists('Symfony\Component\Translation\TranslatorInterface')) {
+ $container->removeDefinition('twig.translation.extractor');
+ }
+
foreach ($configs as $key => $config) {
if (isset($config['globals'])) {
foreach ($config['globals'] as $name => $value) {
@@ -66,7 +78,7 @@ public function load(array $configs, ContainerBuilder $container)
$envConfiguratorDefinition->replaceArgument(4, $config['number_format']['decimal_point']);
$envConfiguratorDefinition->replaceArgument(5, $config['number_format']['thousands_separator']);
- $twigFilesystemLoaderDefinition = $container->getDefinition('twig.loader.filesystem');
+ $twigFilesystemLoaderDefinition = $container->getDefinition('twig.loader.native_filesystem');
// register user-configured paths
foreach ($config['paths'] as $path => $namespace) {
@@ -80,24 +92,23 @@ public function load(array $configs, ContainerBuilder $container)
$container->getDefinition('twig.cache_warmer')->replaceArgument(2, $config['paths']);
$container->getDefinition('twig.template_iterator')->replaceArgument(2, $config['paths']);
- // register bundles as Twig namespaces
- foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
- $dir = $container->getParameter('kernel.root_dir').'/Resources/'.$bundle.'/views';
- if (is_dir($dir)) {
- $this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
+ $bundleHierarchy = $this->getBundleHierarchy($container);
+
+ foreach ($bundleHierarchy as $name => $bundle) {
+ $namespace = $this->normalizeBundleName($name);
+
+ foreach ($bundle['children'] as $child) {
+ foreach ($bundleHierarchy[$child]['paths'] as $path) {
+ $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
+ }
}
- $container->addResource(new FileExistenceResource($dir));
- $reflection = new \ReflectionClass($class);
- $dir = dirname($reflection->getFileName()).'/Resources/views';
- if (is_dir($dir)) {
- $this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
+ foreach ($bundle['paths'] as $path) {
+ $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
}
- $container->addResource(new FileExistenceResource($dir));
}
- $dir = $container->getParameter('kernel.root_dir').'/Resources/views';
- if (is_dir($dir)) {
+ if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) {
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir));
}
$container->addResource(new FileExistenceResource($dir));
@@ -138,13 +149,65 @@ public function load(array $configs, ContainerBuilder $container)
));
}
- private function addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle)
+ private function getBundleHierarchy(ContainerBuilder $container)
+ {
+ $bundleHierarchy = array();
+
+ foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
+ if (!array_key_exists($name, $bundleHierarchy)) {
+ $bundleHierarchy[$name] = array(
+ 'paths' => array(),
+ 'parents' => array(),
+ 'children' => array(),
+ );
+ }
+
+ if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$name.'/views')) {
+ $bundleHierarchy[$name]['paths'][] = $dir;
+ }
+ $container->addResource(new FileExistenceResource($dir));
+
+ if (is_dir($dir = $bundle['path'].'/Resources/views')) {
+ $bundleHierarchy[$name]['paths'][] = $dir;
+ }
+ $container->addResource(new FileExistenceResource($dir));
+
+ if (null === $bundle['parent']) {
+ continue;
+ }
+
+ $bundleHierarchy[$name]['parents'][] = $bundle['parent'];
+
+ if (!array_key_exists($bundle['parent'], $bundleHierarchy)) {
+ $bundleHierarchy[$bundle['parent']] = array(
+ 'paths' => array(),
+ 'parents' => array(),
+ 'children' => array(),
+ );
+ }
+
+ $bundleHierarchy[$bundle['parent']]['children'] = array_merge($bundleHierarchy[$name]['children'], array($name), $bundleHierarchy[$bundle['parent']]['children']);
+
+ foreach ($bundleHierarchy[$bundle['parent']]['parents'] as $parent) {
+ $bundleHierarchy[$name]['parents'][] = $parent;
+ $bundleHierarchy[$parent]['children'] = array_merge($bundleHierarchy[$name]['children'], array($name), $bundleHierarchy[$parent]['children']);
+ }
+
+ foreach ($bundleHierarchy[$name]['children'] as $child) {
+ $bundleHierarchy[$child]['parents'] = array_merge($bundleHierarchy[$child]['parents'], $bundleHierarchy[$name]['parents']);
+ }
+ }
+
+ return $bundleHierarchy;
+ }
+
+ private function normalizeBundleName($name)
{
- $name = $bundle;
if ('Bundle' === substr($name, -6)) {
$name = substr($name, 0, -6);
}
- $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir, $name));
+
+ return $name;
}
/**
diff --git a/src/Symfony/Bundle/TwigBundle/LICENSE b/src/Symfony/Bundle/TwigBundle/LICENSE
index 12a74531e40a4..17d16a13367dd 100644
--- a/src/Symfony/Bundle/TwigBundle/LICENSE
+++ b/src/Symfony/Bundle/TwigBundle/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2016 Fabien Potencier
+Copyright (c) 2004-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml
new file mode 100644
index 0000000000000..f1603c15461bd
--- /dev/null
+++ b/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+ twig.form.renderer
+
+
+
+
+ %twig.form.resources%
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml
new file mode 100644
index 0000000000000..fae523eb6fd06
--- /dev/null
+++ b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
index 29d2c4390a13b..800fc08367fd8 100644
--- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
+++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
@@ -47,25 +47,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -118,26 +104,8 @@
-
-
-
- twig.form.renderer
-
-
-
-
- %twig.form.resources%
-
-
-
-
-
-
-
-
-