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 e61f0a59c4ff9..3490782e94969 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 @@ -85,16 +85,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 fc198328e6002..36efff588f4d8 100644 --- a/CHANGELOG-3.1.md +++ b/CHANGELOG-3.1.md @@ -7,6 +7,52 @@ 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.9 (2017-01-12) + + * 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 #21165 [Serializer] int is valid when float is expected when deserializing JSON (dunglas) + * 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 #21084 [Yaml] handle empty lines inside unindented collection (xabbuh) + * bug #20925 [HttpFoundation] Validate/cast cookie expire time (ro0NL) + * 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 #21010 [Debug] UndefinedMethodFatalErrorHandler - Handle anonymous classes (SpacePossum) + * bug #20991 [cache] Bump RedisAdapter default timeout to 5s (Nicofuma) + * 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 #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 #20847 [Console] fixed BC issue with static closures (araines) + * 3.1.8 (2016-12-13) * bug #20714 [FrameworkBundle] Fix unresolved parameters from default configs in debug:config (chalasr) 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/appveyor.yml b/appveyor.yml index 302f898e72ad4..98f39a5ccc648 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: @@ -44,13 +44,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 a473b3ace2fe5..e3d48a703062c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php @@ -17,7 +17,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()) @@ -31,7 +31,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 @@ -44,7 +44,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 2e2f2952e004e..f141410af83c6 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -67,7 +67,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)) @@ -96,7 +96,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 6cb315967e4fc..b8efa6fcf9591 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') @@ -80,7 +80,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') @@ -110,7 +110,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') @@ -165,12 +165,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/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/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 51a95bc4b57e0..92ed4600bae1a 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,7 +69,7 @@ public function testGetRequest() 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()); } @@ -83,7 +83,7 @@ public function testGetUserWithUsernameAsTokenUser() 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()); @@ -131,7 +131,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); @@ -139,10 +139,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 af93114e5ae57..0800ba8ea2608 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -63,7 +63,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, diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index 833829fd97178..77e78933b99b6 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -39,7 +39,7 @@ protected function setUp() 'bootstrap_3_horizontal_layout.html.twig', 'custom_widgets.html.twig', )); - $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')); + $renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->extension = new FormExtension($renderer); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index 45cddd4050389..b6959542ed73f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -35,7 +35,7 @@ protected function setUp() 'bootstrap_3_layout.html.twig', 'custom_widgets.html.twig', )); - $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')); + $renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->extension = new FormExtension($renderer); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index 1f5161897af81..a00e25fabf0e2 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -36,7 +36,7 @@ protected function setUp() 'form_div_layout.html.twig', 'custom_widgets.html.twig', )); - $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')); + $renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->extension = new FormExtension($renderer); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index 38a3ba3436aa1..41a05e6261cf3 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -35,7 +35,7 @@ protected function setUp() 'form_table_layout.html.twig', 'custom_widgets.html.twig', )); - $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')); + $renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->extension = new FormExtension($renderer); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php index 403ed32fd8015..abbd6c05d9156 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php @@ -51,7 +51,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); 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/StopwatchExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php index 8c0cdfe69b620..2ea111b0baacd 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 ce0eade671c25..b264a6f55b46a 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 3cf2ceb5a2fe5..60d9617ccfa1a 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 c38a72d3787c8..c048756efa3ca 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": "~2.8|~3.0", "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/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/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 9763442977ee1..c34632b5cae63 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -690,12 +690,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; } } @@ -758,6 +757,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'); @@ -806,11 +809,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)); @@ -943,10 +943,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 286b7c62e4d2a..369e95a1f08aa 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/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 536c59fae4709..12936829694f3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -85,7 +85,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') @@ -95,7 +95,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') @@ -105,7 +105,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') @@ -114,7 +114,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') @@ -129,7 +129,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') @@ -146,7 +146,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 4063a00ab7fec..f74117951b024 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php @@ -37,12 +37,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)); @@ -88,7 +88,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') @@ -108,13 +108,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') @@ -132,7 +132,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') @@ -149,14 +149,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') @@ -179,14 +179,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') @@ -211,10 +211,10 @@ public function testJsonWithSerializerContextOverride() 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)); @@ -229,10 +229,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)); @@ -247,7 +247,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)); @@ -263,7 +263,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)); @@ -278,7 +278,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)); @@ -291,10 +291,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(); @@ -309,10 +309,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)); @@ -332,10 +332,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)); @@ -347,10 +347,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(); @@ -371,10 +371,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)); @@ -386,10 +386,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)); @@ -401,9 +401,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)); @@ -422,12 +422,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(); @@ -438,12 +438,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(); @@ -454,9 +454,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 61d31cb86b7b6..7ee9aa558e5f6 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(), ); - $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 c0eef3d627ce7..7f465b253401a 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(), ); - $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,11 +49,8 @@ public function testThatCheckersAreProcessedInPriorityOrder() public function testThatCheckersCanBeMissing() { - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); - $container = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('findTaggedServiceIds') - ); + $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); + $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/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 4e93a0e4f424c..f0f1508d0b9a3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -375,7 +375,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(); @@ -405,6 +406,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'); @@ -630,6 +658,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', @@ -688,7 +717,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/templates.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/templates.php new file mode 100644 index 0000000000000..b97a6ba6a7c57 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/templates.php @@ -0,0 +1,5 @@ + __DIR__.'/../Fixtures/Resources/views/this.is.a.template.format.engine', +); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index 330e0659ca144..d90f5d8358f93 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -214,7 +214,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()) @@ -222,7 +222,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 1b28ec4f78deb..b00a14a06f004 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php @@ -35,6 +35,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 80327f96ecde3..788e014769869 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -24,7 +24,7 @@ "symfony/config": "~2.8|~3.0", "symfony/event-dispatcher": "~2.8|~3.0", "symfony/http-foundation": "~3.1", - "symfony/http-kernel": "~3.1.2|~3.2", + "symfony/http-kernel": "~3.1.9|^3.2.2", "symfony/polyfill-mbstring": "~1.0", "symfony/filesystem": "~2.8|~3.0", "symfony/finder": "~2.8|~3.0", @@ -44,7 +44,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/serializer": "~2.8|^3.0", 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/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 900ade2328688..977f36900ce52 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -167,7 +167,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/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 29274fb144394..6891d33706da2 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -23,10 +23,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')) { @@ -65,11 +84,13 @@ public function process(ContainerBuilder $container) $container->getDefinition('twig.extension.debug')->addTag('twig.extension'); } - if (!$container->has('templating')) { - $loader = $container->getDefinition('twig.loader.native_filesystem'); - $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()); + $twigLoader->clearTag('twig.loader'); + } else { $container->setAlias('twig.loader.filesystem', new Alias('twig.loader.native_filesystem', false)); } 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..864e6b8b5810f --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml @@ -0,0 +1,20 @@ + + + + + + + + + + %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..b4e9dcc5e8671 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index 55182c083abd5..65af011391ea4 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -43,24 +43,11 @@ - - - - - - - - - - - - - @@ -115,21 +102,8 @@ - - - - - - %twig.form.resources% - - - - - - - diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php index c8cdc305c30af..417c83cdecc49 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php @@ -27,7 +27,7 @@ public function testForwardRequestToConfiguredController() $code = 123; $logicalControllerName = 'foo:bar:baz'; - $kernel = $this->getMock('\Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('\Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel ->expects($this->once()) ->method('handle') diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php index 08e9d4602d8c4..e8d9476d8dc2b 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php @@ -31,10 +31,7 @@ class TwigLoaderPassTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'setAlias', 'getDefinition') - ); + $this->builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'setAlias', 'getDefinition'))->getMock(); $this->chainLoader = new Definition('loader'); $this->pass = new TwigLoaderPass(); } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig new file mode 100644 index 0000000000000..bb07ecfe55a36 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig new file mode 100644 index 0000000000000..bb07ecfe55a36 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig new file mode 100644 index 0000000000000..bb07ecfe55a36 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig new file mode 100644 index 0000000000000..bb07ecfe55a36 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 5abe06d9bb29d..c09978f07dfe9 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -151,7 +151,7 @@ public function testTwigLoaderPaths($format) $this->loadFromFile($container, 'extra', $format); $this->compileContainer($container); - $def = $container->getDefinition('twig.loader.filesystem'); + $def = $container->getDefinition('twig.loader.native_filesystem'); $paths = array(); foreach ($def->getMethodCalls() as $call) { if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) { @@ -165,8 +165,22 @@ public function testTwigLoaderPaths($format) array('namespaced_path1', 'namespace1'), array('namespaced_path2', 'namespace2'), array('namespaced_path3', 'namespace3'), + array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildChildChildTwig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildChildTwig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildChildChildTwig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'Twig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'Twig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'Twig'), + array(__DIR__.'/Fixtures/Bundle/ChildTwigBundle/Resources/views', 'Twig'), array(__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'), array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildTwig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildTwig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildTwig'), + array(__DIR__.'/Fixtures/Bundle/ChildTwigBundle/Resources/views', 'ChildTwig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildTwig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildChildTwig'), + array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildChildTwig'), array(__DIR__.'/Fixtures/Resources/views'), ), $paths); } @@ -218,7 +232,40 @@ private function createContainer() 'kernel.root_dir' => __DIR__.'/Fixtures', 'kernel.charset' => 'UTF-8', 'kernel.debug' => false, - 'kernel.bundles' => array('TwigBundle' => 'Symfony\\Bundle\\TwigBundle\\TwigBundle'), + 'kernel.bundles' => array( + 'TwigBundle' => 'Symfony\\Bundle\\TwigBundle\\TwigBundle', + 'ChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildTwigBundle\\ChildTwigBundle', + 'ChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildTwigBundle\\ChildChildTwigBundle', + 'ChildChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildTwigBundle\\ChildChildChildTwigBundle', + 'ChildChildChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildChildTwigBundle\\ChildChildChildChildTwigBundle', + ), + 'kernel.bundles_metadata' => array( + 'ChildChildChildChildTwigBundle' => array( + 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildChildTwigBundle\\ChildChildChildChildTwigBundle', + 'parent' => 'ChildChildChildTwigBundle', + 'path' => __DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle', + ), + 'TwigBundle' => array( + 'namespace' => 'Symfony\\Bundle\\TwigBundle', + 'parent' => null, + 'path' => realpath(__DIR__.'/../..'), + ), + 'ChildTwigBundle' => array( + 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildTwigBundle\\ChildTwigBundle', + 'parent' => 'TwigBundle', + 'path' => __DIR__.'/Fixtures/Bundle/ChildTwigBundle', + ), + 'ChildChildChildTwigBundle' => array( + 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildTwigBundle\\ChildChildChildTwigBundle', + 'parent' => 'ChildChildTwigBundle', + 'path' => __DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle', + ), + 'ChildChildTwigBundle' => array( + 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildTwigBundle\\ChildChildTwigBundle', + 'parent' => 'ChildTwigBundle', + 'path' => __DIR__.'/Fixtures/Bundle/ChildChildTwigBundle', + ), + ), ))); return $container; diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php index 64ba490388f9f..a7abdecb87896 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php @@ -19,8 +19,8 @@ class FilesystemLoaderTest extends TestCase { public function testGetSourceContext() { - $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); - $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator ->expects($this->once()) ->method('locate') @@ -39,8 +39,8 @@ public function testGetSourceContext() public function testExists() { // should return true for templates that Twig does not find, but Symfony does - $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); - $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator ->expects($this->once()) ->method('locate') @@ -56,7 +56,7 @@ public function testExists() */ public function testTwigErrorIfLocatorThrowsInvalid() { - $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $parser ->expects($this->once()) ->method('parse') @@ -64,7 +64,7 @@ public function testTwigErrorIfLocatorThrowsInvalid() ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) ; - $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator ->expects($this->once()) ->method('locate') @@ -80,7 +80,7 @@ public function testTwigErrorIfLocatorThrowsInvalid() */ public function testTwigErrorIfLocatorReturnsFalse() { - $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $parser ->expects($this->once()) ->method('parse') @@ -88,7 +88,7 @@ public function testTwigErrorIfLocatorReturnsFalse() ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) ; - $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator ->expects($this->once()) ->method('locate') @@ -105,8 +105,8 @@ public function testTwigErrorIfLocatorReturnsFalse() */ public function testTwigErrorIfTemplateDoesNotExist() { - $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); - $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); @@ -118,8 +118,8 @@ public function testTwigErrorIfTemplateDoesNotExist() public function testTwigSoftErrorIfTemplateDoesNotExist() { - $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); - $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php index 13bb9ef909180..636d5796f874f 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php @@ -17,7 +17,7 @@ class TemplateIteratorTest extends TestCase { public function testGetIterator() { - $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('BarBundle')); $bundle->expects($this->any())->method('getPath')->will($this->returnValue(__DIR__.'/Fixtures/templates/BarBundle')); diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php index 76daad58a3188..503c55f6af7cb 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php +++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php @@ -49,16 +49,12 @@ public function render($name, array $parameters = array()) try { return parent::render($name, $parameters); } catch (\Twig_Error $e) { - if ($name instanceof TemplateReference) { + if ($name instanceof TemplateReference && !method_exists($e, 'setSourceContext')) { try { // try to get the real name of the template where the error occurred $name = $e->getTemplateName(); $path = (string) $this->locator->locate($this->parser->parse($name)); - if (method_exists($e, 'setSourceContext')) { - $e->setSourceContext(new \Twig_Source('', $name, $path)); - } else { - $e->setTemplateName($path); - } + $e->setTemplateName($path); } catch (\Exception $e2) { } } diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 70649a3c64c03..7b58019f56f9b 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -20,7 +20,7 @@ "symfony/asset": "~2.8|~3.0", "symfony/twig-bridge": "~2.8|~3.0", "symfony/http-foundation": "~2.8|~3.0", - "symfony/http-kernel": "~2.8|~3.0", + "symfony/http-kernel": "~2.8.16|~3.1.9|^3.2.2", "twig/twig": "~1.28|~2.0" }, "require-dev": { diff --git a/src/Symfony/Bundle/WebProfilerBundle/LICENSE b/src/Symfony/Bundle/WebProfilerBundle/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/LICENSE +++ b/src/Symfony/Bundle/WebProfilerBundle/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/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig index 5b6f81edd38d9..63127fec46234 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -163,11 +163,10 @@ font-size: 11px; padding: 4px 8px 4px 0; } -.sf-toolbar-block .sf-toolbar-info-piece span { - +.sf-toolbar-block:not(.sf-toolbar-block-dump) .sf-toolbar-info-piece span { + color: #F5F5F5; } .sf-toolbar-block .sf-toolbar-info-piece span { - color: #F5F5F5; font-size: 12px; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index 19443ed0db467..d0fa268a56f0f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -22,7 +22,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase */ public function testEmptyToken($token) { - $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); + $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') @@ -46,7 +46,7 @@ public function getEmptyTokenCases() public function testReturns404onTokenNotFound() { - $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); + $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') @@ -74,7 +74,7 @@ public function testReturns404onTokenNotFound() public function testSearchResult() { - $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); + $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php index a3732fde425b1..e67958de732ea 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -45,7 +45,7 @@ protected function setUp() { parent::setUp(); - $this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface'); + $this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock(); $this->container = new ContainerBuilder(); $this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface')); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index f5aa3f4ab8531..3b27745ddc0f8 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -246,11 +246,7 @@ public function testThrowingUrlGenerator() protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true) { - $request = $this->getMock( - 'Symfony\Component\HttpFoundation\Request', - array('getSession', 'isXmlHttpRequest', 'getRequestFormat'), - array(), '', false - ); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(array('getSession', 'isXmlHttpRequest', 'getRequestFormat'))->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('isXmlHttpRequest') ->will($this->returnValue($isXmlHttpRequest)); @@ -259,7 +255,7 @@ protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'h ->will($this->returnValue($requestFormat)); if ($hasSession) { - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session', array(), array(), '', false); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('getSession') ->will($this->returnValue($session)); @@ -270,7 +266,7 @@ protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'h protected function getTwigMock($render = 'WDT') { - $templating = $this->getMock('Twig_Environment', array(), array(), '', false); + $templating = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $templating->expects($this->any()) ->method('render') ->will($this->returnValue($render)); @@ -280,11 +276,11 @@ protected function getTwigMock($render = 'WDT') protected function getUrlGeneratorMock() { - return $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); + return $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); } protected function getKernelMock() { - return $this->getMock('Symfony\Component\HttpKernel\Kernel', array(), array(), '', false); + return $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php index c9b199ea18b93..4ac2c7de5f0a2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -136,9 +136,9 @@ protected function mockTwigEnvironment() ->will($this->returnValue('loadedTemplate')); if (interface_exists('\Twig_SourceContextLoaderInterface')) { - $loader = $this->getMock('\Twig_SourceContextLoaderInterface'); + $loader = $this->getMockBuilder('\Twig_SourceContextLoaderInterface')->getMock(); } else { - $loader = $this->getMock('\Twig_LoaderInterface'); + $loader = $this->getMockBuilder('\Twig_LoaderInterface')->getMock(); } $this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader)); diff --git a/src/Symfony/Component/Asset/LICENSE b/src/Symfony/Component/Asset/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Asset/LICENSE +++ b/src/Symfony/Component/Asset/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/Component/Asset/Tests/Context/RequestStackContextTest.php b/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php index 07f75c9f5b734..dea77a587efaf 100644 --- a/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php +++ b/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php @@ -17,7 +17,7 @@ class RequestStackContextTest extends \PHPUnit_Framework_TestCase { public function testGetBasePathEmpty() { - $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStackContext = new RequestStackContext($requestStack); $this->assertEmpty($requestStackContext->getBasePath()); @@ -27,10 +27,10 @@ public function testGetBasePathSet() { $testBasePath = 'test-path'; - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->method('getBasePath') ->willReturn($testBasePath); - $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack->method('getMasterRequest') ->willReturn($request); @@ -41,7 +41,7 @@ public function testGetBasePathSet() public function testIsSecureFalse() { - $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStackContext = new RequestStackContext($requestStack); $this->assertFalse($requestStackContext->isSecure()); @@ -49,10 +49,10 @@ public function testIsSecureFalse() public function testIsSecureTrue() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->method('isSecure') ->willReturn(true); - $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack->method('getMasterRequest') ->willReturn($request); diff --git a/src/Symfony/Component/Asset/Tests/PackagesTest.php b/src/Symfony/Component/Asset/Tests/PackagesTest.php index 0a78a8b4fa6e4..bb515f20964f0 100644 --- a/src/Symfony/Component/Asset/Tests/PackagesTest.php +++ b/src/Symfony/Component/Asset/Tests/PackagesTest.php @@ -20,8 +20,8 @@ class PackagesTest extends \PHPUnit_Framework_TestCase public function testGetterSetters() { $packages = new Packages(); - $packages->setDefaultPackage($default = $this->getMock('Symfony\Component\Asset\PackageInterface')); - $packages->addPackage('a', $a = $this->getMock('Symfony\Component\Asset\PackageInterface')); + $packages->setDefaultPackage($default = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock()); + $packages->addPackage('a', $a = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock()); $this->assertEquals($default, $packages->getPackage()); $this->assertEquals($a, $packages->getPackage('a')); diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php index ff5b0a052f14a..1f0883abad824 100644 --- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php @@ -76,7 +76,7 @@ public function getContextConfigs() private function getContext($basePath) { - $context = $this->getMock('Symfony\Component\Asset\Context\ContextInterface'); + $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock(); $context->expects($this->any())->method('getBasePath')->will($this->returnValue($basePath)); return $context; diff --git a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php index 327876aeaf1b5..588e9985741d3 100644 --- a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php @@ -94,7 +94,7 @@ public function testWrongBaseUrl() private function getContext($secure) { - $context = $this->getMock('Symfony\Component\Asset\Context\ContextInterface'); + $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock(); $context->expects($this->any())->method('isSecure')->will($this->returnValue($secure)); return $context; diff --git a/src/Symfony/Component/BrowserKit/Cookie.php b/src/Symfony/Component/BrowserKit/Cookie.php index eeef805d72099..7e855bf351dad 100644 --- a/src/Symfony/Component/BrowserKit/Cookie.php +++ b/src/Symfony/Component/BrowserKit/Cookie.php @@ -121,7 +121,7 @@ public function __toString() * @param string $cookie A Set-Cookie header value * @param string $url The base URL * - * @return Cookie A Cookie instance + * @return static * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/BrowserKit/LICENSE b/src/Symfony/Component/BrowserKit/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/BrowserKit/LICENSE +++ b/src/Symfony/Component/BrowserKit/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/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index c731e47ddd808..7512472150631 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -27,6 +27,7 @@ class ChainAdapter implements AdapterInterface { private $adapters = array(); + private $adapterCount; private $saveUp; /** @@ -50,6 +51,7 @@ public function __construct(array $adapters, $maxLifetime = 0) $this->adapters[] = new ProxyAdapter($adapter); } } + $this->adapterCount = count($this->adapters); $this->saveUp = \Closure::bind( function ($adapter, $item) use ($maxLifetime) { @@ -146,9 +148,10 @@ public function hasItem($key) public function clear() { $cleared = true; + $i = $this->adapterCount; - foreach ($this->adapters as $adapter) { - $cleared = $adapter->clear() && $cleared; + while ($i--) { + $cleared = $this->adapters[$i]->clear() && $cleared; } return $cleared; @@ -160,9 +163,10 @@ public function clear() public function deleteItem($key) { $deleted = true; + $i = $this->adapterCount; - foreach ($this->adapters as $adapter) { - $deleted = $adapter->deleteItem($key) && $deleted; + while ($i--) { + $deleted = $this->adapters[$i]->deleteItem($key) && $deleted; } return $deleted; @@ -174,9 +178,10 @@ public function deleteItem($key) public function deleteItems(array $keys) { $deleted = true; + $i = $this->adapterCount; - foreach ($this->adapters as $adapter) { - $deleted = $adapter->deleteItems($keys) && $deleted; + while ($i--) { + $deleted = $this->adapters[$i]->deleteItems($keys) && $deleted; } return $deleted; @@ -188,9 +193,10 @@ public function deleteItems(array $keys) public function save(CacheItemInterface $item) { $saved = true; + $i = $this->adapterCount; - foreach ($this->adapters as $adapter) { - $saved = $adapter->save($item) && $saved; + while ($i--) { + $saved = $this->adapters[$i]->save($item) && $saved; } return $saved; @@ -202,9 +208,10 @@ public function save(CacheItemInterface $item) public function saveDeferred(CacheItemInterface $item) { $saved = true; + $i = $this->adapterCount; - foreach ($this->adapters as $adapter) { - $saved = $adapter->saveDeferred($item) && $saved; + while ($i--) { + $saved = $this->adapters[$i]->saveDeferred($item) && $saved; } return $saved; @@ -216,9 +223,10 @@ public function saveDeferred(CacheItemInterface $item) public function commit() { $committed = true; + $i = $this->adapterCount; - foreach ($this->adapters as $adapter) { - $committed = $adapter->commit() && $committed; + while ($i--) { + $committed = $this->adapters[$i]->commit() && $committed; } return $committed; diff --git a/src/Symfony/Component/Cache/Adapter/FilesystemAdapter.php b/src/Symfony/Component/Cache/Adapter/FilesystemAdapter.php index 81886b4d11a54..686c532239d26 100644 --- a/src/Symfony/Component/Cache/Adapter/FilesystemAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/FilesystemAdapter.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Adapter; +use Symfony\Component\Cache\Exception\CacheException; use Symfony\Component\Cache\Exception\InvalidArgumentException; /** @@ -39,9 +40,7 @@ public function __construct($namespace = '', $defaultLifetime = 0, $directory = if (false === $dir = realpath($dir) ?: (file_exists($dir) ? $dir : false)) { throw new InvalidArgumentException(sprintf('Cache directory does not exist (%s)', $directory)); } - if (!is_writable($dir .= DIRECTORY_SEPARATOR)) { - throw new InvalidArgumentException(sprintf('Cache directory is not writable (%s)', $directory)); - } + $dir .= DIRECTORY_SEPARATOR; // On Windows the whole path is limited to 258 chars if ('\\' === DIRECTORY_SEPARATOR && strlen($dir) > 234) { throw new InvalidArgumentException(sprintf('Cache directory too long (%s)', $directory)); @@ -141,6 +140,10 @@ protected function doSave(array $values, $lifetime) } } + if (!$ok && !is_writable($this->directory)) { + throw new CacheException(sprintf('Cache directory is not writable (%s)', $this->directory)); + } + return $ok; } diff --git a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php index a636124acba9f..3a59e837ee134 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php @@ -25,7 +25,7 @@ class RedisAdapter extends AbstractAdapter private static $defaultConnectionOptions = array( 'class' => null, 'persistent' => 0, - 'timeout' => 0, + 'timeout' => 30, 'read_timeout' => 0, 'retry_interval' => 0, ); diff --git a/src/Symfony/Component/Cache/CHANGELOG.md b/src/Symfony/Component/Cache/CHANGELOG.md new file mode 100644 index 0000000000000..0fc0cdfba6a9a --- /dev/null +++ b/src/Symfony/Component/Cache/CHANGELOG.md @@ -0,0 +1,10 @@ +CHANGELOG +========= + +3.1.0 +----- + + * added the component with strict PSR-6 implementations + * added ApcuAdapter, ArrayAdapter, FilesystemAdapter and RedisAdapter + * added AbstractAdapter, ChainAdapter and ProxyAdapter + * added DoctrineAdapter and DoctrineProvider for bidirectional interoperability with Doctrine Cache diff --git a/src/Symfony/Component/Cache/LICENSE b/src/Symfony/Component/Cache/LICENSE index 0564c5a9b7f1f..ce39894f6a9a2 100644 --- a/src/Symfony/Component/Cache/LICENSE +++ b/src/Symfony/Component/Cache/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016 Fabien Potencier +Copyright (c) 2016-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/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index edbdd551bf297..92865157f11e9 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -269,7 +269,13 @@ private static function compressCode($code) */ private static function writeCacheFile($file, $content) { - $tmpFile = tempnam(dirname($file), basename($file)); + $dir = dirname($file); + if (!is_writable($dir)) { + throw new \RuntimeException(sprintf('Cache directory "%s" is not writable.', $dir)); + } + + $tmpFile = tempnam($dir, basename($file)); + if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { @chmod($file, 0666 & ~umask()); diff --git a/src/Symfony/Component/ClassLoader/LICENSE b/src/Symfony/Component/ClassLoader/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/ClassLoader/LICENSE +++ b/src/Symfony/Component/ClassLoader/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/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index dc1c2fd8db224..a1fc1fab0ef78 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -86,7 +86,7 @@ public function prototype($type) * If this function has been called and the node is not set during the finalization * phase, it's default value will be derived from its children default values. * - * @return ArrayNodeDefinition + * @return $this */ public function addDefaultsIfNotSet() { @@ -102,7 +102,7 @@ public function addDefaultsIfNotSet() * * This method is applicable to prototype nodes only. * - * @return ArrayNodeDefinition + * @return $this */ public function addDefaultChildrenIfNoneSet($children = null) { @@ -116,7 +116,7 @@ public function addDefaultChildrenIfNoneSet($children = null) * * This method is applicable to prototype nodes only. * - * @return ArrayNodeDefinition + * @return $this */ public function requiresAtLeastOneElement() { @@ -130,7 +130,7 @@ public function requiresAtLeastOneElement() * * If used all keys have to be defined in the same configuration file. * - * @return ArrayNodeDefinition + * @return $this */ public function disallowNewKeysInSubsequentConfigs() { @@ -145,7 +145,7 @@ public function disallowNewKeysInSubsequentConfigs() * @param string $singular The key to remap * @param string $plural The plural of the key for irregular plurals * - * @return ArrayNodeDefinition + * @return $this */ public function fixXmlConfig($singular, $plural = null) { @@ -180,7 +180,7 @@ public function fixXmlConfig($singular, $plural = null) * @param string $name The name of the key * @param bool $removeKeyItem Whether or not the key item should be removed * - * @return ArrayNodeDefinition + * @return $this */ public function useAttributeAsKey($name, $removeKeyItem = true) { @@ -195,7 +195,7 @@ public function useAttributeAsKey($name, $removeKeyItem = true) * * @param bool $allow * - * @return ArrayNodeDefinition + * @return $this */ public function canBeUnset($allow = true) { @@ -217,7 +217,7 @@ public function canBeUnset($allow = true) * enableableArrayNode: {enabled: false, ...} # The config is disabled * enableableArrayNode: false # The config is disabled * - * @return ArrayNodeDefinition + * @return $this */ public function canBeEnabled() { @@ -247,7 +247,7 @@ public function canBeEnabled() * * By default, the section is enabled. * - * @return ArrayNodeDefinition + * @return $this */ public function canBeDisabled() { @@ -267,7 +267,7 @@ public function canBeDisabled() /** * Disables the deep merging of the node. * - * @return ArrayNodeDefinition + * @return $this */ public function performNoDeepMerging() { @@ -287,7 +287,7 @@ public function performNoDeepMerging() * * @param bool $remove Whether to remove the extra keys * - * @return ArrayNodeDefinition + * @return $this */ public function ignoreExtraKeys($remove = true) { @@ -302,7 +302,7 @@ public function ignoreExtraKeys($remove = true) * * @param bool $bool Whether to enable key normalization * - * @return ArrayNodeDefinition + * @return $this */ public function normalizeKeys($bool) { @@ -324,7 +324,7 @@ public function normalizeKeys($bool) * * @param NodeDefinition $node A NodeDefinition instance * - * @return ArrayNodeDefinition This node + * @return $this */ public function append(NodeDefinition $node) { diff --git a/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php index 5d3ff014f1823..56047ad5dec2c 100644 --- a/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php @@ -25,7 +25,7 @@ class EnumNodeDefinition extends ScalarNodeDefinition /** * @param array $values * - * @return EnumNodeDefinition|$this + * @return $this */ public function values(array $values) { diff --git a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php index 3d79b2985874e..10112a813df7a 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php @@ -40,7 +40,7 @@ public function __construct(NodeDefinition $node) * * @param \Closure $then * - * @return ExprBuilder + * @return $this */ public function always(\Closure $then = null) { @@ -60,7 +60,7 @@ public function always(\Closure $then = null) * * @param \Closure $closure * - * @return ExprBuilder + * @return $this */ public function ifTrue(\Closure $closure = null) { @@ -76,7 +76,7 @@ public function ifTrue(\Closure $closure = null) /** * Tests if the value is a string. * - * @return ExprBuilder + * @return $this */ public function ifString() { @@ -88,7 +88,7 @@ public function ifString() /** * Tests if the value is null. * - * @return ExprBuilder + * @return $this */ public function ifNull() { @@ -100,7 +100,7 @@ public function ifNull() /** * Tests if the value is an array. * - * @return ExprBuilder + * @return $this */ public function ifArray() { @@ -114,7 +114,7 @@ public function ifArray() * * @param array $array * - * @return ExprBuilder + * @return $this */ public function ifInArray(array $array) { @@ -128,7 +128,7 @@ public function ifInArray(array $array) * * @param array $array * - * @return ExprBuilder + * @return $this */ public function ifNotInArray(array $array) { @@ -142,7 +142,7 @@ public function ifNotInArray(array $array) * * @param \Closure $closure * - * @return ExprBuilder + * @return $this */ public function then(\Closure $closure) { @@ -154,7 +154,7 @@ public function then(\Closure $closure) /** * Sets a closure returning an empty array. * - * @return ExprBuilder + * @return $this */ public function thenEmptyArray() { @@ -170,7 +170,7 @@ public function thenEmptyArray() * * @param string $message * - * @return ExprBuilder + * @return $this * * @throws \InvalidArgumentException */ @@ -184,7 +184,7 @@ public function thenInvalid($message) /** * Sets a closure unsetting this key of the array at validation time. * - * @return ExprBuilder + * @return $this * * @throws UnsetKeyException */ @@ -198,7 +198,7 @@ public function thenUnset() /** * Returns the related node. * - * @return NodeDefinition + * @return NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition * * @throws \RuntimeException */ diff --git a/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php index f908a499cab20..1d24953df5742 100644 --- a/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php @@ -37,7 +37,7 @@ public function __construct(NodeDefinition $node) * * @param bool $allow * - * @return MergeBuilder + * @return $this */ public function allowUnset($allow = true) { @@ -51,7 +51,7 @@ public function allowUnset($allow = true) * * @param bool $deny Whether the overwriting is forbidden or not * - * @return MergeBuilder + * @return $this */ public function denyOverwrite($deny = true) { @@ -63,7 +63,7 @@ public function denyOverwrite($deny = true) /** * Returns the related node. * - * @return NodeDefinition + * @return NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition */ public function end() { diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php index 2a063f1bd9130..e780777a1e837 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php @@ -42,7 +42,7 @@ public function __construct() * * @param ParentNodeDefinitionInterface $parent The parent node * - * @return NodeBuilder This node builder + * @return $this */ public function setParent(ParentNodeDefinitionInterface $parent = null) { @@ -182,7 +182,7 @@ public function node($name, $type) * * @param NodeDefinition $node * - * @return NodeBuilder This node builder + * @return $this */ public function append(NodeDefinition $node) { @@ -207,7 +207,7 @@ public function append(NodeDefinition $node) * @param string $type The name of the type * @param string $class The fully qualified name the node definition class * - * @return NodeBuilder This node builder + * @return $this */ public function setNodeClass($type, $class) { diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index 4633dc7d2a5a6..1b712a3150bc3 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -56,7 +56,7 @@ public function __construct($name, NodeParentInterface $parent = null) * * @param NodeParentInterface $parent The parent * - * @return NodeDefinition|$this + * @return $this */ public function setParent(NodeParentInterface $parent) { @@ -70,7 +70,7 @@ public function setParent(NodeParentInterface $parent) * * @param string $info The info text * - * @return NodeDefinition|$this + * @return $this */ public function info($info) { @@ -82,7 +82,7 @@ public function info($info) * * @param string|array $example * - * @return NodeDefinition|$this + * @return $this */ public function example($example) { @@ -95,7 +95,7 @@ public function example($example) * @param string $key * @param mixed $value * - * @return NodeDefinition|$this + * @return $this */ public function attribute($key, $value) { @@ -107,7 +107,7 @@ public function attribute($key, $value) /** * Returns the parent node. * - * @return NodeParentInterface|NodeBuilder|NodeDefinition|null The builder of the parent node + * @return NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null The builder of the parent node */ public function end() { @@ -146,7 +146,7 @@ public function getNode($forceRootNode = false) * * @param mixed $value The default value * - * @return NodeDefinition|$this + * @return $this */ public function defaultValue($value) { @@ -159,7 +159,7 @@ public function defaultValue($value) /** * Sets the node as required. * - * @return NodeDefinition|$this + * @return $this */ public function isRequired() { @@ -173,7 +173,7 @@ public function isRequired() * * @param mixed $value * - * @return NodeDefinition|$this + * @return $this */ public function treatNullLike($value) { @@ -187,7 +187,7 @@ public function treatNullLike($value) * * @param mixed $value * - * @return NodeDefinition|$this + * @return $this */ public function treatTrueLike($value) { @@ -201,7 +201,7 @@ public function treatTrueLike($value) * * @param mixed $value * - * @return NodeDefinition|$this + * @return $this */ public function treatFalseLike($value) { @@ -213,7 +213,7 @@ public function treatFalseLike($value) /** * Sets null as the default value. * - * @return NodeDefinition|$this + * @return $this */ public function defaultNull() { @@ -223,7 +223,7 @@ public function defaultNull() /** * Sets true as the default value. * - * @return NodeDefinition|$this + * @return $this */ public function defaultTrue() { @@ -233,7 +233,7 @@ public function defaultTrue() /** * Sets false as the default value. * - * @return NodeDefinition|$this + * @return $this */ public function defaultFalse() { @@ -253,7 +253,7 @@ public function beforeNormalization() /** * Denies the node value being empty. * - * @return NodeDefinition|$this + * @return $this */ public function cannotBeEmpty() { @@ -281,7 +281,7 @@ public function validate() * * @param bool $deny Whether the overwriting is forbidden or not * - * @return NodeDefinition|$this + * @return $this */ public function cannotBeOverwritten($deny = true) { diff --git a/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php index 748c9f28cbece..ae642a2d49a2c 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php @@ -38,7 +38,7 @@ public function __construct(NodeDefinition $node) * @param string $key The key to remap * @param string $plural The plural of the key in case of irregular plural * - * @return NormalizationBuilder + * @return $this */ public function remap($key, $plural = null) { @@ -52,7 +52,7 @@ public function remap($key, $plural = null) * * @param \Closure $closure * - * @return ExprBuilder|NormalizationBuilder + * @return ExprBuilder|$this */ public function before(\Closure $closure = null) { diff --git a/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php index 8451e75b2661a..0d0207ca4fc79 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php @@ -28,7 +28,7 @@ abstract class NumericNodeDefinition extends ScalarNodeDefinition * * @param mixed $max * - * @return NumericNodeDefinition + * @return $this * * @throws \InvalidArgumentException when the constraint is inconsistent */ @@ -47,7 +47,7 @@ public function max($max) * * @param mixed $min * - * @return NumericNodeDefinition + * @return $this * * @throws \InvalidArgumentException when the constraint is inconsistent */ diff --git a/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php index e885823892645..12aa59a4fd61c 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php @@ -36,7 +36,7 @@ public function __construct(NodeDefinition $node) * * @param \Closure $closure * - * @return ExprBuilder|ValidationBuilder + * @return ExprBuilder|$this */ public function rule(\Closure $closure = null) { diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index ae1a76663a411..1c3c2188326be 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -29,6 +29,10 @@ class PrototypedArrayNode extends ArrayNode protected $minNumberOfElements = 0; protected $defaultValue = array(); protected $defaultChildren; + /** + * @var NodeInterface[] An array of the prototypes of the simplified value children + */ + private $valuePrototypes = array(); /** * Sets the minimum number of elements that a prototype based node must @@ -194,9 +198,9 @@ protected function finalizeValue($value) } foreach ($value as $k => $v) { - $this->prototype->setName($k); + $prototype = $this->getPrototypeForChild($k); try { - $value[$k] = $this->prototype->finalize($v); + $value[$k] = $prototype->finalize($v); } catch (UnsetKeyException $e) { unset($value[$k]); } @@ -250,8 +254,18 @@ protected function normalizeValue($value) } // if only "value" is left - if (1 == count($v) && isset($v['value'])) { + if (array_keys($v) === array('value')) { $v = $v['value']; + if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && array_key_exists('value', $children)) { + $valuePrototype = current($this->valuePrototypes) ?: clone $children['value']; + $valuePrototype->parent = $this; + $originalClosures = $this->prototype->normalizationClosures; + if (is_array($originalClosures)) { + $valuePrototypeClosures = $valuePrototype->normalizationClosures; + $valuePrototype->normalizationClosures = is_array($valuePrototypeClosures) ? array_merge($originalClosures, $valuePrototypeClosures) : $originalClosures; + } + $this->valuePrototypes[$k] = $valuePrototype; + } } } @@ -264,11 +278,11 @@ protected function normalizeValue($value) } } - $this->prototype->setName($k); + $prototype = $this->getPrototypeForChild($k); if (null !== $this->keyAttribute || $isAssoc) { - $normalized[$k] = $this->prototype->normalize($v); + $normalized[$k] = $prototype->normalize($v); } else { - $normalized[] = $this->prototype->normalize($v); + $normalized[] = $prototype->normalize($v); } } @@ -322,10 +336,54 @@ protected function mergeValues($leftSide, $rightSide) continue; } - $this->prototype->setName($k); - $leftSide[$k] = $this->prototype->merge($leftSide[$k], $v); + $prototype = $this->getPrototypeForChild($k); + $leftSide[$k] = $prototype->merge($leftSide[$k], $v); } return $leftSide; } + + /** + * Returns a prototype for the child node that is associated to $key in the value array. + * For general child nodes, this will be $this->prototype. + * But if $this->removeKeyAttribute is true and there are only two keys in the child node: + * one is same as this->keyAttribute and the other is 'value', then the prototype will be different. + * + * For example, assume $this->keyAttribute is 'name' and the value array is as follows: + * array( + * array( + * 'name' => 'name001', + * 'value' => 'value001' + * ) + * ) + * + * Now, the key is 0 and the child node is: + * array( + * 'name' => 'name001', + * 'value' => 'value001' + * ) + * + * When normalizing the value array, the 'name' element will removed from the child node + * and its value becomes the new key of the child node: + * array( + * 'name001' => array('value' => 'value001') + * ) + * + * Now only 'value' element is left in the child node which can be further simplified into a string: + * array('name001' => 'value001') + * + * Now, the key becomes 'name001' and the child node becomes 'value001' and + * the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance. + * + * @param string $key The key of the child node + * + * @return mixed The prototype instance + */ + private function getPrototypeForChild($key) + { + $prototype = isset($this->valuePrototypes[$key]) ? $this->valuePrototypes[$key] : $this->prototype; + $prototype->setName($key); + + return $prototype; + } } diff --git a/src/Symfony/Component/Config/LICENSE b/src/Symfony/Component/Config/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Config/LICENSE +++ b/src/Symfony/Component/Config/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/Component/Config/Loader/Loader.php b/src/Symfony/Component/Config/Loader/Loader.php index de4e127386d8b..a6f8d9c66454c 100644 --- a/src/Symfony/Component/Config/Loader/Loader.php +++ b/src/Symfony/Component/Config/Loader/Loader.php @@ -57,7 +57,7 @@ public function import($resource, $type = null) * @param mixed $resource A resource * @param string|null $type The resource type or null if unknown * - * @return LoaderInterface A LoaderInterface instance + * @return $this|LoaderInterface * * @throws FileLoaderLoadException If no loader is found */ diff --git a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php index c343fcfd94fc0..77013a14b2d98 100644 --- a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php @@ -14,6 +14,7 @@ use Symfony\Component\Config\Definition\PrototypedArrayNode; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\ScalarNode; +use Symfony\Component\Config\Definition\VariableNode; class PrototypedArrayNodeTest extends \PHPUnit_Framework_TestCase { @@ -177,4 +178,164 @@ protected function getPrototypeNodeWithDefaultChildren() return $node; } + + /** + * Tests that when a key attribute is mapped, that key is removed from the array. + * And if only 'value' element is left in the array, it will replace its wrapper array. + * + * + * + * + * The above should finally be mapped to an array that looks like this + * (because "id" is the key attribute). + * + * array( + * 'things' => array( + * 'option1' => 'value1' + * ) + * ) + * + * It's also possible to mix 'value-only' and 'non-value-only' elements in the array. + * + * + * + * + * The above should finally be mapped to an array as follows + * + * array( + * 'things' => array( + * 'option1' => 'value1', + * 'option2' => array( + * 'value' => 'value2', + * 'foo' => 'foo2' + * ) + * ) + * ) + * + * The 'value' element can also be ArrayNode: + * + * + * + * + * + * The above should be finally be mapped to an array as follows + * + * array( + * 'things' => array( + * 'option1' => array( + * 'foo' => 'foo1', + * 'bar' => 'bar1' + * ) + * ) + * ) + * + * If using VariableNode for value node, it's also possible to mix different types of value nodes: + * + * + * + * + * + * The above should be finally mapped to an array as follows + * + * array( + * 'things' => array( + * 'option1' => array( + * 'foo' => 'foo1', + * 'bar' => 'bar1' + * ), + * 'option2' => 'value2' + * ) + * ) + * + * + * @dataProvider getDataForKeyRemovedLeftValueOnly + */ + public function testMappedAttributeKeyIsRemovedLeftValueOnly($value, $children, $expected) + { + $node = new PrototypedArrayNode('root'); + $node->setKeyAttribute('id', true); + + // each item under the root is an array, with one scalar item + $prototype = new ArrayNode(null, $node); + $prototype->addChild(new ScalarNode('id')); + $prototype->addChild(new ScalarNode('foo')); + $prototype->addChild($value); + $node->setPrototype($prototype); + + $normalized = $node->normalize($children); + $this->assertEquals($expected, $normalized); + } + + public function getDataForKeyRemovedLeftValueOnly() + { + $scalarValue = new ScalarNode('value'); + + $arrayValue = new ArrayNode('value'); + $arrayValue->addChild(new ScalarNode('foo')); + $arrayValue->addChild(new ScalarNode('bar')); + + $variableValue = new VariableNode('value'); + + return array( + array( + $scalarValue, + array( + array('id' => 'option1', 'value' => 'value1'), + ), + array('option1' => 'value1'), + ), + + array( + $scalarValue, + array( + array('id' => 'option1', 'value' => 'value1'), + array('id' => 'option2', 'value' => 'value2', 'foo' => 'foo2'), + ), + array( + 'option1' => 'value1', + 'option2' => array('value' => 'value2', 'foo' => 'foo2'), + ), + ), + + array( + $arrayValue, + array( + array( + 'id' => 'option1', + 'value' => array('foo' => 'foo1', 'bar' => 'bar1'), + ), + ), + array( + 'option1' => array('foo' => 'foo1', 'bar' => 'bar1'), + ), + ), + + array($variableValue, + array( + array( + 'id' => 'option1', 'value' => array('foo' => 'foo1', 'bar' => 'bar1'), + ), + array('id' => 'option2', 'value' => 'value2'), + ), + array( + 'option1' => array('foo' => 'foo1', 'bar' => 'bar1'), + 'option2' => 'value2', + ), + ), + ); + } } diff --git a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php index cdb0980307f8b..8f3039df8ed42 100644 --- a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php @@ -33,12 +33,12 @@ public function testGetSetResolver() public function testSupports() { - $loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader1->expects($this->once())->method('supports')->will($this->returnValue(true)); $loader = new DelegatingLoader(new LoaderResolver(array($loader1))); $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); - $loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader1->expects($this->once())->method('supports')->will($this->returnValue(false)); $loader = new DelegatingLoader(new LoaderResolver(array($loader1))); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable'); @@ -46,7 +46,7 @@ public function testSupports() public function testLoad() { - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); $loader->expects($this->once())->method('load'); $resolver = new LoaderResolver(array($loader)); @@ -60,7 +60,7 @@ public function testLoad() */ public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded() { - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->once())->method('supports')->will($this->returnValue(false)); $resolver = new LoaderResolver(array($loader)); $loader = new DelegatingLoader($resolver); diff --git a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php index 1e8e91eda1c16..8f46051bd8ba1 100644 --- a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php @@ -18,9 +18,9 @@ class FileLoaderTest extends \PHPUnit_Framework_TestCase { public function testImportWithFileLocatorDelegation() { - $locatorMock = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); - $locatorMockForAdditionalLoader = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + $locatorMockForAdditionalLoader = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls( array('path/to/file1'), // Default array('path/to/file1', 'path/to/file2'), // First is imported diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php index 03db21be4e2c0..1685f32ed060d 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php @@ -18,7 +18,7 @@ class LoaderResolverTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $resolver = new LoaderResolver(array( - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'), + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(), )); $this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument'); @@ -26,11 +26,11 @@ public function testConstructor() public function testResolve() { - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $resolver = new LoaderResolver(array($loader)); $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource'); - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); $resolver = new LoaderResolver(array($loader)); $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource'); @@ -39,7 +39,7 @@ public function testResolve() public function testLoaders() { $resolver = new LoaderResolver(); - $resolver->addLoader($loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface')); + $resolver->addLoader($loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock()); $this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader'); } diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php index e938a4b071775..e9f79a8d6ddb2 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php @@ -17,7 +17,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase { public function testGetSetResolver() { - $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $loader = new ProjectLoader1(); $loader->setResolver($resolver); @@ -27,9 +27,9 @@ public function testGetSetResolver() public function testResolve() { - $resolvedLoader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo.xml') @@ -47,7 +47,7 @@ public function testResolve() */ public function testResolveWhenResolverCannotFindLoader() { - $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('FOOBAR') @@ -61,13 +61,13 @@ public function testResolveWhenResolverCannotFindLoader() public function testImport() { - $resolvedLoader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $resolvedLoader->expects($this->once()) ->method('load') ->with('foo') ->will($this->returnValue('yes')); - $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo') @@ -81,13 +81,13 @@ public function testImport() public function testImportWithType() { - $resolvedLoader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $resolvedLoader->expects($this->once()) ->method('load') ->with('foo', 'bar') ->will($this->returnValue('yes')); - $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo', 'bar') diff --git a/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php b/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php index c76c0dd0ac2b9..d66c2e89d95b8 100644 --- a/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php +++ b/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php @@ -44,7 +44,7 @@ public function testGetPath() public function testCacheIsNotFreshIfEmpty() { - $checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface') + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock() ->expects($this->never())->method('supports'); /* If there is nothing in the cache, it needs to be filled (and thus it's not fresh). @@ -75,7 +75,7 @@ public function testResourcesWithoutcheckersAreIgnoredAndConsideredFresh() public function testIsFreshWithchecker() { - $checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface'); + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); $checker->expects($this->once()) ->method('supports') @@ -93,7 +93,7 @@ public function testIsFreshWithchecker() public function testIsNotFreshWithchecker() { - $checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface'); + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); $checker->expects($this->once()) ->method('supports') @@ -111,7 +111,7 @@ public function testIsNotFreshWithchecker() public function testCacheIsNotFreshWhenUnserializeFails() { - $checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface'); + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); $cache->write('foo', array(new FileResource(__FILE__))); diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index cefd4f29556df..14aed808f59ba 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -47,7 +47,7 @@ public function testLoadFile() $this->assertContains('XSD file or callable', $e->getMessage()); } - $mock = $this->getMock(__NAMESPACE__.'\Validator'); + $mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock(); $mock->expects($this->exactly(2))->method('validate')->will($this->onConsecutiveCalls(false, true)); try { diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index b2a49e363cf23..81a20ef7b361e 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -99,8 +99,6 @@ public function setDispatcher(EventDispatcherInterface $dispatcher) * @param OutputInterface $output An Output instance * * @return int 0 if everything went fine, or an error code - * - * @throws \Exception When doRun returns Exception */ public function run(InputInterface $input = null, OutputInterface $output = null) { @@ -404,7 +402,7 @@ public function add(Command $command) * * @return Command A Command object * - * @throws CommandNotFoundException When command name given does not exist + * @throws CommandNotFoundException When given command name does not exist */ public function get($name) { @@ -748,7 +746,7 @@ public function getTerminalDimensions() * @param int $width The width * @param int $height The height * - * @return Application The current application + * @return $this */ public function setTerminalDimensions($width, $height) { @@ -805,8 +803,6 @@ protected function configureIO(InputInterface $input, OutputInterface $output) * @param OutputInterface $output An Output instance * * @return int 0 if everything went fine, or an error code - * - * @throws \Exception when the command being run threw an exception */ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index c3a5aa2d0d8de..14875877044ea 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -227,7 +227,14 @@ public function run(InputInterface $input, OutputInterface $output) if (null !== $this->processTitle) { if (function_exists('cli_set_process_title')) { - cli_set_process_title($this->processTitle); + if (false === @cli_set_process_title($this->processTitle)) { + if ('Darwin' === PHP_OS) { + $output->writeln('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.'); + } else { + $error = error_get_last(); + trigger_error($error['message'], E_USER_WARNING); + } + } } elseif (function_exists('setproctitle')) { setproctitle($this->processTitle); } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) { @@ -265,7 +272,7 @@ public function run(InputInterface $input, OutputInterface $output) * * @param callable $code A callable(InputInterface $input, OutputInterface $output) * - * @return Command The current instance + * @return $this * * @throws InvalidArgumentException * @@ -276,7 +283,15 @@ public function setCode(callable $code) if ($code instanceof \Closure) { $r = new \ReflectionFunction($code); if (null === $r->getClosureThis()) { - $code = \Closure::bind($code, $this); + if (PHP_VERSION_ID < 70000) { + // Bug in PHP5: https://bugs.php.net/bug.php?id=64761 + // This means that we cannot bind static closures and therefore we must + // ignore any errors here. There is no way to test if the closure is + // bindable. + $code = @\Closure::bind($code, $this); + } else { + $code = \Closure::bind($code, $this); + } } } @@ -317,7 +332,7 @@ public function mergeApplicationDefinition($mergeArgs = true) * * @param array|InputDefinition $definition An array of argument and option instances or a definition instance * - * @return Command The current instance + * @return $this */ public function setDefinition($definition) { @@ -365,7 +380,7 @@ public function getNativeDefinition() * @param string $description A description text * @param mixed $default The default value (for InputArgument::OPTIONAL mode only) * - * @return Command The current instance + * @return $this */ public function addArgument($name, $mode = null, $description = '', $default = null) { @@ -383,7 +398,7 @@ public function addArgument($name, $mode = null, $description = '', $default = n * @param string $description A description text * @param mixed $default The default value (must be null for InputOption::VALUE_NONE) * - * @return Command The current instance + * @return $this */ public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null) { @@ -402,7 +417,7 @@ public function addOption($name, $shortcut = null, $mode = null, $description = * * @param string $name The command name * - * @return Command The current instance + * @return $this * * @throws InvalidArgumentException When the name is invalid */ @@ -425,7 +440,7 @@ public function setName($name) * * @param string $title The process title * - * @return Command The current instance + * @return $this */ public function setProcessTitle($title) { @@ -449,7 +464,7 @@ public function getName() * * @param string $description The description for the command * - * @return Command The current instance + * @return $this */ public function setDescription($description) { @@ -473,7 +488,7 @@ public function getDescription() * * @param string $help The help for the command * - * @return Command The current instance + * @return $this */ public function setHelp($help) { @@ -519,7 +534,7 @@ public function getProcessedHelp() * * @param string[] $aliases An array of aliases for the command * - * @return Command The current instance + * @return $this * * @throws InvalidArgumentException When an alias is invalid */ @@ -571,7 +586,7 @@ public function getSynopsis($short = false) * * @param string $usage The usage, it'll be prefixed with the command name * - * @return Command The current instance + * @return $this */ public function addUsage($usage) { diff --git a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php index 2eb9944d6213c..c2d6243e280cc 100644 --- a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\Helper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; @@ -94,7 +95,7 @@ protected function describeCommand(Command $command, array $options = array()) $this->write( $command->getName()."\n" - .str_repeat('-', strlen($command->getName()))."\n\n" + .str_repeat('-', Helper::strlen($command->getName()))."\n\n" .'* Description: '.($command->getDescription() ?: '')."\n" .'* Usage:'."\n\n" .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) { @@ -121,7 +122,7 @@ protected function describeApplication(Application $application, array $options $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; $description = new ApplicationDescription($application, $describedNamespace); - $this->write($application->getName()."\n".str_repeat('=', strlen($application->getName()))); + $this->write($application->getName()."\n".str_repeat('=', Helper::strlen($application->getName()))); foreach ($description->getNamespaces() as $namespace) { if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index c2eb78d0d9b27..c7fccdeaddb98 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -13,6 +13,8 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Formatter\OutputFormatter; +use Symfony\Component\Console\Helper\Helper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; @@ -37,7 +39,7 @@ protected function describeInputArgument(InputArgument $argument, array $options $default = ''; } - $totalWidth = isset($options['total_width']) ? $options['total_width'] : strlen($argument->getName()); + $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName()); $spacingWidth = $totalWidth - strlen($argument->getName()); $this->writeText(sprintf(' %s %s%s%s', @@ -75,7 +77,7 @@ protected function describeInputOption(InputOption $option, array $options = arr sprintf('--%s%s', $option->getName(), $value) ); - $spacingWidth = $totalWidth - strlen($synopsis); + $spacingWidth = $totalWidth - Helper::strlen($synopsis); $this->writeText(sprintf(' %s %s%s%s%s', $synopsis, @@ -94,7 +96,7 @@ protected function describeInputDefinition(InputDefinition $definition, array $o { $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions()); foreach ($definition->getArguments() as $argument) { - $totalWidth = max($totalWidth, strlen($argument->getName())); + $totalWidth = max($totalWidth, Helper::strlen($argument->getName())); } if ($definition->getArguments()) { @@ -206,7 +208,7 @@ protected function describeApplication(Application $application, array $options foreach ($namespace['commands'] as $name) { $this->writeText("\n"); - $spacingWidth = $width - strlen($name); + $spacingWidth = $width - Helper::strlen($name); $this->writeText(sprintf(' %s%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options); } } @@ -235,6 +237,16 @@ private function writeText($content, array $options = array()) */ private function formatDefaultValue($default) { + if (is_string($default)) { + $default = OutputFormatter::escape($default); + } elseif (is_array($default)) { + foreach ($default as $key => $value) { + if (is_string($value)) { + $default[$key] = OutputFormatter::escape($value); + } + } + } + return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } @@ -248,9 +260,9 @@ private function getColumnWidth(array $commands) $widths = array(); foreach ($commands as $command) { - $widths[] = strlen($command->getName()); + $widths[] = Helper::strlen($command->getName()); foreach ($command->getAliases() as $alias) { - $widths[] = strlen($alias); + $widths[] = Helper::strlen($alias); } } @@ -267,10 +279,10 @@ private function calculateTotalWidthForOptions($options) $totalWidth = 0; foreach ($options as $option) { // "-" + shortcut + ", --" + name - $nameLength = 1 + max(strlen($option->getShortcut()), 1) + 4 + strlen($option->getName()); + $nameLength = 1 + max(strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName()); if ($option->acceptValue()) { - $valueLength = 1 + strlen($option->getName()); // = + value + $valueLength = 1 + Helper::strlen($option->getName()); // = + value $valueLength += $option->isValueOptional() ? 2 : 0; // [ + ] $nameLength += $valueLength; diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 56cd5e568f16d..dee6967594b36 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -35,6 +35,20 @@ public static function escape($text) { $text = preg_replace('/([^\\\\]?)getQuestion()); + $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion()); $default = $question->getDefault(); switch (true) { diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 1434562dfea69..37ba3f53238ee 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -107,7 +107,7 @@ public static function setStyleDefinition($name, TableStyle $style) * * @param string $name The style name * - * @return TableStyle A TableStyle instance + * @return TableStyle */ public static function getStyleDefinition($name) { @@ -127,7 +127,7 @@ public static function getStyleDefinition($name) * * @param TableStyle|string $name The style name or a TableStyle instance * - * @return Table + * @return $this */ public function setStyle($name) { @@ -152,7 +152,7 @@ public function getStyle() * @param int $columnIndex Column index * @param TableStyle|string $name The style name or a TableStyle instance * - * @return Table + * @return $this */ public function setColumnStyle($columnIndex, $name) { @@ -187,7 +187,7 @@ public function getColumnStyle($columnIndex) * @param int $columnIndex Column index * @param int $width Minimum column width in characters * - * @return Table + * @return $this */ public function setColumnWidth($columnIndex, $width) { @@ -201,7 +201,7 @@ public function setColumnWidth($columnIndex, $width) * * @param array $widths * - * @return Table + * @return $this */ public function setColumnWidths(array $widths) { diff --git a/src/Symfony/Component/Console/Helper/TableStyle.php b/src/Symfony/Component/Console/Helper/TableStyle.php index d7e28ff2b4ead..2999c76f86ad3 100644 --- a/src/Symfony/Component/Console/Helper/TableStyle.php +++ b/src/Symfony/Component/Console/Helper/TableStyle.php @@ -37,7 +37,7 @@ class TableStyle * * @param string $paddingChar * - * @return TableStyle + * @return $this */ public function setPaddingChar($paddingChar) { @@ -65,7 +65,7 @@ public function getPaddingChar() * * @param string $horizontalBorderChar * - * @return TableStyle + * @return $this */ public function setHorizontalBorderChar($horizontalBorderChar) { @@ -89,7 +89,7 @@ public function getHorizontalBorderChar() * * @param string $verticalBorderChar * - * @return TableStyle + * @return $this */ public function setVerticalBorderChar($verticalBorderChar) { @@ -113,7 +113,7 @@ public function getVerticalBorderChar() * * @param string $crossingChar * - * @return TableStyle + * @return $this */ public function setCrossingChar($crossingChar) { @@ -137,7 +137,7 @@ public function getCrossingChar() * * @param string $cellHeaderFormat * - * @return TableStyle + * @return $this */ public function setCellHeaderFormat($cellHeaderFormat) { @@ -161,7 +161,7 @@ public function getCellHeaderFormat() * * @param string $cellRowFormat * - * @return TableStyle + * @return $this */ public function setCellRowFormat($cellRowFormat) { @@ -185,7 +185,7 @@ public function getCellRowFormat() * * @param string $cellRowContentFormat * - * @return TableStyle + * @return $this */ public function setCellRowContentFormat($cellRowContentFormat) { @@ -209,7 +209,7 @@ public function getCellRowContentFormat() * * @param string $borderFormat * - * @return TableStyle + * @return $this */ public function setBorderFormat($borderFormat) { @@ -233,7 +233,7 @@ public function getBorderFormat() * * @param int $padType STR_PAD_* * - * @return TableStyle + * @return $this */ public function setPadType($padType) { diff --git a/src/Symfony/Component/Console/LICENSE b/src/Symfony/Component/Console/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Console/LICENSE +++ b/src/Symfony/Component/Console/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/Component/Console/Question/ChoiceQuestion.php b/src/Symfony/Component/Console/Question/ChoiceQuestion.php index 39c4a852d0833..522a81bb146d5 100644 --- a/src/Symfony/Component/Console/Question/ChoiceQuestion.php +++ b/src/Symfony/Component/Console/Question/ChoiceQuestion.php @@ -58,7 +58,7 @@ public function getChoices() * * @param bool $multiselect * - * @return ChoiceQuestion The current instance + * @return $this */ public function setMultiselect($multiselect) { @@ -93,7 +93,7 @@ public function getPrompt() * * @param string $prompt * - * @return ChoiceQuestion The current instance + * @return $this */ public function setPrompt($prompt) { @@ -109,7 +109,7 @@ public function setPrompt($prompt) * * @param string $errorMessage * - * @return ChoiceQuestion The current instance + * @return $this */ public function setErrorMessage($errorMessage) { diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index 7a69279f4d485..6425cc5416b6b 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -77,7 +77,7 @@ public function isHidden() * * @param bool $hidden * - * @return Question The current instance + * @return $this * * @throws LogicException In case the autocompleter is also used */ @@ -107,7 +107,7 @@ public function isHiddenFallback() * * @param bool $fallback * - * @return Question The current instance + * @return $this */ public function setHiddenFallback($fallback) { @@ -131,7 +131,7 @@ public function getAutocompleterValues() * * @param null|array|\Traversable $values * - * @return Question The current instance + * @return $this * * @throws InvalidArgumentException * @throws LogicException @@ -162,7 +162,7 @@ public function setAutocompleterValues($values) * * @param null|callable $validator * - * @return Question The current instance + * @return $this */ public function setValidator(callable $validator = null) { @@ -188,7 +188,7 @@ public function getValidator() * * @param null|int $attempts * - * @return Question The current instance + * @return $this * * @throws InvalidArgumentException In case the number of attempts is invalid. */ @@ -222,7 +222,7 @@ public function getMaxAttempts() * * @param callable $normalizer * - * @return Question The current instance + * @return $this */ public function setNormalizer(callable $normalizer) { diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index a9c57443427b3..9ae6513ceb031 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -79,7 +79,7 @@ public function title($message) { $this->autoPrependBlock(); $this->writeln(array( - sprintf('%s', $message), + sprintf('%s', OutputFormatter::escapeTrailingBackslash($message)), sprintf('%s', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))), )); $this->newLine(); @@ -92,7 +92,7 @@ public function section($message) { $this->autoPrependBlock(); $this->writeln(array( - sprintf('%s', $message), + sprintf('%s', OutputFormatter::escapeTrailingBackslash($message)), sprintf('%s', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))), )); $this->newLine(); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index dbbb5bcdd69f4..aff7a10552320 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -454,7 +454,7 @@ public function testFindAlternativeNamespace() public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces() { - $application = $this->getMock('Symfony\Component\Console\Application', array('getNamespaces')); + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getNamespaces'))->getMock(); $application->expects($this->once()) ->method('getNamespaces') ->will($this->returnValue(array('foo:sublong', 'bar:sub'))); @@ -476,7 +476,7 @@ public function testFindWithDoubleColonInNameThrowsException() public function testSetCatchExceptions() { - $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock(); $application->setAutoExit(false); $application->expects($this->any()) ->method('getTerminalWidth') @@ -514,7 +514,7 @@ public function testAutoExitSetting() public function testRenderException() { - $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock(); $application->setAutoExit(false); $application->expects($this->any()) ->method('getTerminalWidth') @@ -546,7 +546,7 @@ public function testRenderException() $tester->run(array('command' => 'foo3:bar'), array('decorated' => true, 'capture_stderr_separately' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); - $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock(); $application->setAutoExit(false); $application->expects($this->any()) ->method('getTerminalWidth') @@ -559,7 +559,7 @@ public function testRenderException() public function testRenderExceptionWithDoubleWidthCharacters() { - $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock(); $application->setAutoExit(false); $application->expects($this->any()) ->method('getTerminalWidth') @@ -575,7 +575,7 @@ public function testRenderExceptionWithDoubleWidthCharacters() $tester->run(array('command' => 'foo'), array('decorated' => true, 'capture_stderr_separately' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); - $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock(); $application->setAutoExit(false); $application->expects($this->any()) ->method('getTerminalWidth') @@ -709,7 +709,7 @@ public function testRunReturnsIntegerExitCode() { $exception = new \Exception('', 4); - $application = $this->getMock('Symfony\Component\Console\Application', array('doRun')); + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('doRun'))->getMock(); $application->setAutoExit(false); $application->expects($this->once()) ->method('doRun') @@ -724,7 +724,7 @@ public function testRunReturnsExitCodeOneForExceptionCodeZero() { $exception = new \Exception('', 0); - $application = $this->getMock('Symfony\Component\Console\Application', array('doRun')); + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('doRun'))->getMock(); $application->setAutoExit(false); $application->expects($this->once()) ->method('doRun') diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 3bab819f40188..5a91a6a0f0b84 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -54,6 +54,14 @@ public function testSetApplication() $command = new \TestCommand(); $command->setApplication($application); $this->assertEquals($application, $command->getApplication(), '->setApplication() sets the current application'); + $this->assertEquals($application->getHelperSet(), $command->getHelperSet()); + } + + public function testSetApplicationNull() + { + $command = new \TestCommand(); + $command->setApplication(null); + $this->assertNull($command->getHelperSet()); } public function testSetGetDefinition() @@ -156,6 +164,13 @@ public function testGetSetAliases() $this->assertEquals(array('name1'), $command->getAliases(), '->setAliases() sets the aliases'); } + public function testSetAliasesNull() + { + $command = new \TestCommand(); + $this->setExpectedException('InvalidArgumentException'); + $command->setAliases(null); + } + public function testGetSynopsis() { $command = new \TestCommand(); @@ -164,6 +179,15 @@ public function testGetSynopsis() $this->assertEquals('namespace:name [--foo] [--] []', $command->getSynopsis(), '->getSynopsis() returns the synopsis'); } + public function testAddGetUsages() + { + $command = new \TestCommand(); + $command->addUsage('foo1'); + $command->addUsage('foo2'); + $this->assertContains('namespace:name foo1', $command->getUsages()); + $this->assertContains('namespace:name foo2', $command->getUsages()); + } + public function testGetHelper() { $application = new Application(); @@ -273,10 +297,10 @@ public function testRunReturnsIntegerExitCode() $exitCode = $command->run(new StringInput(''), new NullOutput()); $this->assertSame(0, $exitCode, '->run() returns integer exit code (treats null as 0)'); - $command = $this->getMock('TestCommand', array('execute')); + $command = $this->getMockBuilder('TestCommand')->setMethods(array('execute'))->getMock(); $command->expects($this->once()) - ->method('execute') - ->will($this->returnValue('2.3')); + ->method('execute') + ->will($this->returnValue('2.3')); $exitCode = $command->run(new StringInput(''), new NullOutput()); $this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)'); } @@ -297,6 +321,20 @@ public function testRunReturnsAlwaysInteger() $this->assertSame(0, $command->run(new StringInput(''), new NullOutput())); } + public function testRunWithProcessTitle() + { + $command = new \TestCommand(); + $command->setApplication(new Application()); + $command->setProcessTitle('foo'); + $this->assertSame(0, $command->run(new StringInput(''), new NullOutput())); + if (function_exists('cli_set_process_title')) { + if (null === @cli_get_process_title() && 'Darwin' === PHP_OS) { + $this->markTestSkipped('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.'); + } + $this->assertEquals('foo', cli_get_process_title()); + } + } + public function testSetCode() { $command = new \TestCommand(); @@ -334,6 +372,29 @@ public function testSetCodeBindToClosure($previouslyBound, $expected) $this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay()); } + public function testSetCodeWithStaticClosure() + { + $command = new \TestCommand(); + $command->setCode(self::createClosure()); + $tester = new CommandTester($command); + $tester->execute(array()); + + if (PHP_VERSION_ID < 70000) { + // Cannot bind static closures in PHP 5 + $this->assertEquals('interact called'.PHP_EOL.'not bound'.PHP_EOL, $tester->getDisplay()); + } else { + // Can bind static closures in PHP 7 + $this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay()); + } + } + + private static function createClosure() + { + return function (InputInterface $input, OutputInterface $output) { + $output->writeln(isset($this) ? 'bound' : 'not bound'); + }; + } + public function testSetCodeWithNonClosureCallable() { $command = new \TestCommand(); diff --git a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php index c36c4a8e5e8b9..74e95b7569977 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php @@ -86,7 +86,7 @@ abstract protected function getDescriptor(); abstract protected function getFormat(); - private function getDescriptionTestData(array $objects) + protected function getDescriptionTestData(array $objects) { $data = array(); foreach ($objects as $name => $object) { diff --git a/src/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php index c85e8a594beae..eb80f58b1cc58 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php @@ -12,9 +12,27 @@ namespace Symfony\Component\Console\Tests\Descriptor; use Symfony\Component\Console\Descriptor\MarkdownDescriptor; +use Symfony\Component\Console\Tests\Fixtures\DescriptorApplicationMbString; +use Symfony\Component\Console\Tests\Fixtures\DescriptorCommandMbString; class MarkdownDescriptorTest extends AbstractDescriptorTest { + public function getDescribeCommandTestData() + { + return $this->getDescriptionTestData(array_merge( + ObjectsProvider::getCommands(), + array('command_mbstring' => new DescriptorCommandMbString()) + )); + } + + public function getDescribeApplicationTestData() + { + return $this->getDescriptionTestData(array_merge( + ObjectsProvider::getApplications(), + array('application_mbstring' => new DescriptorApplicationMbString()) + )); + } + protected function getDescriptor() { return new MarkdownDescriptor(); diff --git a/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php b/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php index 45b3b2fff9034..8f825ecb68395 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php @@ -31,6 +31,7 @@ public static function getInputArguments() 'input_argument_2' => new InputArgument('argument_name', InputArgument::IS_ARRAY, 'argument description'), 'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'), 'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"), + 'input_argument_with_style' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'style'), ); } @@ -43,6 +44,8 @@ public static function getInputOptions() 'input_option_4' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'option description', array()), 'input_option_5' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, "multiline\noption description"), 'input_option_6' => new InputOption('option_name', array('o', 'O'), InputOption::VALUE_REQUIRED, 'option with multiple shortcuts'), + 'input_option_with_style' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description', 'style'), + 'input_option_with_style_array' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'option description', array('Hello', 'world')), ); } diff --git a/src/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php index 350b67950d2b1..364e29c02664b 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php @@ -12,9 +12,27 @@ namespace Symfony\Component\Console\Tests\Descriptor; use Symfony\Component\Console\Descriptor\TextDescriptor; +use Symfony\Component\Console\Tests\Fixtures\DescriptorApplicationMbString; +use Symfony\Component\Console\Tests\Fixtures\DescriptorCommandMbString; class TextDescriptorTest extends AbstractDescriptorTest { + public function getDescribeCommandTestData() + { + return $this->getDescriptionTestData(array_merge( + ObjectsProvider::getCommands(), + array('command_mbstring' => new DescriptorCommandMbString()) + )); + } + + public function getDescribeApplicationTestData() + { + return $this->getDescriptionTestData(array_merge( + ObjectsProvider::getApplications(), + array('application_mbstring' => new DescriptorApplicationMbString()) + )); + } + protected function getDescriptor() { return new TextDescriptor(); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplicationMbString.php b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplicationMbString.php new file mode 100644 index 0000000000000..bf170c449f51e --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplicationMbString.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Fixtures; + +use Symfony\Component\Console\Application; + +class DescriptorApplicationMbString extends Application +{ + public function __construct() + { + parent::__construct('MbString åpplicätion'); + + $this->add(new DescriptorCommandMbString()); + } +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommandMbString.php b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommandMbString.php new file mode 100644 index 0000000000000..66de917e29f58 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommandMbString.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Fixtures; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; + +class DescriptorCommandMbString extends Command +{ + protected function configure() + { + $this + ->setName('descriptor:åèä') + ->setDescription('command åèä description') + ->setHelp('command åèä help') + ->addUsage('-o|--option_name ') + ->addUsage('') + ->addArgument('argument_åèä', InputArgument::REQUIRED) + ->addOption('option_åèä', 'o', InputOption::VALUE_NONE) + ; + } +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php new file mode 100644 index 0000000000000..e6a13558d046c --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php @@ -0,0 +1,13 @@ +title('Title ending with \\'); + $output->section('Section ending with \\'); +}; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_17.txt b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_17.txt new file mode 100644 index 0000000000000..59d00e04a248d --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_17.txt @@ -0,0 +1,7 @@ + +Title ending with \ +=================== + +Section ending with \ +--------------------- + diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md b/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md new file mode 100644 index 0000000000000..22a256fae6834 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md @@ -0,0 +1,289 @@ +MbString åpplicätion +==================== + +* help +* list + +**descriptor:** + +* descriptor:åèä + +help +---- + +* Description: Displays help for a command +* Usage: + + * `help [--format FORMAT] [--raw] [--] []` + +The help command displays help for a given command: + + php app/console help list + +You can also output the help in other formats by using the --format option: + + php app/console help --format=xml list + +To display the list of available commands, please use the list command. + +### Arguments: + +**command_name:** + +* Name: command_name +* Is required: no +* Is array: no +* Description: The command name +* Default: `'help'` + +### Options: + +**format:** + +* Name: `--format` +* Shortcut: +* Accept value: yes +* Is value required: yes +* Is multiple: no +* Description: The output format (txt, xml, json, or md) +* Default: `'txt'` + +**raw:** + +* Name: `--raw` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output raw command help +* Default: `false` + +**help:** + +* Name: `--help` +* Shortcut: `-h` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this help message +* Default: `false` + +**quiet:** + +* Name: `--quiet` +* Shortcut: `-q` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not output any message +* Default: `false` + +**verbose:** + +* Name: `--verbose` +* Shortcut: `-v|-vv|-vvv` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug +* Default: `false` + +**version:** + +* Name: `--version` +* Shortcut: `-V` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this application version +* Default: `false` + +**ansi:** + +* Name: `--ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Force ANSI output +* Default: `false` + +**no-ansi:** + +* Name: `--no-ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Disable ANSI output +* Default: `false` + +**no-interaction:** + +* Name: `--no-interaction` +* Shortcut: `-n` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not ask any interactive question +* Default: `false` + +list +---- + +* Description: Lists commands +* Usage: + + * `list [--raw] [--format FORMAT] [--] []` + +The list command lists all commands: + + php app/console list + +You can also display the commands for a specific namespace: + + php app/console list test + +You can also output the information in other formats by using the --format option: + + php app/console list --format=xml + +It's also possible to get raw list of commands (useful for embedding command runner): + + php app/console list --raw + +### Arguments: + +**namespace:** + +* Name: namespace +* Is required: no +* Is array: no +* Description: The namespace name +* Default: `NULL` + +### Options: + +**raw:** + +* Name: `--raw` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output raw command list +* Default: `false` + +**format:** + +* Name: `--format` +* Shortcut: +* Accept value: yes +* Is value required: yes +* Is multiple: no +* Description: The output format (txt, xml, json, or md) +* Default: `'txt'` + +descriptor:åèä +-------------- + +* Description: command åèä description +* Usage: + + * `descriptor:åèä [-o|--option_åèä] [--] ` + * `descriptor:åèä -o|--option_name ` + * `descriptor:åèä ` + +command åèä help + +### Arguments: + +**argument_åèä:** + +* Name: argument_åèä +* Is required: yes +* Is array: no +* Description: +* Default: `NULL` + +### Options: + +**option_åèä:** + +* Name: `--option_åèä` +* Shortcut: `-o` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: +* Default: `false` + +**help:** + +* Name: `--help` +* Shortcut: `-h` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this help message +* Default: `false` + +**quiet:** + +* Name: `--quiet` +* Shortcut: `-q` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not output any message +* Default: `false` + +**verbose:** + +* Name: `--verbose` +* Shortcut: `-v|-vv|-vvv` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug +* Default: `false` + +**version:** + +* Name: `--version` +* Shortcut: `-V` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this application version +* Default: `false` + +**ansi:** + +* Name: `--ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Force ANSI output +* Default: `false` + +**no-ansi:** + +* Name: `--no-ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Disable ANSI output +* Default: `false` + +**no-interaction:** + +* Name: `--no-interaction` +* Shortcut: `-n` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not ask any interactive question +* Default: `false` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.txt new file mode 100644 index 0000000000000..9d21f829d505e --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.txt @@ -0,0 +1,19 @@ +MbString åpplicätion + +Usage: + command [options] [arguments] + +Options: + -h, --help Display this help message + -q, --quiet Do not output any message + -V, --version Display this application version + --ansi Force ANSI output + --no-ansi Disable ANSI output + -n, --no-interaction Do not ask any interactive question + -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + +Available commands: + help Displays help for a command + list Lists commands + descriptor + descriptor:åèä command åèä description diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.md b/src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.md new file mode 100644 index 0000000000000..2adac53f05fb8 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.md @@ -0,0 +1,33 @@ +descriptor:åèä +-------------- + +* Description: command åèä description +* Usage: + + * `descriptor:åèä [-o|--option_åèä] [--] ` + * `descriptor:åèä -o|--option_name ` + * `descriptor:åèä ` + +command åèä help + +### Arguments: + +**argument_åèä:** + +* Name: argument_åèä +* Is required: yes +* Is array: no +* Description: +* Default: `NULL` + +### Options: + +**option_åèä:** + +* Name: `--option_åèä` +* Shortcut: `-o` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: +* Default: `false` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.txt b/src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.txt new file mode 100644 index 0000000000000..969a0652420b2 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.txt @@ -0,0 +1,13 @@ +Usage: + descriptor:åèä [options] [--] + descriptor:åèä -o|--option_name + descriptor:åèä + +Arguments: + argument_åèä + +Options: + -o, --option_åèä + +Help: + command åèä help diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.json b/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.json new file mode 100644 index 0000000000000..9334235109451 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.json @@ -0,0 +1,7 @@ +{ + "name": "argument_name", + "is_required": false, + "is_array": false, + "description": "argument description", + "default": "style" +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.md b/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.md new file mode 100644 index 0000000000000..45adf2f488bd9 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.md @@ -0,0 +1,7 @@ +**argument_name:** + +* Name: argument_name +* Is required: no +* Is array: no +* Description: argument description +* Default: `'style'` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.txt b/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.txt new file mode 100644 index 0000000000000..35384a6be87e7 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.txt @@ -0,0 +1 @@ + argument_name argument description [default: "\style\"] diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.xml b/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.xml new file mode 100644 index 0000000000000..73332c796e8e4 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.xml @@ -0,0 +1,7 @@ + + + argument description + + <comment>style</> + + diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.json b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.json new file mode 100644 index 0000000000000..df328bf824e70 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.json @@ -0,0 +1,9 @@ +{ + "name": "--option_name", + "shortcut": "-o", + "accept_value": true, + "is_value_required": true, + "is_multiple": false, + "description": "option description", + "default": "style" +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.md b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.md new file mode 100644 index 0000000000000..3f6dd2369a7c2 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.md @@ -0,0 +1,9 @@ +**option_name:** + +* Name: `--option_name` +* Shortcut: `-o` +* Accept value: yes +* Is value required: yes +* Is multiple: no +* Description: option description +* Default: `'style'` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.txt b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.txt new file mode 100644 index 0000000000000..880a53518e214 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.txt @@ -0,0 +1 @@ + -o, --option_name=OPTION_NAME option description [default: "\style\"] diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.xml b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.xml new file mode 100644 index 0000000000000..764b9e6521596 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.xml @@ -0,0 +1,7 @@ + + diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.json b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.json new file mode 100644 index 0000000000000..b1754550b52de --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.json @@ -0,0 +1,12 @@ +{ + "name": "--option_name", + "shortcut": "-o", + "accept_value": true, + "is_value_required": true, + "is_multiple": true, + "description": "option description", + "default": [ + "Hello", + "world" + ] +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.md b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.md new file mode 100644 index 0000000000000..24e58b530258d --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.md @@ -0,0 +1,9 @@ +**option_name:** + +* Name: `--option_name` +* Shortcut: `-o` +* Accept value: yes +* Is value required: yes +* Is multiple: yes +* Description: option description +* Default: `array ( 0 => 'Hello', 1 => 'world',)` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.txt b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.txt new file mode 100644 index 0000000000000..265c18c5a45d2 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.txt @@ -0,0 +1 @@ + -o, --option_name=OPTION_NAME option description [default: ["\Hello\","\world\"]] (multiple values allowed) diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.xml b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.xml new file mode 100644 index 0000000000000..09dc865830e93 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.xml @@ -0,0 +1,8 @@ + + diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php index 998249dbc18af..7c7f71971d06d 100644 --- a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php @@ -110,7 +110,7 @@ public function testIteration() private function getGenericMockHelper($name, HelperSet $helperset = null) { - $mock_helper = $this->getMock('\Symfony\Component\Console\Helper\HelperInterface'); + $mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock(); $mock_helper->expects($this->any()) ->method('getName') ->will($this->returnValue($name)); diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index a35ddbc90a9a9..14ebe134f6af0 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -294,7 +294,7 @@ public function testRegressProgress() public function testRedrawFrequency() { - $bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream(), 6)); + $bar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')->setMethods(array('display'))->setConstructorArgs(array($this->getOutputStream(), 6))->getMock(); $bar->expects($this->exactly(4))->method('display'); $bar->setRedrawFrequency(2); @@ -307,7 +307,7 @@ public function testRedrawFrequency() public function testRedrawFrequencyIsAtLeastOneIfZeroGiven() { - $bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream())); + $bar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')->setMethods(array('display'))->setConstructorArgs(array($this->getOutputStream()))->getMock(); $bar->expects($this->exactly(2))->method('display'); $bar->setRedrawFrequency(0); @@ -317,7 +317,7 @@ public function testRedrawFrequencyIsAtLeastOneIfZeroGiven() public function testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven() { - $bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream())); + $bar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')->setMethods(array('display'))->setConstructorArgs(array($this->getOutputStream()))->getMock(); $bar->expects($this->exactly(2))->method('display'); $bar->setRedrawFrequency(0.9); diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index 86ad446c1b396..044459660a733 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -388,7 +388,7 @@ public function testChoiceOutputFormattingQuestionForUtf8Keys() ' [żółw ] bar', ' [łabądź] baz', ); - $output = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); + $output = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface')->getMock(); $output->method('getFormatter')->willReturn(new OutputFormatter()); $dialog = new QuestionHelper(); @@ -449,7 +449,7 @@ protected function createOutputInterface() protected function createInputInterfaceMock($interactive = true) { - $mock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); + $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); $mock->expects($this->any()) ->method('isInteractive') ->will($this->returnValue($interactive)); diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index f57d65070e076..9bb50d52806a9 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -92,13 +92,22 @@ public function testAskEscapeDefaultValue() $this->assertOutputContains('Can I have a backslash? [\]', $output); } - public function testAskEscapeLabel() + public function testAskEscapeAndFormatLabel() + { + $helper = new SymfonyQuestionHelper(); + $helper->setInputStream($this->getInputStream('Foo\\Bar')); + $helper->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), new Question('Do you want to use Foo\\Bar or Foo\\Baz\\?', 'Foo\\Baz')); + + $this->assertOutputContains('Do you want to use Foo\\Bar or Foo\\Baz\\? [Foo\\Baz]:', $output); + } + + public function testLabelTrailingBackslash() { $helper = new SymfonyQuestionHelper(); $helper->setInputStream($this->getInputStream('sure')); - $helper->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), new Question('Do you want a \?')); + $helper->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), new Question('Question with a trailing \\')); - $this->assertOutputContains('Do you want a \?', $output); + $this->assertOutputContains('Question with a trailing \\', $output); } /** @@ -132,7 +141,7 @@ protected function createOutputInterface() protected function createInputInterfaceMock($interactive = true) { - $mock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); + $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); $mock->expects($this->any()) ->method('isInteractive') ->will($this->returnValue($interactive)); diff --git a/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php b/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php index 1afbbb6e6cffc..b3808c07cfbf8 100644 --- a/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Output; +use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\Output; @@ -22,4 +23,19 @@ public function testConstructor() $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); $this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument'); } + + public function testSetFormatter() + { + $output = new ConsoleOutput(); + $outputFormatter = new OutputFormatter(); + $output->setFormatter($outputFormatter); + $this->assertSame($outputFormatter, $output->getFormatter()); + } + + public function testSetVerbosity() + { + $output = new ConsoleOutput(); + $output->setVerbosity(Output::VERBOSITY_VERBOSE); + $this->assertSame(Output::VERBOSITY_VERBOSE, $output->getVerbosity()); + } } diff --git a/src/Symfony/Component/Console/Tests/Output/NullOutputTest.php b/src/Symfony/Component/Console/Tests/Output/NullOutputTest.php index b20ae4e8d07ae..f09573f04da90 100644 --- a/src/Symfony/Component/Console/Tests/Output/NullOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/NullOutputTest.php @@ -11,7 +11,9 @@ namespace Symfony\Component\Console\Tests\Output; +use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Output\Output; use Symfony\Component\Console\Output\OutputInterface; class NullOutputTest extends \PHPUnit_Framework_TestCase @@ -36,4 +38,50 @@ public function testVerbosity() $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); $this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() always returns VERBOSITY_QUIET for NullOutput'); } + + public function testSetFormatter() + { + $output = new NullOutput(); + $outputFormatter = new OutputFormatter(); + $output->setFormatter($outputFormatter); + $this->assertNotSame($outputFormatter, $output->getFormatter()); + } + + public function testSetVerbosity() + { + $output = new NullOutput(); + $output->setVerbosity(Output::VERBOSITY_NORMAL); + $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity()); + } + + public function testSetDecorated() + { + $output = new NullOutput(); + $output->setDecorated(true); + $this->assertFalse($output->isDecorated()); + } + + public function testIsQuiet() + { + $output = new NullOutput(); + $this->assertTrue($output->isQuiet()); + } + + public function testIsVerbose() + { + $output = new NullOutput(); + $this->assertFalse($output->isVerbose()); + } + + public function testIsVeryVerbose() + { + $output = new NullOutput(); + $this->assertFalse($output->isVeryVerbose()); + } + + public function testIsDebug() + { + $output = new NullOutput(); + $this->assertFalse($output->isDebug()); + } } diff --git a/src/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php b/src/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php index 418bc301cbca9..cb3158a5536dc 100644 --- a/src/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php +++ b/src/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php @@ -27,7 +27,7 @@ class SyntaxErrorException extends ParseException * @param string $expectedValue * @param Token $foundToken * - * @return SyntaxErrorException + * @return self */ public static function unexpectedToken($expectedValue, Token $foundToken) { @@ -38,7 +38,7 @@ public static function unexpectedToken($expectedValue, Token $foundToken) * @param string $pseudoElement * @param string $unexpectedLocation * - * @return SyntaxErrorException + * @return self */ public static function pseudoElementFound($pseudoElement, $unexpectedLocation) { @@ -48,7 +48,7 @@ public static function pseudoElementFound($pseudoElement, $unexpectedLocation) /** * @param int $position * - * @return SyntaxErrorException + * @return self */ public static function unclosedString($position) { @@ -56,7 +56,7 @@ public static function unclosedString($position) } /** - * @return SyntaxErrorException + * @return self */ public static function nestedNot() { @@ -64,7 +64,7 @@ public static function nestedNot() } /** - * @return SyntaxErrorException + * @return self */ public static function stringAsFunctionArgument() { diff --git a/src/Symfony/Component/CssSelector/LICENSE b/src/Symfony/Component/CssSelector/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/CssSelector/LICENSE +++ b/src/Symfony/Component/CssSelector/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/Component/CssSelector/Node/Specificity.php b/src/Symfony/Component/CssSelector/Node/Specificity.php index a24b4fdf8403b..d09eaca77ef45 100644 --- a/src/Symfony/Component/CssSelector/Node/Specificity.php +++ b/src/Symfony/Component/CssSelector/Node/Specificity.php @@ -61,7 +61,7 @@ public function __construct($a, $b, $c) /** * @param Specificity $specificity * - * @return Specificity + * @return self */ public function plus(Specificity $specificity) { diff --git a/src/Symfony/Component/CssSelector/Parser/TokenStream.php b/src/Symfony/Component/CssSelector/Parser/TokenStream.php index b1f912f9d71ba..aeba0f86c06ee 100644 --- a/src/Symfony/Component/CssSelector/Parser/TokenStream.php +++ b/src/Symfony/Component/CssSelector/Parser/TokenStream.php @@ -61,7 +61,7 @@ class TokenStream * * @param Token $token * - * @return TokenStream + * @return $this */ public function push(Token $token) { @@ -73,7 +73,7 @@ public function push(Token $token) /** * Freezes stream. * - * @return TokenStream + * @return $this */ public function freeze() { diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php index 9d7f8fa3f08dd..09e6469e7d4dc 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php @@ -50,7 +50,7 @@ public function __construct($flags = 0) * @param int $flag * @param bool $on * - * @return NodeExtension + * @return $this */ public function setFlag($flag, $on) { diff --git a/src/Symfony/Component/CssSelector/XPath/Translator.php b/src/Symfony/Component/CssSelector/XPath/Translator.php index 2cc2b110c93c3..2b01fc8e52526 100644 --- a/src/Symfony/Component/CssSelector/XPath/Translator.php +++ b/src/Symfony/Component/CssSelector/XPath/Translator.php @@ -146,7 +146,7 @@ public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or * * @param Extension\ExtensionInterface $extension * - * @return Translator + * @return $this */ public function registerExtension(Extension\ExtensionInterface $extension) { @@ -182,7 +182,7 @@ public function getExtension($name) * * @param ParserInterface $shortcut * - * @return Translator + * @return $this */ public function registerParserShortcut(ParserInterface $shortcut) { diff --git a/src/Symfony/Component/CssSelector/XPath/XPathExpr.php b/src/Symfony/Component/CssSelector/XPath/XPathExpr.php index 420ef3d85c0b0..38ca295540071 100644 --- a/src/Symfony/Component/CssSelector/XPath/XPathExpr.php +++ b/src/Symfony/Component/CssSelector/XPath/XPathExpr.php @@ -66,7 +66,7 @@ public function getElement() /** * @param $condition * - * @return XPathExpr + * @return $this */ public function addCondition($condition) { @@ -84,7 +84,7 @@ public function getCondition() } /** - * @return XPathExpr + * @return $this */ public function addNameTest() { @@ -97,7 +97,7 @@ public function addNameTest() } /** - * @return XPathExpr + * @return $this */ public function addStarPrefix() { @@ -112,7 +112,7 @@ public function addStarPrefix() * @param string $combiner * @param XPathExpr $expr * - * @return XPathExpr + * @return $this */ public function join($combiner, XPathExpr $expr) { diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 31a54d162510e..a53e9fe5bb217 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -529,7 +529,11 @@ public function handleException($exception, array $error = null) } } if ($this->loggedErrors & $type) { - $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e); + try { + $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e); + } catch (\Exception $handlerException) { + } catch (\Throwable $handlerException) { + } } if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) { foreach ($this->getFatalErrorHandlers() as $handler) { diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 0e80f2aabefb0..857d6623b10a7 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -49,7 +49,7 @@ public function __construct($debug = true, $charset = null, $fileLinkFormat = nu * @param string|null $charset The charset used by exception messages * @param string|null $fileLinkFormat The IDE link template * - * @return ExceptionHandler The registered exception handler + * @return static */ public static function register($debug = true, $charset = null, $fileLinkFormat = null) { diff --git a/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php b/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php index f734d6bb7dd9e..6fa62b6f24fbb 100644 --- a/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php +++ b/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php @@ -36,8 +36,13 @@ public function handleError(array $error, FatalErrorException $exception) $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className); + if (!class_exists($className) || null === $methods = get_class_methods($className)) { + // failed to get the class or its methods on which an unknown method was called (for example on an anonymous class) + return new UndefinedMethodException($message, $exception); + } + $candidates = array(); - foreach (get_class_methods($className) as $definedMethodName) { + foreach ($methods as $definedMethodName) { $lev = levenshtein($methodName, $definedMethodName); if ($lev <= strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) { $candidates[] = $definedMethodName; @@ -52,6 +57,7 @@ public function handleError(array $error, FatalErrorException $exception) } else { $candidates = '"'.$last; } + $message .= "\nDid you mean to call ".$candidates; } diff --git a/src/Symfony/Component/Debug/LICENSE b/src/Symfony/Component/Debug/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Debug/LICENSE +++ b/src/Symfony/Component/Debug/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/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 163ef530e35d5..895d0356d64b1 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -124,7 +124,7 @@ public function testDefaultLogger() try { $handler = ErrorHandler::register(); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $handler->setDefaultLogger($logger, E_NOTICE); $handler->setDefaultLogger($logger, array(E_USER_NOTICE => LogLevel::CRITICAL)); @@ -198,7 +198,7 @@ public function testHandleError() restore_error_handler(); restore_exception_handler(); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $warnArgCheck = function ($logLevel, $message, $context) { $this->assertEquals('info', $logLevel); @@ -222,7 +222,7 @@ public function testHandleError() restore_error_handler(); restore_exception_handler(); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logArgCheck = function ($level, $message, $context) { $this->assertEquals('Undefined variable: undefVar', $message); @@ -283,7 +283,7 @@ public function testHandleDeprecation() $this->assertArrayHasKey('stack', $context); }; - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger ->expects($this->once()) ->method('log') @@ -302,7 +302,7 @@ public function testHandleException() $exception = new \Exception('foo'); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logArgCheck = function ($level, $message, $context) { $this->assertEquals('Uncaught Exception: foo', $message); @@ -342,7 +342,7 @@ public function testErrorStacking() $handler = ErrorHandler::register(); $handler->screamAt(E_USER_WARNING); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger ->expects($this->exactly(2)) @@ -400,7 +400,7 @@ public function testBootstrappingLogger() $bootLogger->log($expectedLog[0], $expectedLog[1], $expectedLog[2]); - $mockLogger = $this->getMock('Psr\Log\LoggerInterface'); + $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $mockLogger->expects($this->once()) ->method('log') ->with(LogLevel::WARNING, 'Foo message', $expectedLog[2]); @@ -420,7 +420,7 @@ public function testHandleFatalError() 'line' => 123, ); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logArgCheck = function ($level, $message, $context) { $this->assertEquals('Fatal Parse Error: foo', $message); @@ -471,7 +471,7 @@ public function testHandleFatalErrorOnHHVM() try { $handler = ErrorHandler::register(); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger ->expects($this->once()) ->method('log') diff --git a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php index 1703da6ebbfbf..6e4105721cded 100644 --- a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php @@ -100,7 +100,7 @@ public function testHandle() { $exception = new \Exception('foo'); - $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse')); + $handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(array('sendPhpResponse'))->getMock(); $handler ->expects($this->exactly(2)) ->method('sendPhpResponse'); @@ -118,7 +118,7 @@ public function testHandleOutOfMemoryException() { $exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__); - $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse')); + $handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(array('sendPhpResponse'))->getMock(); $handler ->expects($this->once()) ->method('sendPhpResponse'); diff --git a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php index de7b21c69978b..22cbc3033bd6c 100644 --- a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php @@ -61,6 +61,15 @@ public function provideUndefinedMethodData() ), "Attempted to call an undefined method named \"offsetFet\" of class \"SplObjectStorage\".\nDid you mean to call e.g. \"offsetGet\", \"offsetSet\" or \"offsetUnset\"?", ), + array( + array( + 'type' => 1, + 'message' => 'Call to undefined method class@anonymous::test()', + 'file' => '/home/possum/work/symfony/test.php', + 'line' => 11, + ), + 'Attempted to call an undefined method named "test" of class "class@anonymous".', + ), ); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php b/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php index dc9a1a00eadc8..e7306ab560e22 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php @@ -45,7 +45,7 @@ public function hasNode($id) * * @param string $id The id to retrieve * - * @return ServiceReferenceGraphNode The node matching the supplied identifier + * @return ServiceReferenceGraphNode * * @throws InvalidArgumentException if no node matches the supplied identifier */ @@ -61,7 +61,7 @@ public function getNode($id) /** * Returns all nodes. * - * @return ServiceReferenceGraphNode[] An array of all ServiceReferenceGraphNode objects + * @return ServiceReferenceGraphNode[] */ public function getNodes() { diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 61ce551a2a473..fbad201521e85 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -195,7 +195,7 @@ public function getResources() * * @param ResourceInterface $resource A resource instance * - * @return ContainerBuilder The current instance + * @return $this */ public function addResource(ResourceInterface $resource) { @@ -213,7 +213,7 @@ public function addResource(ResourceInterface $resource) * * @param ResourceInterface[] $resources An array of resources * - * @return ContainerBuilder The current instance + * @return $this */ public function setResources(array $resources) { @@ -231,7 +231,7 @@ public function setResources(array $resources) * * @param object $object An object instance * - * @return ContainerBuilder The current instance + * @return $this */ public function addObjectResource($object) { @@ -247,7 +247,7 @@ public function addObjectResource($object) * * @param \ReflectionClass $class * - * @return ContainerBuilder The current instance + * @return $this */ public function addClassResource(\ReflectionClass $class) { @@ -270,7 +270,7 @@ public function addClassResource(\ReflectionClass $class) * @param string $extension The extension alias or namespace * @param array $values An array of values that customizes the extension * - * @return ContainerBuilder The current instance + * @return $this * * @throws BadMethodCallException When this ContainerBuilder is frozen * @throws \LogicException if the container is frozen @@ -294,7 +294,7 @@ public function loadFromExtension($extension, array $values = array()) * @param CompilerPassInterface $pass A compiler pass * @param string $type The type of compiler pass * - * @return ContainerBuilder The current instance + * @return $this */ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) { @@ -399,7 +399,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV } if (!isset($this->definitions[$id]) && isset($this->aliasDefinitions[$id])) { - return $this->get($this->aliasDefinitions[$id], $invalidBehavior); + return $this->get((string) $this->aliasDefinitions[$id], $invalidBehavior); } try { @@ -1036,14 +1036,14 @@ private function callMethod($service, $call) /** * Shares a given service in the container. * - * @param Definition $definition - * @param mixed $service - * @param string $id + * @param Definition $definition + * @param mixed $service + * @param string|null $id */ private function shareService(Definition $definition, $service, $id) { - if ($definition->isShared()) { - $this->services[$lowerId = strtolower($id)] = $service; + if (null !== $id && $definition->isShared()) { + $this->services[strtolower($id)] = $service; } } diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index c80265d73f3cd..9ff720648ccf5 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -56,7 +56,7 @@ public function __construct($class = null, array $arguments = array()) * * @param string|array $factory A PHP function or an array containing a class/Reference and a method to call * - * @return Definition The current instance + * @return $this */ public function setFactory($factory) { @@ -86,7 +86,7 @@ public function getFactory() * @param null|string $renamedId The new decorated service id * @param int $priority The priority of decoration * - * @return Definition The current instance + * @return $this * * @throws InvalidArgumentException In case the decorated service id and the new decorated service id are equals. */ @@ -120,7 +120,7 @@ public function getDecoratedService() * * @param string $class The service class * - * @return Definition The current instance + * @return $this */ public function setClass($class) { @@ -144,7 +144,7 @@ public function getClass() * * @param array $arguments An array of arguments * - * @return Definition The current instance + * @return $this */ public function setArguments(array $arguments) { @@ -177,7 +177,7 @@ public function setProperty($name, $value) * * @param mixed $argument An argument * - * @return Definition The current instance + * @return $this */ public function addArgument($argument) { @@ -192,7 +192,7 @@ public function addArgument($argument) * @param int $index * @param mixed $argument * - * @return Definition The current instance + * @return $this * * @throws OutOfBoundsException When the replaced argument does not exist */ @@ -240,7 +240,7 @@ public function getArgument($index) * * @param array $calls An array of method calls * - * @return Definition The current instance + * @return $this */ public function setMethodCalls(array $calls = array()) { @@ -258,7 +258,7 @@ public function setMethodCalls(array $calls = array()) * @param string $method The method name to call * @param array $arguments An array of arguments to pass to the method call * - * @return Definition The current instance + * @return $this * * @throws InvalidArgumentException on empty $method param */ @@ -277,7 +277,7 @@ public function addMethodCall($method, array $arguments = array()) * * @param string $method The method name to remove * - * @return Definition The current instance + * @return $this */ public function removeMethodCall($method) { @@ -324,7 +324,7 @@ public function getMethodCalls() * * @param array $tags * - * @return Definition the current instance + * @return $this */ public function setTags(array $tags) { @@ -361,7 +361,7 @@ public function getTag($name) * @param string $name The tag name * @param array $attributes An array of attributes * - * @return Definition The current instance + * @return $this */ public function addTag($name, array $attributes = array()) { @@ -387,7 +387,7 @@ public function hasTag($name) * * @param string $name The tag name * - * @return Definition + * @return $this */ public function clearTag($name) { @@ -399,7 +399,7 @@ public function clearTag($name) /** * Clears the tags for this definition. * - * @return Definition The current instance + * @return $this */ public function clearTags() { @@ -413,7 +413,7 @@ public function clearTags() * * @param string $file A full pathname to include * - * @return Definition The current instance + * @return $this */ public function setFile($file) { @@ -437,7 +437,7 @@ public function getFile() * * @param bool $shared Whether the service must be shared or not * - * @return Definition The current instance + * @return $this */ public function setShared($shared) { @@ -461,7 +461,7 @@ public function isShared() * * @param bool $boolean * - * @return Definition The current instance + * @return $this */ public function setPublic($boolean) { @@ -485,7 +485,7 @@ public function isPublic() * * @param bool $lazy * - * @return Definition The current instance + * @return $this */ public function setLazy($lazy) { @@ -510,7 +510,7 @@ public function isLazy() * * @param bool $boolean * - * @return Definition the current instance + * @return $this */ public function setSynthetic($boolean) { @@ -536,7 +536,7 @@ public function isSynthetic() * * @param bool $boolean * - * @return Definition the current instance + * @return $this */ public function setAbstract($boolean) { @@ -563,7 +563,7 @@ public function isAbstract() * @param bool $status * @param string $template Template message to use if the definition is deprecated * - * @return Definition the current instance + * @return $this * * @throws InvalidArgumentException When the message template is invalid. */ @@ -614,7 +614,7 @@ public function getDeprecationMessage($id) * * @param callable $callable A PHP callable * - * @return Definition The current instance + * @return $this */ public function setConfigurator($callable) { @@ -638,7 +638,7 @@ public function getConfigurator() * * @param string[] $types * - * @return Definition The current instance + * @return $this */ public function setAutowiringTypes(array $types) { @@ -666,7 +666,7 @@ public function isAutowired() * * @param bool $autowired * - * @return Definition The current instance + * @return $this */ public function setAutowired($autowired) { @@ -690,7 +690,7 @@ public function getAutowiringTypes() * * @param string $type * - * @return Definition The current instance + * @return $this */ public function addAutowiringType($type) { @@ -704,7 +704,7 @@ public function addAutowiringType($type) * * @param string $type * - * @return Definition The current instance + * @return $this */ public function removeAutowiringType($type) { diff --git a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php index f17657a3a1b07..1243695dba930 100644 --- a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php @@ -182,7 +182,7 @@ public function getArgument($index) * @param int $index * @param mixed $value * - * @return DefinitionDecorator the current instance + * @return $this * * @throws InvalidArgumentException when $index isn't an integer */ diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index 1a3efdd3953d2..73bc7136f74b7 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -168,7 +168,7 @@ private function addServiceAlias($alias, $id) return sprintf(" %s: '@%s'\n", $alias, $id); } - return sprintf(" %s:\n alias: %s\n public: false", $alias, $id); + return sprintf(" %s:\n alias: %s\n public: false\n", $alias, $id); } /** diff --git a/src/Symfony/Component/DependencyInjection/LICENSE b/src/Symfony/Component/DependencyInjection/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/DependencyInjection/LICENSE +++ b/src/Symfony/Component/DependencyInjection/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/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd index 182e09e8572ce..674cc08e2a7d8 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd +++ b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd @@ -148,7 +148,7 @@ - + @@ -161,7 +161,7 @@ - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index a8b1be355017a..16c8130cd5cad 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -213,13 +213,13 @@ public function testCreateDefinition() $this->assertCount(1, $container->getDefinition('coop_tilleuls')->getArguments()); $this->assertEquals('autowired.symfony\component\dependencyinjection\tests\compiler\dunglas', $container->getDefinition('coop_tilleuls')->getArgument(0)); - $dunglasDefinition = $container->getDefinition('autowired.symfony\component\dependencyinjection\tests\compiler\dunglas'); + $dunglasDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas'); $this->assertEquals(__NAMESPACE__.'\Dunglas', $dunglasDefinition->getClass()); $this->assertFalse($dunglasDefinition->isPublic()); $this->assertCount(1, $dunglasDefinition->getArguments()); $this->assertEquals('autowired.symfony\component\dependencyinjection\tests\compiler\lille', $dunglasDefinition->getArgument(0)); - $lilleDefinition = $container->getDefinition('autowired.symfony\component\dependencyinjection\tests\compiler\lille'); + $lilleDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Lille'); $this->assertEquals(__NAMESPACE__.'\Lille', $lilleDefinition->getClass()); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php index b786db95f6fe2..33060dcd0e29c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php @@ -23,7 +23,7 @@ class ExtensionCompilerPassTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + $this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock(); $this->pass = new ExtensionCompilerPass(); } @@ -46,10 +46,10 @@ public function testProcess() private function createExtensionMock($hasInlineCompile) { - return $this->getMock('Symfony\Component\DependencyInjection\\'.( + return $this->getMockBuilder('Symfony\Component\DependencyInjection\\'.( $hasInlineCompile ? 'Compiler\CompilerPassInterface' : 'Extension\ExtensionInterface' - )); + ))->getMock(); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php index aed8cdfe1a293..8d957d47b5b7e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php @@ -21,7 +21,7 @@ public function testExpressionLanguageProviderForwarding() { $tmpProviders = array(); - $extension = $this->getMock('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface'); + $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); $extension->expects($this->any()) ->method('getXsdValidationBasePath') ->will($this->returnValue(false)); @@ -37,7 +37,7 @@ public function testExpressionLanguageProviderForwarding() $tmpProviders = $container->getExpressionLanguageProviders(); })); - $provider = $this->getMock('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface'); + $provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock(); $container = new ContainerBuilder(new ParameterBag()); $container->registerExtension($extension); $container->prependExtensionConfig('foo', array('bar' => true)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index a533afde293a7..8f374f1c19fa5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -254,7 +254,7 @@ public function testAddGetCompilerPass() $builder = new ContainerBuilder(); $builder->setResourceTracking(false); $builderCompilerPasses = $builder->getCompiler()->getPassConfig()->getPasses(); - $builder->addCompilerPass($this->getMock('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface')); + $builder->addCompilerPass($this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface')->getMock()); $this->assertCount(count($builder->getCompiler()->getPassConfig()->getPasses()) - 1, $builderCompilerPasses); } @@ -608,7 +608,7 @@ public function testExtension() public function testRegisteredButNotLoadedExtension() { - $extension = $this->getMock('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface'); + $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); $extension->expects($this->once())->method('getAlias')->will($this->returnValue('project')); $extension->expects($this->never())->method('load'); @@ -620,7 +620,7 @@ public function testRegisteredButNotLoadedExtension() public function testRegisteredAndLoadedExtension() { - $extension = $this->getMock('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface'); + $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); $extension->expects($this->exactly(2))->method('getAlias')->will($this->returnValue('project')); $extension->expects($this->once())->method('load')->with(array(array('foo' => 'bar'))); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index 0fbeb36293d0a..6edd33bcc0e26 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -132,7 +132,7 @@ public function testSet() { $sc = new Container(); $sc->set('foo', $foo = new \stdClass()); - $this->assertEquals($foo, $sc->get('foo'), '->set() sets a service'); + $this->assertSame($foo, $sc->get('foo'), '->set() sets a service'); } public function testSetWithNullResetTheService() @@ -154,15 +154,15 @@ public function testGet() { $sc = new ProjectServiceContainer(); $sc->set('foo', $foo = new \stdClass()); - $this->assertEquals($foo, $sc->get('foo'), '->get() returns the service for the given id'); - $this->assertEquals($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase'); - $this->assertEquals($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id'); - $this->assertEquals($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined'); - $this->assertEquals($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined'); - $this->assertEquals($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined'); + $this->assertSame($foo, $sc->get('foo'), '->get() returns the service for the given id'); + $this->assertSame($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase'); + $this->assertSame($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id'); + $this->assertSame($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined'); + $this->assertSame($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined'); + $this->assertSame($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined'); $sc->set('bar', $bar = new \stdClass()); - $this->assertEquals($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()'); + $this->assertSame($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()'); try { $sc->get(''); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 0dbcea1ac30c4..7f428814b764f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -250,7 +250,7 @@ public function testOverrideServiceWhenUsingADumpedContainer() $container->set('bar', $bar = new \stdClass()); $container->setParameter('foo_bar', 'foo_bar'); - $this->assertEquals($bar, $container->get('bar'), '->set() overrides an already defined service'); + $this->assertSame($bar, $container->get('bar'), '->set() overrides an already defined service'); } public function testOverrideServiceWhenUsingADumpedContainerAndServiceIsUsedFromAnotherOne() diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml index dbd7b88f680a9..20ed7e315a996 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml @@ -25,6 +25,8 @@ services: class: Request synthetic: true lazy: true + another_third_alias_for_foo: + alias: foo decorator_service: decorates: decorated decorator_service_with_name: diff --git a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php index 6dcf25d2bee10..a3524c3d7263d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php @@ -25,7 +25,7 @@ public function testInstantiateProxy() { $instantiator = new RealServiceInstantiator(); $instance = new \stdClass(); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $callback = function () use ($instance) { return $instance; }; diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index b5adaac2aa56f..71b05d983eda4 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -337,7 +337,7 @@ public function addNode(\DOMNode $node) * * @param int $position The position * - * @return Crawler A new instance of the Crawler with the selected node, or an empty Crawler if it does not exist + * @return self */ public function eq($position) { @@ -380,7 +380,7 @@ public function each(\Closure $closure) * @param int $offset * @param int $length * - * @return Crawler A Crawler instance with the sliced nodes + * @return self */ public function slice($offset = 0, $length = null) { @@ -394,7 +394,7 @@ public function slice($offset = 0, $length = null) * * @param \Closure $closure An anonymous function * - * @return Crawler A Crawler instance with the selected nodes + * @return self */ public function reduce(\Closure $closure) { @@ -411,7 +411,7 @@ public function reduce(\Closure $closure) /** * Returns the first node of the current selection. * - * @return Crawler A Crawler instance with the first selected node + * @return self */ public function first() { @@ -421,7 +421,7 @@ public function first() /** * Returns the last node of the current selection. * - * @return Crawler A Crawler instance with the last selected node + * @return self */ public function last() { @@ -431,7 +431,7 @@ public function last() /** * Returns the siblings nodes of the current selection. * - * @return Crawler A Crawler instance with the sibling nodes + * @return self * * @throws \InvalidArgumentException When current node is empty */ @@ -447,7 +447,7 @@ public function siblings() /** * Returns the next siblings nodes of the current selection. * - * @return Crawler A Crawler instance with the next sibling nodes + * @return self * * @throws \InvalidArgumentException When current node is empty */ @@ -463,7 +463,7 @@ public function nextAll() /** * Returns the previous sibling nodes of the current selection. * - * @return Crawler A Crawler instance with the previous sibling nodes + * @return self * * @throws \InvalidArgumentException */ @@ -479,7 +479,7 @@ public function previousAll() /** * Returns the parents nodes of the current selection. * - * @return Crawler A Crawler instance with the parents nodes of the current selection + * @return self * * @throws \InvalidArgumentException When current node is empty */ @@ -504,7 +504,7 @@ public function parents() /** * Returns the children nodes of the current selection. * - * @return Crawler A Crawler instance with the children nodes + * @return self * * @throws \InvalidArgumentException When current node is empty */ @@ -637,7 +637,7 @@ public function extract($attributes) * * @param string $xpath An XPath expression * - * @return Crawler A new instance of Crawler with the filtered list of nodes + * @return self */ public function filterXPath($xpath) { @@ -658,7 +658,7 @@ public function filterXPath($xpath) * * @param string $selector A CSS selector * - * @return Crawler A new instance of Crawler with the filtered list of nodes + * @return self * * @throws \RuntimeException if the CssSelector Component is not available */ @@ -679,7 +679,7 @@ public function filter($selector) * * @param string $value The link text * - * @return Crawler A new instance of Crawler with the filtered list of nodes + * @return self */ public function selectLink($value) { @@ -694,7 +694,7 @@ public function selectLink($value) * * @param string $value The image alt * - * @return Crawler A new instance of Crawler with the filtered list of nodes + * @return self A new instance of Crawler with the filtered list of nodes */ public function selectImage($value) { @@ -708,7 +708,7 @@ public function selectImage($value) * * @param string $value The button text * - * @return Crawler A new instance of Crawler with the filtered list of nodes + * @return self */ public function selectButton($value) { @@ -910,7 +910,7 @@ public static function xpathLiteral($s) * * @param string $xpath * - * @return Crawler + * @return self */ private function filterRelativeXPath($xpath) { diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 0390e3fc7831a..bad1b34935d04 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -69,7 +69,7 @@ public function getFormNode() * * @param array $values An array of field values * - * @return Form + * @return $this */ public function setValues(array $values) { @@ -279,7 +279,7 @@ public function set(FormField $field) /** * Gets all fields. * - * @return FormField[] An array of fields + * @return FormField[] */ public function all() { diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php index 7dd3d3e7a3229..9168dd365af98 100644 --- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -151,7 +151,7 @@ public function all() * @param string $base The fully qualified name of the base field * @param array $values The values of the fields * - * @return FormFieldRegistry + * @return static */ private static function create($base, array $values) { diff --git a/src/Symfony/Component/DomCrawler/LICENSE b/src/Symfony/Component/DomCrawler/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/DomCrawler/LICENSE +++ b/src/Symfony/Component/DomCrawler/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/Component/EventDispatcher/GenericEvent.php b/src/Symfony/Component/EventDispatcher/GenericEvent.php index 2b9f40e26ad2b..e8e4cc050266e 100644 --- a/src/Symfony/Component/EventDispatcher/GenericEvent.php +++ b/src/Symfony/Component/EventDispatcher/GenericEvent.php @@ -80,7 +80,7 @@ public function getArgument($key) * @param string $key Argument name * @param mixed $value Value * - * @return GenericEvent + * @return $this */ public function setArgument($key, $value) { @@ -104,7 +104,7 @@ public function getArguments() * * @param array $args Arguments * - * @return GenericEvent + * @return $this */ public function setArguments(array $args = array()) { diff --git a/src/Symfony/Component/EventDispatcher/LICENSE b/src/Symfony/Component/EventDispatcher/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/EventDispatcher/LICENSE +++ b/src/Symfony/Component/EventDispatcher/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/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php index 04b1ec145dc74..2a0da9ca67c3a 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php @@ -29,7 +29,7 @@ public function testAddAListenerService() { $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $service ->expects($this->once()) @@ -50,7 +50,7 @@ public function testAddASubscriberService() { $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\SubscriberService')->getMock(); $service ->expects($this->once()) @@ -85,7 +85,7 @@ public function testPreventDuplicateListenerService() { $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $service ->expects($this->once()) @@ -107,7 +107,7 @@ public function testHasListenersOnLazyLoad() { $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $container = new Container(); $container->set('service.listener', $service); @@ -130,7 +130,7 @@ public function testHasListenersOnLazyLoad() public function testGetListenersOnLazyLoad() { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $container = new Container(); $container->set('service.listener', $service); @@ -147,7 +147,7 @@ public function testGetListenersOnLazyLoad() public function testRemoveAfterDispatch() { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $container = new Container(); $container->set('service.listener', $service); @@ -162,7 +162,7 @@ public function testRemoveAfterDispatch() public function testRemoveBeforeDispatch() { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $container = new Container(); $container->set('service.listener', $service); diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php index 6613a887eca49..14205d62ea887 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php @@ -120,7 +120,7 @@ public function testGetCalledListenersNested() public function testLogger() { - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $dispatcher = new EventDispatcher(); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); @@ -135,7 +135,7 @@ public function testLogger() public function testLoggerWithStoppedEvent() { - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $dispatcher = new EventDispatcher(); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); diff --git a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php index 0fdd6372bd31f..cb04f74beb6d4 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php @@ -29,7 +29,7 @@ public function testEventSubscriberWithoutInterface() 'my_event_subscriber' => array(0 => array()), ); - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); $definition->expects($this->atLeastOnce()) ->method('isPublic') ->will($this->returnValue(true)); @@ -37,10 +37,7 @@ public function testEventSubscriberWithoutInterface() ->method('getClass') ->will($this->returnValue('stdClass')); - $builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'getDefinition') - ); + $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock(); $builder->expects($this->any()) ->method('hasDefinition') ->will($this->returnValue(true)); @@ -64,7 +61,7 @@ public function testValidEventSubscriber() 'my_event_subscriber' => array(0 => array()), ); - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); $definition->expects($this->atLeastOnce()) ->method('isPublic') ->will($this->returnValue(true)); @@ -72,10 +69,7 @@ public function testValidEventSubscriber() ->method('getClass') ->will($this->returnValue('Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService')); - $builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition') - ); + $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition'))->getMock(); $builder->expects($this->any()) ->method('hasDefinition') ->will($this->returnValue(true)); diff --git a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php index 80a7e43be6205..0f8868037d15e 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php @@ -31,7 +31,7 @@ class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->innerDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $this->innerDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher); } @@ -80,7 +80,7 @@ public function testAddListenerDisallowed() */ public function testAddSubscriberDisallowed() { - $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface'); + $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock(); $this->dispatcher->addSubscriber($subscriber); } @@ -98,7 +98,7 @@ public function testRemoveListenerDisallowed() */ public function testRemoveSubscriberDisallowed() { - $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface'); + $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock(); $this->dispatcher->removeSubscriber($subscriber); } diff --git a/src/Symfony/Component/ExpressionLanguage/Compiler.php b/src/Symfony/Component/ExpressionLanguage/Compiler.php index d9f29696474e1..f32ec36d306f2 100644 --- a/src/Symfony/Component/ExpressionLanguage/Compiler.php +++ b/src/Symfony/Component/ExpressionLanguage/Compiler.php @@ -53,7 +53,7 @@ public function reset() * * @param Node\Node $node The node to compile * - * @return Compiler The current compiler instance + * @return $this */ public function compile(Node\Node $node) { @@ -80,7 +80,7 @@ public function subcompile(Node\Node $node) * * @param string $string The string * - * @return Compiler The current compiler instance + * @return $this */ public function raw($string) { @@ -94,7 +94,7 @@ public function raw($string) * * @param string $value The string * - * @return Compiler The current compiler instance + * @return $this */ public function string($value) { @@ -108,7 +108,7 @@ public function string($value) * * @param mixed $value The value to convert * - * @return Compiler The current compiler instance + * @return $this */ public function repr($value) { diff --git a/src/Symfony/Component/ExpressionLanguage/LICENSE b/src/Symfony/Component/ExpressionLanguage/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/ExpressionLanguage/LICENSE +++ b/src/Symfony/Component/ExpressionLanguage/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/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php index 5af0c4a8e803f..d2e60bd64905d 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php @@ -18,7 +18,7 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase { public function testCachedParse() { - $cacheMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface'); + $cacheMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock(); $savedParsedExpression = null; $expressionLanguage = new ExpressionLanguage($cacheMock); @@ -116,7 +116,7 @@ public function testCachingForOverriddenVariableNames() public function testCachingWithDifferentNamesOrder() { - $cacheMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface'); + $cacheMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock(); $expressionLanguage = new ExpressionLanguage($cacheMock); $savedParsedExpressions = array(); $cacheMock diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 34af820432efa..f39c9891dd2d1 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -548,7 +548,9 @@ public function dumpFile($filename, $content) if (!is_dir($dir)) { $this->mkdir($dir); - } elseif (!is_writable($dir)) { + } + + if (!is_writable($dir)) { throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir); } diff --git a/src/Symfony/Component/Filesystem/LICENSE b/src/Symfony/Component/Filesystem/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Filesystem/LICENSE +++ b/src/Symfony/Component/Filesystem/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/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index 62f4f549d12d7..add3fa2579e94 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -72,7 +72,7 @@ public function __construct() /** * Creates a new Finder. * - * @return Finder A new Finder instance + * @return static */ public static function create() { @@ -82,7 +82,7 @@ public static function create() /** * Restricts the matching to directories only. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this */ public function directories() { @@ -94,7 +94,7 @@ public function directories() /** * Restricts the matching to files only. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this */ public function files() { @@ -113,7 +113,7 @@ public function files() * * @param string|int $level The depth level expression * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see DepthRangeFilterIterator * @see NumberComparator @@ -137,7 +137,7 @@ public function depth($level) * * @param string $date A date range string * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see strtotime * @see DateRangeFilterIterator @@ -161,7 +161,7 @@ public function date($date) * * @param string $pattern A pattern (a regexp, a glob, or a string) * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see FilenameFilterIterator */ @@ -177,7 +177,7 @@ public function name($pattern) * * @param string $pattern A pattern (a regexp, a glob, or a string) * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see FilenameFilterIterator */ @@ -198,7 +198,7 @@ public function notName($pattern) * * @param string $pattern A pattern (string or regexp) * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see FilecontentFilterIterator */ @@ -219,7 +219,7 @@ public function contains($pattern) * * @param string $pattern A pattern (string or regexp) * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see FilecontentFilterIterator */ @@ -242,7 +242,7 @@ public function notContains($pattern) * * @param string $pattern A pattern (a regexp or a string) * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see FilenameFilterIterator */ @@ -265,7 +265,7 @@ public function path($pattern) * * @param string $pattern A pattern (a regexp or a string) * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see FilenameFilterIterator */ @@ -285,7 +285,7 @@ public function notPath($pattern) * * @param string|int $size A size range string or an integer * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see SizeRangeFilterIterator * @see NumberComparator @@ -302,7 +302,7 @@ public function size($size) * * @param string|array $dirs A directory path or an array of directories * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see ExcludeDirectoryFilterIterator */ @@ -318,7 +318,7 @@ public function exclude($dirs) * * @param bool $ignoreDotFiles Whether to exclude "hidden" files or not * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see ExcludeDirectoryFilterIterator */ @@ -338,7 +338,7 @@ public function ignoreDotFiles($ignoreDotFiles) * * @param bool $ignoreVCS Whether to exclude VCS files or not * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see ExcludeDirectoryFilterIterator */ @@ -378,7 +378,7 @@ public static function addVCSPattern($pattern) * * @param \Closure $closure An anonymous function * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see SortableIterator */ @@ -394,7 +394,7 @@ public function sort(\Closure $closure) * * This can be slow as all the matching files and directories must be retrieved for comparison. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see SortableIterator */ @@ -410,7 +410,7 @@ public function sortByName() * * This can be slow as all the matching files and directories must be retrieved for comparison. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see SortableIterator */ @@ -428,7 +428,7 @@ public function sortByType() * * This can be slow as all the matching files and directories must be retrieved for comparison. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see SortableIterator */ @@ -448,7 +448,7 @@ public function sortByAccessedTime() * * This can be slow as all the matching files and directories must be retrieved for comparison. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see SortableIterator */ @@ -466,7 +466,7 @@ public function sortByChangedTime() * * This can be slow as all the matching files and directories must be retrieved for comparison. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see SortableIterator */ @@ -485,7 +485,7 @@ public function sortByModifiedTime() * * @param \Closure $closure An anonymous function * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see CustomFilterIterator */ @@ -499,7 +499,7 @@ public function filter(\Closure $closure) /** * Forces the following of symlinks. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this */ public function followLinks() { @@ -515,7 +515,7 @@ public function followLinks() * * @param bool $ignore * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this */ public function ignoreUnreadableDirs($ignore = true) { @@ -529,7 +529,7 @@ public function ignoreUnreadableDirs($ignore = true) * * @param string|array $dirs A directory path or an array of directories * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @throws \InvalidArgumentException if one of the directories does not exist */ @@ -590,7 +590,7 @@ public function getIterator() * * @param mixed $iterator * - * @return Finder|SplFileInfo[] The finder + * @return $this * * @throws \InvalidArgumentException When the given argument is not iterable. */ diff --git a/src/Symfony/Component/Finder/LICENSE b/src/Symfony/Component/Finder/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Finder/LICENSE +++ b/src/Symfony/Component/Finder/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/Component/Form/Button.php b/src/Symfony/Component/Form/Button.php index 6ceaed278e866..efc14c063932b 100644 --- a/src/Symfony/Component/Form/Button.php +++ b/src/Symfony/Component/Form/Button.php @@ -369,7 +369,7 @@ public function handleRequest($request = null) * @param null|string $submittedData The data * @param bool $clearMissing Not used * - * @return Button The button instance + * @return $this * * @throws Exception\AlreadySubmittedException If the button has already been submitted. */ diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index 23dced537f48c..c65fb303ddcd3 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -286,7 +286,7 @@ public function setDataMapper(DataMapperInterface $dataMapper = null) * * @param bool $disabled Whether the button is disabled * - * @return ButtonBuilder The button builder + * @return $this */ public function setDisabled($disabled) { @@ -398,7 +398,7 @@ public function setCompound($compound) * * @param ResolvedFormTypeInterface $type The type of the button * - * @return ButtonBuilder The button builder + * @return $this */ public function setType(ResolvedFormTypeInterface $type) { @@ -490,7 +490,7 @@ public function setRequestHandler(RequestHandlerInterface $requestHandler) * * @param bool $initialize * - * @return ButtonBuilder + * @return $this * * @throws BadMethodCallException */ diff --git a/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php b/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php index 9e648cc360000..f3eae3762a152 100644 --- a/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php +++ b/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php @@ -48,7 +48,7 @@ public function __construct($label, array $choices = array()) /** * {@inheritdoc} * - * @return ChoiceGroupView[]|ChoiceView[] + * @return self[]|ChoiceView[] */ public function getIterator() { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index 8434f8932bab1..68ce27b083f9b 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -129,11 +129,11 @@ public function reverseTransform($value) try { if ($dateOnly) { // we only care about year-month-date, which has been delivered as a timestamp pointing to UTC midnight - return new \DateTime(gmdate('Y-m-d', $timestamp), new \DateTimeZone($this->inputTimezone)); + $dateTime = new \DateTime(gmdate('Y-m-d', $timestamp), new \DateTimeZone($this->outputTimezone)); + } else { + // read timestamp into DateTime object - the formatter delivers a timestamp + $dateTime = new \DateTime(sprintf('@%s', $timestamp)); } - - // read timestamp into DateTime object - the formatter delivers a timestamp - $dateTime = new \DateTime(sprintf('@%s', $timestamp)); // set timezone separately, as it would be ignored if set via the constructor, // see http://php.net/manual/en/datetime.construct.php $dateTime->setTimezone(new \DateTimeZone($this->outputTimezone)); diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index 07803ab53d063..93d5188d9ddc8 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; @@ -47,8 +48,8 @@ public function validate($form, Constraint $constraint) // Validate the data against its own constraints if ($form->isRoot() && (is_object($data) || is_array($data))) { - foreach ($groups as $group) { - $validator->atPath('data')->validate($form->getData(), null, $group); + if (is_array($groups) && count($groups) > 0 || $groups instanceof GroupSequence && count($groups->groups) > 0) { + $validator->atPath('data')->validate($form->getData(), null, $groups); } } @@ -166,6 +167,10 @@ private static function resolveValidationGroups($groups, FormInterface $form) $groups = call_user_func($groups, $form); } + if ($groups instanceof GroupSequence) { + return $groups; + } + return (array) $groups; } } diff --git a/src/Symfony/Component/Form/Extension/Validator/Type/BaseValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/Type/BaseValidatorExtension.php index 512d8184e4957..4f52003c0d099 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Type/BaseValidatorExtension.php +++ b/src/Symfony/Component/Form/Extension/Validator/Type/BaseValidatorExtension.php @@ -14,6 +14,7 @@ use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\GroupSequence; /** * Encapsulates common logic of {@link FormTypeValidatorExtension} and @@ -42,6 +43,10 @@ public function configureOptions(OptionsResolver $resolver) return $groups; } + if ($groups instanceof GroupSequence) { + return $groups; + } + return (array) $groups; }; diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index bc1714852803f..4ef6abd39ffc6 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -713,7 +713,7 @@ public function isEmpty() return FormUtil::isEmpty($this->modelData) || // arrays, countables - 0 === count($this->modelData) || + ((is_array($this->modelData) || $this->modelData instanceof \Countable) && 0 === count($this->modelData)) || // traversables that are not countable ($this->modelData instanceof \Traversable && 0 === iterator_count($this->modelData)); } diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index a9bf67be1f508..e8648ac41b171 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -248,7 +248,7 @@ public function getIterator() * * @param string $name The name of the unresolved child * - * @return FormBuilder The created instance + * @return self The created instance */ private function resolveChild($name) { diff --git a/src/Symfony/Component/Form/FormBuilderInterface.php b/src/Symfony/Component/Form/FormBuilderInterface.php index 68a176c98a326..bd7ce9b61e518 100644 --- a/src/Symfony/Component/Form/FormBuilderInterface.php +++ b/src/Symfony/Component/Form/FormBuilderInterface.php @@ -27,7 +27,7 @@ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuild * @param string|null $type * @param array $options * - * @return FormBuilderInterface The builder object + * @return $this */ public function add($child, $type = null, array $options = array()); @@ -38,7 +38,7 @@ public function add($child, $type = null, array $options = array()); * @param string|null $type The type of the form or null if name is a property * @param array $options The options * - * @return FormBuilderInterface The created builder + * @return self */ public function create($name, $type = null, array $options = array()); @@ -47,7 +47,7 @@ public function create($name, $type = null, array $options = array()); * * @param string $name The name of the child * - * @return FormBuilderInterface The builder for the child + * @return self * * @throws Exception\InvalidArgumentException if the given child does not exist */ @@ -58,7 +58,7 @@ public function get($name); * * @param string $name * - * @return FormBuilderInterface The builder object + * @return $this */ public function remove($name); diff --git a/src/Symfony/Component/Form/FormConfigBuilderInterface.php b/src/Symfony/Component/Form/FormConfigBuilderInterface.php index 72d747c2421bb..13ac4682b6bca 100644 --- a/src/Symfony/Component/Form/FormConfigBuilderInterface.php +++ b/src/Symfony/Component/Form/FormConfigBuilderInterface.php @@ -28,7 +28,7 @@ interface FormConfigBuilderInterface extends FormConfigInterface * with a higher priority are called before * listeners with a lower priority. * - * @return self The configuration object + * @return $this The configuration object */ public function addEventListener($eventName, $listener, $priority = 0); @@ -37,7 +37,7 @@ public function addEventListener($eventName, $listener, $priority = 0); * * @param EventSubscriberInterface $subscriber The subscriber to attach * - * @return self The configuration object + * @return $this The configuration object */ public function addEventSubscriber(EventSubscriberInterface $subscriber); @@ -52,14 +52,14 @@ public function addEventSubscriber(EventSubscriberInterface $subscriber); * @param DataTransformerInterface $viewTransformer * @param bool $forcePrepend if set to true, prepend instead of appending * - * @return self The configuration object + * @return $this The configuration object */ public function addViewTransformer(DataTransformerInterface $viewTransformer, $forcePrepend = false); /** * Clears the view transformers. * - * @return self The configuration object + * @return $this The configuration object */ public function resetViewTransformers(); @@ -74,14 +74,14 @@ public function resetViewTransformers(); * @param DataTransformerInterface $modelTransformer * @param bool $forceAppend if set to true, append instead of prepending * - * @return self The configuration object + * @return $this The configuration object */ public function addModelTransformer(DataTransformerInterface $modelTransformer, $forceAppend = false); /** * Clears the normalization transformers. * - * @return self The configuration object + * @return $this The configuration object */ public function resetModelTransformers(); @@ -91,7 +91,7 @@ public function resetModelTransformers(); * @param string $name The name of the attribute * @param mixed $value The value of the attribute * - * @return self The configuration object + * @return $this The configuration object */ public function setAttribute($name, $value); @@ -100,7 +100,7 @@ public function setAttribute($name, $value); * * @param array $attributes The attributes * - * @return self The configuration object + * @return $this The configuration object */ public function setAttributes(array $attributes); @@ -109,7 +109,7 @@ public function setAttributes(array $attributes); * * @param DataMapperInterface $dataMapper * - * @return self The configuration object + * @return $this The configuration object */ public function setDataMapper(DataMapperInterface $dataMapper = null); @@ -118,7 +118,7 @@ public function setDataMapper(DataMapperInterface $dataMapper = null); * * @param bool $disabled Whether the form is disabled * - * @return self The configuration object + * @return $this The configuration object */ public function setDisabled($disabled); @@ -127,7 +127,7 @@ public function setDisabled($disabled); * * @param mixed $emptyData The empty data * - * @return self The configuration object + * @return $this The configuration object */ public function setEmptyData($emptyData); @@ -136,7 +136,7 @@ public function setEmptyData($emptyData); * * @param bool $errorBubbling * - * @return self The configuration object + * @return $this The configuration object */ public function setErrorBubbling($errorBubbling); @@ -145,7 +145,7 @@ public function setErrorBubbling($errorBubbling); * * @param bool $required * - * @return self The configuration object + * @return $this The configuration object */ public function setRequired($required); @@ -156,7 +156,7 @@ public function setRequired($required); * The property path or null if the path should be set * automatically based on the form's name. * - * @return self The configuration object + * @return $this The configuration object */ public function setPropertyPath($propertyPath); @@ -166,7 +166,7 @@ public function setPropertyPath($propertyPath); * * @param bool $mapped Whether the form should be mapped * - * @return self The configuration object + * @return $this The configuration object */ public function setMapped($mapped); @@ -176,7 +176,7 @@ public function setMapped($mapped); * @param bool $byReference Whether the data should be * modified by reference. * - * @return self The configuration object + * @return $this The configuration object */ public function setByReference($byReference); @@ -185,7 +185,7 @@ public function setByReference($byReference); * * @param bool $inheritData Whether the form should inherit its parent's data * - * @return self The configuration object + * @return $this The configuration object */ public function setInheritData($inheritData); @@ -194,7 +194,7 @@ public function setInheritData($inheritData); * * @param bool $compound Whether the form should be compound * - * @return self The configuration object + * @return $this The configuration object * * @see FormConfigInterface::getCompound() */ @@ -205,7 +205,7 @@ public function setCompound($compound); * * @param ResolvedFormTypeInterface $type The type of the form * - * @return self The configuration object + * @return $this The configuration object */ public function setType(ResolvedFormTypeInterface $type); @@ -214,7 +214,7 @@ public function setType(ResolvedFormTypeInterface $type); * * @param mixed $data The data of the form in application format * - * @return self The configuration object + * @return $this The configuration object */ public function setData($data); @@ -227,7 +227,7 @@ public function setData($data); * * @param bool $locked Whether to lock the default data * - * @return self The configuration object + * @return $this The configuration object */ public function setDataLocked($locked); @@ -243,7 +243,7 @@ public function setFormFactory(FormFactoryInterface $formFactory); * * @param string $action The target URL of the form * - * @return self The configuration object + * @return $this The configuration object */ public function setAction($action); @@ -252,7 +252,7 @@ public function setAction($action); * * @param string $method The HTTP method of the form * - * @return self The configuration object + * @return $this The configuration object */ public function setMethod($method); @@ -261,7 +261,7 @@ public function setMethod($method); * * @param RequestHandlerInterface $requestHandler * - * @return self The configuration object + * @return $this The configuration object */ public function setRequestHandler(RequestHandlerInterface $requestHandler); @@ -275,7 +275,7 @@ public function setRequestHandler(RequestHandlerInterface $requestHandler); * In the second case, you need to call * {@link FormInterface::initialize()} manually. * - * @return self The configuration object + * @return $this The configuration object */ public function setAutoInitialize($initialize); diff --git a/src/Symfony/Component/Form/FormFactoryBuilderInterface.php b/src/Symfony/Component/Form/FormFactoryBuilderInterface.php index d89e2f9f9a2bf..c1e55dcc60ea5 100644 --- a/src/Symfony/Component/Form/FormFactoryBuilderInterface.php +++ b/src/Symfony/Component/Form/FormFactoryBuilderInterface.php @@ -23,7 +23,7 @@ interface FormFactoryBuilderInterface * * @param ResolvedFormTypeFactoryInterface $resolvedTypeFactory * - * @return FormFactoryBuilderInterface The builder + * @return $this */ public function setResolvedTypeFactory(ResolvedFormTypeFactoryInterface $resolvedTypeFactory); @@ -32,7 +32,7 @@ public function setResolvedTypeFactory(ResolvedFormTypeFactoryInterface $resolve * * @param FormExtensionInterface $extension The extension * - * @return FormFactoryBuilderInterface The builder + * @return $this */ public function addExtension(FormExtensionInterface $extension); @@ -41,7 +41,7 @@ public function addExtension(FormExtensionInterface $extension); * * @param FormExtensionInterface[] $extensions The extensions * - * @return FormFactoryBuilderInterface The builder + * @return $this */ public function addExtensions(array $extensions); @@ -50,7 +50,7 @@ public function addExtensions(array $extensions); * * @param FormTypeInterface $type The form type * - * @return FormFactoryBuilderInterface The builder + * @return $this */ public function addType(FormTypeInterface $type); @@ -59,7 +59,7 @@ public function addType(FormTypeInterface $type); * * @param FormTypeInterface[] $types The form types * - * @return FormFactoryBuilderInterface The builder + * @return $this */ public function addTypes(array $types); @@ -68,7 +68,7 @@ public function addTypes(array $types); * * @param FormTypeExtensionInterface $typeExtension The form type extension * - * @return FormFactoryBuilderInterface The builder + * @return $this */ public function addTypeExtension(FormTypeExtensionInterface $typeExtension); @@ -77,7 +77,7 @@ public function addTypeExtension(FormTypeExtensionInterface $typeExtension); * * @param FormTypeExtensionInterface[] $typeExtensions The form type extensions * - * @return FormFactoryBuilderInterface The builder + * @return $this */ public function addTypeExtensions(array $typeExtensions); @@ -86,7 +86,7 @@ public function addTypeExtensions(array $typeExtensions); * * @param FormTypeGuesserInterface $typeGuesser The type guesser * - * @return FormFactoryBuilderInterface The builder + * @return $this */ public function addTypeGuesser(FormTypeGuesserInterface $typeGuesser); @@ -95,7 +95,7 @@ public function addTypeGuesser(FormTypeGuesserInterface $typeGuesser); * * @param FormTypeGuesserInterface[] $typeGuessers The type guessers * - * @return FormFactoryBuilderInterface The builder + * @return $this */ public function addTypeGuessers(array $typeGuessers); diff --git a/src/Symfony/Component/Form/FormInterface.php b/src/Symfony/Component/Form/FormInterface.php index 9de802847ee8e..a61f7f99d0d74 100644 --- a/src/Symfony/Component/Form/FormInterface.php +++ b/src/Symfony/Component/Form/FormInterface.php @@ -25,7 +25,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable * * @param FormInterface|null $parent The parent form or null if it's the root * - * @return FormInterface The form instance + * @return self * * @throws Exception\AlreadySubmittedException If the form has already been submitted. * @throws Exception\LogicException When trying to set a parent for a form with @@ -36,7 +36,7 @@ public function setParent(FormInterface $parent = null); /** * Returns the parent form. * - * @return FormInterface|null The parent form or null if there is none + * @return self|null The parent form or null if there is none */ public function getParent(); @@ -47,7 +47,7 @@ public function getParent(); * @param string|null $type The child's type, if a name was passed * @param array $options The child's options, if a name was passed * - * @return FormInterface The form instance + * @return self * * @throws Exception\AlreadySubmittedException If the form has already been submitted. * @throws Exception\LogicException When trying to add a child to a non-compound form. @@ -60,7 +60,7 @@ public function add($child, $type = null, array $options = array()); * * @param string $name The name of the child * - * @return FormInterface The child form + * @return self * * @throws \OutOfBoundsException If the named child does not exist. */ @@ -80,7 +80,7 @@ public function has($name); * * @param string $name The name of the child to remove * - * @return FormInterface The form instance + * @return $this * * @throws Exception\AlreadySubmittedException If the form has already been submitted. */ @@ -89,7 +89,7 @@ public function remove($name); /** * Returns all children in this group. * - * @return FormInterface[] An array of FormInterface instances + * @return self[] */ public function all(); @@ -110,7 +110,7 @@ public function getErrors($deep = false, $flatten = true); * * @param mixed $modelData The data formatted as expected for the underlying object * - * @return FormInterface The form instance + * @return $this * * @throws Exception\AlreadySubmittedException If the form has already been submitted. * @throws Exception\LogicException If listeners try to call setData in a cycle. Or if @@ -182,7 +182,7 @@ public function getPropertyPath(); * * @param FormError $error * - * @return FormInterface The form instance + * @return $this */ public function addError(FormError $error); @@ -248,7 +248,7 @@ public function getTransformationFailure(); * * Should be called on the root form after constructing the tree. * - * @return FormInterface The form instance + * @return $this */ public function initialize(); @@ -262,7 +262,7 @@ public function initialize(); * * @param mixed $request The request to handle * - * @return FormInterface The form instance + * @return $this */ public function handleRequest($request = null); @@ -274,7 +274,7 @@ public function handleRequest($request = null); * when they are missing in the * submitted data. * - * @return FormInterface The form instance + * @return $this * * @throws Exception\AlreadySubmittedException If the form has already been submitted. */ @@ -283,7 +283,7 @@ public function submit($submittedData, $clearMissing = true); /** * Returns the root of the form tree. * - * @return FormInterface The root of the tree + * @return self The root of the tree */ public function getRoot(); diff --git a/src/Symfony/Component/Form/FormView.php b/src/Symfony/Component/Form/FormView.php index 401288cf83d91..c1da5f8fc9bb1 100644 --- a/src/Symfony/Component/Form/FormView.php +++ b/src/Symfony/Component/Form/FormView.php @@ -81,7 +81,7 @@ public function isRendered() /** * Marks the view as rendered. * - * @return FormView The view object + * @return $this */ public function setRendered() { @@ -95,7 +95,7 @@ public function setRendered() * * @param string $name The child name * - * @return FormView The child view + * @return self The child view */ public function offsetGet($name) { diff --git a/src/Symfony/Component/Form/Guess/Guess.php b/src/Symfony/Component/Form/Guess/Guess.php index 0595e7bba3d34..36614ffdb9f93 100644 --- a/src/Symfony/Component/Form/Guess/Guess.php +++ b/src/Symfony/Component/Form/Guess/Guess.php @@ -70,7 +70,7 @@ abstract class Guess * * @param Guess[] $guesses An array of guesses * - * @return Guess|null The guess with the highest confidence + * @return self|null */ public static function getBestGuess(array $guesses) { diff --git a/src/Symfony/Component/Form/LICENSE b/src/Symfony/Component/Form/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Form/LICENSE +++ b/src/Symfony/Component/Form/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/Component/Form/ResolvedFormTypeInterface.php b/src/Symfony/Component/Form/ResolvedFormTypeInterface.php index 7d7647728f435..dc3b81d2fa2a8 100644 --- a/src/Symfony/Component/Form/ResolvedFormTypeInterface.php +++ b/src/Symfony/Component/Form/ResolvedFormTypeInterface.php @@ -30,7 +30,7 @@ public function getBlockPrefix(); /** * Returns the parent type. * - * @return ResolvedFormTypeInterface|null The parent type or null + * @return self|null The parent type or null */ public function getParent(); diff --git a/src/Symfony/Component/Form/SubmitButton.php b/src/Symfony/Component/Form/SubmitButton.php index 53ff7bc311cb1..4bfc1b6465819 100644 --- a/src/Symfony/Component/Form/SubmitButton.php +++ b/src/Symfony/Component/Form/SubmitButton.php @@ -37,7 +37,7 @@ public function isClicked() * @param null|string $submittedData The data * @param bool $clearMissing Not used * - * @return SubmitButton The button instance + * @return $this * * @throws Exception\AlreadySubmittedException If the form has already been submitted. */ diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php index c2c3ad21b24b3..09138b1da7dcd 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php @@ -1364,7 +1364,7 @@ public function testCountryWithPlaceholder() public function testDateTime() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => false, )); @@ -1383,7 +1383,7 @@ public function testDateTime() /following-sibling::select [@id="name_date_year"] [@class="form-control"] - [./option[@value="2011"][@selected="selected"]] + [./option[@value="'.date('Y').'"][@selected="selected"]] /following-sibling::select [@id="name_time_hour"] [@class="form-control"] @@ -1438,7 +1438,7 @@ public function testDateTimeWithPlaceholderGlobal() public function testDateTimeWithHourAndMinute() { - $data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5'); + $data = array('year' => date('Y'), 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5'); $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', $data, array( 'input' => 'array', @@ -1460,7 +1460,7 @@ public function testDateTimeWithHourAndMinute() /following-sibling::select [@id="name_date_year"] [@class="form-control"] - [./option[@value="2011"][@selected="selected"]] + [./option[@value="'.date('Y').'"][@selected="selected"]] /following-sibling::select [@id="name_time_hour"] [@class="form-control"] @@ -1477,7 +1477,7 @@ public function testDateTimeWithHourAndMinute() public function testDateTimeWithSeconds() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => true, )); @@ -1497,7 +1497,7 @@ public function testDateTimeWithSeconds() /following-sibling::select [@id="name_date_year"] [@class="form-control"] - [./option[@value="2011"][@selected="selected"]] + [./option[@value="'.date('Y').'"][@selected="selected"]] /following-sibling::select [@id="name_time_hour"] [@class="form-control"] @@ -1587,7 +1587,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() public function testDateChoice() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', date('Y').'-02-03', array( 'input' => 'string', 'widget' => 'choice', )); @@ -1607,7 +1607,7 @@ public function testDateChoice() /following-sibling::select [@id="name_year"] [@class="form-control"] - [./option[@value="2011"][@selected="selected"]] + [./option[@value="'.date('Y').'"][@selected="selected"]] ] [count(./select)=3] ' diff --git a/src/Symfony/Component/Form/Tests/AbstractFormTest.php b/src/Symfony/Component/Form/Tests/AbstractFormTest.php index dec9df70768cd..951258921ec46 100644 --- a/src/Symfony/Component/Form/Tests/AbstractFormTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractFormTest.php @@ -35,7 +35,7 @@ abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->dispatcher = new EventDispatcher(); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $this->form = $this->createForm(); } @@ -71,8 +71,8 @@ protected function getBuilder($name = 'name', EventDispatcherInterface $dispatch */ protected function getMockForm($name = 'name') { - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $config = $this->getMock('Symfony\Component\Form\FormConfigInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); + $config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock(); $form->expects($this->any()) ->method('getName') @@ -89,7 +89,7 @@ protected function getMockForm($name = 'name') */ protected function getDataMapper() { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); + return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); } /** @@ -97,7 +97,7 @@ protected function getDataMapper() */ protected function getDataTransformer() { - return $this->getMock('Symfony\Component\Form\DataTransformerInterface'); + return $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); } /** @@ -105,6 +105,6 @@ protected function getDataTransformer() */ protected function getFormValidator() { - return $this->getMock('Symfony\Component\Form\FormValidatorInterface'); + return $this->getMockBuilder('Symfony\Component\Form\FormValidatorInterface')->getMock(); } } diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 25edbed147103..31372ebef99cb 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -28,7 +28,7 @@ protected function setUp() \Locale::setDefault('en'); - $this->csrfTokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); + $this->csrfTokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); parent::setUp(); } @@ -1233,7 +1233,7 @@ public function testCountryWithPlaceholder() public function testDateTime() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => false, )); @@ -1252,7 +1252,7 @@ public function testDateTime() [./option[@value="3"][@selected="selected"]] /following-sibling::select [@id="name_date_year"] - [./option[@value="2011"][@selected="selected"]] + [./option[@value="'.date('Y').'"][@selected="selected"]] ] /following-sibling::div [@id="name_time"] @@ -1312,7 +1312,7 @@ public function testDateTimeWithPlaceholderGlobal() public function testDateTimeWithHourAndMinute() { - $data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5'); + $data = array('year' => date('Y'), 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5'); $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', $data, array( 'input' => 'array', @@ -1333,7 +1333,7 @@ public function testDateTimeWithHourAndMinute() [./option[@value="3"][@selected="selected"]] /following-sibling::select [@id="name_date_year"] - [./option[@value="2011"][@selected="selected"]] + [./option[@value="'.date('Y').'"][@selected="selected"]] ] /following-sibling::div [@id="name_time"] @@ -1353,7 +1353,7 @@ public function testDateTimeWithHourAndMinute() public function testDateTimeWithSeconds() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => true, )); @@ -1372,7 +1372,7 @@ public function testDateTimeWithSeconds() [./option[@value="3"][@selected="selected"]] /following-sibling::select [@id="name_date_year"] - [./option[@value="2011"][@selected="selected"]] + [./option[@value="'.date('Y').'"][@selected="selected"]] ] /following-sibling::div [@id="name_time"] @@ -1459,7 +1459,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() public function testDateChoice() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', date('Y').'-02-03', array( 'input' => 'string', 'widget' => 'choice', )); @@ -1475,7 +1475,7 @@ public function testDateChoice() [./option[@value="3"][@selected="selected"]] /following-sibling::select [@id="name_year"] - [./option[@value="2011"][@selected="selected"]] + [./option[@value="'.date('Y').'"][@selected="selected"]] ] [count(./select)=3] ' diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php index 022b5148e9e51..5ddd6cb60b383 100644 --- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php @@ -37,10 +37,7 @@ abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->serverParams = $this->getMock( - 'Symfony\Component\Form\Util\ServerParams', - array('getNormalizedIniPostMaxSize', 'getContentLength') - ); + $this->serverParams = $this->getMockBuilder('Symfony\Component\Form\Util\ServerParams')->setMethods(array('getNormalizedIniPostMaxSize', 'getContentLength'))->getMock(); $this->requestHandler = $this->getRequestHandler(); $this->factory = Forms::createFormFactoryBuilder()->getFormFactory(); $this->request = null; @@ -363,7 +360,7 @@ abstract protected function getMockFile($suffix = ''); protected function getMockForm($name, $method = null, $compound = true) { - $config = $this->getMock('Symfony\Component\Form\FormConfigInterface'); + $config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock(); $config->expects($this->any()) ->method('getMethod') ->will($this->returnValue($method)); @@ -371,7 +368,7 @@ protected function getMockForm($name, $method = null, $compound = true) ->method('getCompound') ->will($this->returnValue($compound)); - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $form->expects($this->any()) ->method('getName') ->will($this->returnValue($name)); diff --git a/src/Symfony/Component/Form/Tests/ButtonTest.php b/src/Symfony/Component/Form/Tests/ButtonTest.php index b0c766c73c081..5fa2fa136874a 100644 --- a/src/Symfony/Component/Form/Tests/ButtonTest.php +++ b/src/Symfony/Component/Form/Tests/ButtonTest.php @@ -25,8 +25,8 @@ class ButtonTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); } /** diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index c27c0093615f0..af73e96792ce6 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -30,7 +30,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->decoratedFactory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface'); + $this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock(); $this->factory = new CachingFactoryDecorator($this->decoratedFactory); } @@ -157,7 +157,7 @@ public function testCreateFromChoicesDifferentValueClosure() public function testCreateFromLoaderSameLoader() { - $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $list = new \stdClass(); $this->decoratedFactory->expects($this->once()) @@ -171,8 +171,8 @@ public function testCreateFromLoaderSameLoader() public function testCreateFromLoaderDifferentLoader() { - $loader1 = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); - $loader2 = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $list1 = new \stdClass(); $list2 = new \stdClass(); @@ -191,7 +191,7 @@ public function testCreateFromLoaderDifferentLoader() public function testCreateFromLoaderSameValueClosure() { - $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $list = new \stdClass(); $closure = function () {}; @@ -206,7 +206,7 @@ public function testCreateFromLoaderSameValueClosure() public function testCreateFromLoaderDifferentValueClosure() { - $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $list1 = new \stdClass(); $list2 = new \stdClass(); $closure1 = function () {}; @@ -228,7 +228,7 @@ public function testCreateFromLoaderDifferentValueClosure() public function testCreateViewSamePreferredChoices() { $preferred = array('a'); - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view = new \stdClass(); $this->decoratedFactory->expects($this->once()) @@ -244,7 +244,7 @@ public function testCreateViewDifferentPreferredChoices() { $preferred1 = array('a'); $preferred2 = array('b'); - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view1 = new \stdClass(); $view2 = new \stdClass(); @@ -264,7 +264,7 @@ public function testCreateViewDifferentPreferredChoices() public function testCreateViewSamePreferredChoicesClosure() { $preferred = function () {}; - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view = new \stdClass(); $this->decoratedFactory->expects($this->once()) @@ -280,7 +280,7 @@ public function testCreateViewDifferentPreferredChoicesClosure() { $preferred1 = function () {}; $preferred2 = function () {}; - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view1 = new \stdClass(); $view2 = new \stdClass(); @@ -300,7 +300,7 @@ public function testCreateViewDifferentPreferredChoicesClosure() public function testCreateViewSameLabelClosure() { $labels = function () {}; - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view = new \stdClass(); $this->decoratedFactory->expects($this->once()) @@ -316,7 +316,7 @@ public function testCreateViewDifferentLabelClosure() { $labels1 = function () {}; $labels2 = function () {}; - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view1 = new \stdClass(); $view2 = new \stdClass(); @@ -336,7 +336,7 @@ public function testCreateViewDifferentLabelClosure() public function testCreateViewSameIndexClosure() { $index = function () {}; - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view = new \stdClass(); $this->decoratedFactory->expects($this->once()) @@ -352,7 +352,7 @@ public function testCreateViewDifferentIndexClosure() { $index1 = function () {}; $index2 = function () {}; - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view1 = new \stdClass(); $view2 = new \stdClass(); @@ -372,7 +372,7 @@ public function testCreateViewDifferentIndexClosure() public function testCreateViewSameGroupByClosure() { $groupBy = function () {}; - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view = new \stdClass(); $this->decoratedFactory->expects($this->once()) @@ -388,7 +388,7 @@ public function testCreateViewDifferentGroupByClosure() { $groupBy1 = function () {}; $groupBy2 = function () {}; - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view1 = new \stdClass(); $view2 = new \stdClass(); @@ -408,7 +408,7 @@ public function testCreateViewDifferentGroupByClosure() public function testCreateViewSameAttributes() { $attr = array('class' => 'foobar'); - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view = new \stdClass(); $this->decoratedFactory->expects($this->once()) @@ -424,7 +424,7 @@ public function testCreateViewDifferentAttributes() { $attr1 = array('class' => 'foobar1'); $attr2 = array('class' => 'foobar2'); - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view1 = new \stdClass(); $view2 = new \stdClass(); @@ -444,7 +444,7 @@ public function testCreateViewDifferentAttributes() public function testCreateViewSameAttributesClosure() { $attr = function () {}; - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view = new \stdClass(); $this->decoratedFactory->expects($this->once()) @@ -460,7 +460,7 @@ public function testCreateViewDifferentAttributesClosure() { $attr1 = function () {}; $attr2 = function () {}; - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $view1 = new \stdClass(); $view2 = new \stdClass(); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index 4c268418aa6f3..80e6e8f2642b7 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -193,7 +193,7 @@ function ($object) { return $object->value; } public function testCreateFromLoader() { - $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $list = $this->factory->createListFromLoader($loader); @@ -202,7 +202,7 @@ public function testCreateFromLoader() public function testCreateFromLoaderWithValues() { - $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $value = function () {}; $list = $this->factory->createListFromLoader($loader, $value); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index c7b225410a7af..30111a24082da 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -31,7 +31,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->decoratedFactory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface'); + $this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock(); $this->factory = new PropertyAccessDecorator($this->decoratedFactory); } @@ -80,7 +80,7 @@ public function testCreateFromChoicesPropertyPathWithCallableString() public function testCreateFromLoaderPropertyPath() { - $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') @@ -97,7 +97,7 @@ public function testCreateFromLoaderPropertyPath() */ public function testCreateFromLoaderPropertyPathWithCallableString() { - $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') @@ -125,7 +125,7 @@ public function testCreateFromChoicesAssumeNullIfValuePropertyPathUnreadable() // https://github.com/symfony/symfony/issues/5494 public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadable() { - $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') @@ -139,7 +139,7 @@ public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadabl public function testCreateFromLoaderPropertyPathInstance() { - $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') @@ -153,7 +153,7 @@ public function testCreateFromLoaderPropertyPathInstance() public function testCreateViewPreferredChoicesAsPropertyPath() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -173,7 +173,7 @@ public function testCreateViewPreferredChoicesAsPropertyPath() */ public function testCreateViewPreferredChoicesAsPropertyPathWithCallableString() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -188,7 +188,7 @@ public function testCreateViewPreferredChoicesAsPropertyPathWithCallableString() public function testCreateViewPreferredChoicesAsPropertyPathInstance() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -206,7 +206,7 @@ public function testCreateViewPreferredChoicesAsPropertyPathInstance() // https://github.com/symfony/symfony/issues/5494 public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -223,7 +223,7 @@ public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable public function testCreateViewLabelsAsPropertyPath() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -244,7 +244,7 @@ public function testCreateViewLabelsAsPropertyPath() */ public function testCreateViewLabelsAsPropertyPathWithCallableString() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -260,7 +260,7 @@ public function testCreateViewLabelsAsPropertyPathWithCallableString() public function testCreateViewLabelsAsPropertyPathInstance() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -278,7 +278,7 @@ public function testCreateViewLabelsAsPropertyPathInstance() public function testCreateViewIndicesAsPropertyPath() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -300,7 +300,7 @@ public function testCreateViewIndicesAsPropertyPath() */ public function testCreateViewIndicesAsPropertyPathWithCallableString() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -317,7 +317,7 @@ public function testCreateViewIndicesAsPropertyPathWithCallableString() public function testCreateViewIndicesAsPropertyPathInstance() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -336,7 +336,7 @@ public function testCreateViewIndicesAsPropertyPathInstance() public function testCreateViewGroupsAsPropertyPath() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -359,7 +359,7 @@ public function testCreateViewGroupsAsPropertyPath() */ public function testCreateViewGroupsAsPropertyPathWithCallableString() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -377,7 +377,7 @@ public function testCreateViewGroupsAsPropertyPathWithCallableString() public function testCreateViewGroupsAsPropertyPathInstance() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -398,7 +398,7 @@ public function testCreateViewGroupsAsPropertyPathInstance() // https://github.com/symfony/symfony/issues/5494 public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -418,7 +418,7 @@ public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable() public function testCreateViewAttrAsPropertyPath() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -442,7 +442,7 @@ public function testCreateViewAttrAsPropertyPath() */ public function testCreateViewAttrAsPropertyPathWithCallableString() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -461,7 +461,7 @@ public function testCreateViewAttrAsPropertyPathWithCallableString() public function testCreateViewAttrAsPropertyPathInstance() { - $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php index 073913f803c99..824b2f3229b47 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php @@ -38,8 +38,8 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->loadedList = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); - $this->loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $this->loadedList = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $this->loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $this->value = function () {}; $this->list = new LazyChoiceList($this->loader, $this->value); } diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index bfe716680c3fd..3e71a83ea0028 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -877,7 +877,7 @@ public function testGetErrorsDeepRecursive() // Basic cases are covered in SimpleFormTest public function testCreateViewWithChildren() { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $options = array('a' => 'Foo', 'b' => 'Bar'); $field1 = $this->getMockForm('foo'); $field2 = $this->getMockForm('bar'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php index 0597de74e2148..3385c05dc4be3 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php @@ -34,8 +34,8 @@ class PropertyPathMapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->propertyAccessor = $this->getMock('Symfony\Component\PropertyAccess\PropertyAccessorInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->propertyAccessor = $this->getMockBuilder('Symfony\Component\PropertyAccess\PropertyAccessorInterface')->getMock(); $this->mapper = new PropertyPathMapper($this->propertyAccessor); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php index 7eb716b6d3d49..ac61acc4e64fb 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php @@ -19,11 +19,7 @@ class BaseDateTimeTransformerTest extends \PHPUnit_Framework_TestCase */ public function testConstructFailsIfInputTimezoneIsInvalid() { - $this->getMock( - 'Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer', - array(), - array('this_timezone_does_not_exist') - ); + $this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer')->setConstructorArgs(array('this_timezone_does_not_exist'))->getMock(); } /** @@ -32,10 +28,6 @@ public function testConstructFailsIfInputTimezoneIsInvalid() */ public function testConstructFailsIfOutputTimezoneIsInvalid() { - $this->getMock( - 'Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer', - array(), - array(null, 'that_timezone_does_not_exist') - ); + $this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer')->setConstructorArgs(array(null, 'that_timezone_does_not_exist'))->getMock(); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php index 2ee2f22db075c..9ec553db4bd71 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php @@ -17,12 +17,12 @@ class DataTransformerChainTest extends \PHPUnit_Framework_TestCase { public function testTransform() { - $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); + $transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); $transformer1->expects($this->once()) ->method('transform') ->with($this->identicalTo('foo')) ->will($this->returnValue('bar')); - $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); + $transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); $transformer2->expects($this->once()) ->method('transform') ->with($this->identicalTo('bar')) @@ -35,12 +35,12 @@ public function testTransform() public function testReverseTransform() { - $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); + $transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); $transformer2->expects($this->once()) ->method('reverseTransform') ->with($this->identicalTo('foo')) ->will($this->returnValue('bar')); - $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); + $transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); $transformer1->expects($this->once()) ->method('reverseTransform') ->with($this->identicalTo('bar')) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index b54c0d50ef74f..05453acb7ef00 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -237,6 +237,15 @@ public function testReverseTransformWithDifferentTimezones() $this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('03.02.2010, 04:05')); } + public function testReverseTransformOnlyDateWithDifferentTimezones() + { + $transformer = new DateTimeToLocalizedStringTransformer('Europe/Berlin', 'Pacific/Tahiti', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd'); + + $dateTime = new \DateTime('2017-01-10 11:00', new \DateTimeZone('Europe/Berlin')); + + $this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('2017-01-10')); + } + public function testReverseTransformWithDifferentPatterns() { $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php index c3c9d08463efa..d31de3cadab63 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php @@ -19,7 +19,7 @@ class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase public function testFixHttpUrl() { $data = 'www.symfony.com'; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $filter = new FixUrlProtocolListener('http'); @@ -31,7 +31,7 @@ public function testFixHttpUrl() public function testSkipKnownUrl() { $data = 'http://www.symfony.com'; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $filter = new FixUrlProtocolListener('http'); @@ -56,7 +56,7 @@ public function provideUrlsWithSupportedProtocols() */ public function testSkipOtherProtocol($url) { - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $url); $filter = new FixUrlProtocolListener('http'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php index 2d7ecfec75571..ddd46819a4f0c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php @@ -22,8 +22,8 @@ abstract class MergeCollectionListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $this->form = $this->getForm('axes'); } @@ -45,7 +45,7 @@ protected function getForm($name = 'name', $propertyPath = null) protected function getMockForm() { - return $this->getMock('Symfony\Component\Form\Test\FormInterface'); + return $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); } public function getBooleanMatrix1() diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php index e4959a3c95a83..52afec76013ea 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php @@ -24,8 +24,8 @@ class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $this->form = $this->getBuilder() ->setCompound(true) ->setDataMapper($this->getDataMapper()) @@ -54,12 +54,12 @@ protected function getForm($name = 'name') */ private function getDataMapper() { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); + return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); } protected function getMockForm() { - return $this->getMock('Symfony\Component\Form\Test\FormInterface'); + return $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); } public function testPreSetDataResizesForm() diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php index 959eb928d20eb..b60365cacf63e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php @@ -19,7 +19,7 @@ class TrimListenerTest extends \PHPUnit_Framework_TestCase public function testTrim() { $data = ' Foo! '; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $filter = new TrimListener(); @@ -31,7 +31,7 @@ public function testTrim() public function testTrimSkipNonStrings() { $data = 1234; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $filter = new TrimListener(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php index 4904b679dda9d..356d1c808c1cc 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php @@ -25,9 +25,9 @@ class CsrfValidationListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->tokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); $this->form = $this->getBuilder('post') ->setDataMapper($this->getDataMapper()) ->getForm(); @@ -53,12 +53,12 @@ protected function getForm($name = 'name') protected function getDataMapper() { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); + return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); } protected function getMockForm() { - return $this->getMock('Symfony\Component\Form\Test\FormInterface'); + return $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); } // https://github.com/symfony/symfony/pull/5838 diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php index 3a34394070919..0e7261cc2e3c2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -42,8 +42,8 @@ class FormTypeCsrfExtensionTest extends TypeTestCase protected function setUp() { - $this->tokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); - $this->translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); + $this->tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); + $this->translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); parent::setUp(); } diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php index da34d4a975bb4..7c44eb7a0bd7c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php @@ -27,7 +27,7 @@ class DataCollectorExtensionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dataCollector = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface'); + $this->dataCollector = $this->getMockBuilder('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface')->getMock(); $this->extension = new DataCollectorExtension($this->dataCollector); } diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php index f6fa2493d55c7..f76b19e4b6efe 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php @@ -65,11 +65,11 @@ class FormDataCollectorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dataExtractor = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataExtractorInterface'); + $this->dataExtractor = $this->getMockBuilder('Symfony\Component\Form\Extension\DataCollector\FormDataExtractorInterface')->getMock(); $this->dataCollector = new FormDataCollector($this->dataExtractor); - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->dataMapper = $this->getMock('Symfony\Component\Form\DataMapperInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->dataMapper = $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); $this->form = $this->createForm('name'); $this->childForm = $this->createForm('child'); $this->view = new FormView(); diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php index 690e4bd1f606a..c05175a0073a6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php @@ -60,13 +60,13 @@ protected function setUp() { $this->valueExporter = new FormDataExtractorTest_SimpleValueExporter(); $this->dataExtractor = new FormDataExtractor($this->valueExporter); - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); } public function testExtractConfiguration() { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') ->will($this->returnValue(new \stdClass())); @@ -87,7 +87,7 @@ public function testExtractConfiguration() public function testExtractConfigurationSortsPassedOptions() { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') ->will($this->returnValue(new \stdClass())); @@ -121,7 +121,7 @@ public function testExtractConfigurationSortsPassedOptions() public function testExtractConfigurationSortsResolvedOptions() { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') ->will($this->returnValue(new \stdClass())); @@ -152,18 +152,18 @@ public function testExtractConfigurationSortsResolvedOptions() public function testExtractConfigurationBuildsIdRecursively() { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') ->will($this->returnValue(new \stdClass())); $grandParent = $this->createBuilder('grandParent') ->setCompound(true) - ->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')) + ->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock()) ->getForm(); $parent = $this->createBuilder('parent') ->setCompound(true) - ->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')) + ->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock()) ->getForm(); $form = $this->createBuilder('name') ->setType($type) diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php index 9c53387ce3c0a..abe98e29b10e9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php @@ -27,7 +27,7 @@ class DataCollectorTypeExtensionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dataCollector = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface'); + $this->dataCollector = $this->getMockBuilder('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface')->getMock(); $this->extension = new DataCollectorTypeExtension($this->dataCollector); } @@ -38,7 +38,7 @@ public function testGetExtendedType() public function testBuildForm() { - $builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface'); + $builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock(); $builder->expects($this->atLeastOnce()) ->method('addEventSubscriber') ->with($this->isInstanceOf('Symfony\Component\Form\Extension\DataCollector\EventListener\DataCollectorListener')); diff --git a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php index 77fb370d73e0b..cfb7fadfa26c8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php @@ -18,17 +18,17 @@ class DependencyInjectionExtensionTest extends \PHPUnit_Framework_TestCase { public function testGetTypeExtensions() { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - $typeExtension1 = $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface'); + $typeExtension1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeExtensionInterface')->getMock(); $typeExtension1->expects($this->any()) ->method('getExtendedType') ->willReturn('test'); - $typeExtension2 = $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface'); + $typeExtension2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeExtensionInterface')->getMock(); $typeExtension2->expects($this->any()) ->method('getExtendedType') ->willReturn('test'); - $typeExtension3 = $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface'); + $typeExtension3 = $this->getMockBuilder('Symfony\Component\Form\FormTypeExtensionInterface')->getMock(); $typeExtension3->expects($this->any()) ->method('getExtendedType') ->willReturn('other'); @@ -61,9 +61,9 @@ public function testGetTypeExtensions() */ public function testThrowExceptionForInvalidExtendedType() { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - $typeExtension = $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface'); + $typeExtension = $this->getMockBuilder('Symfony\Component\Form\FormTypeExtensionInterface')->getMock(); $typeExtension->expects($this->any()) ->method('getExtendedType') ->willReturn('unmatched'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index abc6597bc1d82..5cdcb2035bf4a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -18,6 +18,7 @@ use Symfony\Component\Form\Extension\Validator\Constraints\Form; use Symfony\Component\Form\Extension\Validator\Constraints\FormValidator; use Symfony\Component\Form\SubmitButtonBuilder; +use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Valid; @@ -45,12 +46,9 @@ class FormValidatorTest extends AbstractConstraintValidatorTest protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->serverParams = $this->getMock( - 'Symfony\Component\Form\Extension\Validator\Util\ServerParams', - array('getNormalizedIniPostMaxSize', 'getContentLength') - ); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->serverParams = $this->getMockBuilder('Symfony\Component\Form\Extension\Validator\Util\ServerParams')->setMethods(array('getNormalizedIniPostMaxSize', 'getContentLength'))->getMock(); parent::setUp(); } @@ -62,14 +60,13 @@ protected function createValidator() public function testValidate() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $options = array('validation_groups' => array('group1', 'group2')); $form = $this->getBuilder('name', '\stdClass', $options) ->setData($object) ->getForm(); - $this->expectValidateAt(0, 'data', $object, 'group1'); - $this->expectValidateAt(1, 'data', $object, 'group2'); + $this->expectValidateAt(0, 'data', $object, array('group1', 'group2')); $this->validator->validate($form, new Form()); @@ -78,7 +75,7 @@ public function testValidate() public function testValidateConstraints() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $constraint1 = new NotNull(array('groups' => array('group1', 'group2'))); $constraint2 = new NotBlank(array('groups' => 'group2')); @@ -91,12 +88,11 @@ public function testValidateConstraints() ->getForm(); // First default constraints - $this->expectValidateAt(0, 'data', $object, 'group1'); - $this->expectValidateAt(1, 'data', $object, 'group2'); + $this->expectValidateAt(0, 'data', $object, array('group1', 'group2')); // Then custom constraints - $this->expectValidateValueAt(2, 'data', $object, $constraint1, 'group1'); - $this->expectValidateValueAt(3, 'data', $object, $constraint2, 'group2'); + $this->expectValidateValueAt(1, 'data', $object, $constraint1, 'group1'); + $this->expectValidateValueAt(2, 'data', $object, $constraint2, 'group2'); $this->validator->validate($form, new Form()); @@ -105,7 +101,7 @@ public function testValidateConstraints() public function testValidateChildIfValidConstraint() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent') ->setCompound(true) @@ -129,7 +125,7 @@ public function testValidateChildIfValidConstraint() public function testDontValidateIfParentWithoutValidConstraint() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent', null) ->setCompound(true) @@ -154,7 +150,7 @@ public function testMissingConstraintIndex() $form = new FormBuilder('name', '\stdClass', $this->dispatcher, $this->factory); $form = $form->setData($object)->getForm(); - $this->expectValidateAt(0, 'data', $object, 'Default'); + $this->expectValidateAt(0, 'data', $object, array('Default')); $this->validator->validate($form, new Form()); @@ -163,7 +159,7 @@ public function testMissingConstraintIndex() public function testValidateConstraintsOptionEvenIfNoValidConstraint() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $constraint1 = new NotNull(array('groups' => array('group1', 'group2'))); $constraint2 = new NotBlank(array('groups' => 'group2')); @@ -190,7 +186,7 @@ public function testValidateConstraintsOptionEvenIfNoValidConstraint() public function testDontValidateIfNoValidationGroups() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $form = $this->getBuilder('name', '\stdClass', array( 'validation_groups' => array(), @@ -209,9 +205,9 @@ public function testDontValidateIfNoValidationGroups() public function testDontValidateConstraintsIfNoValidationGroups() { - $object = $this->getMock('\stdClass'); - $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint'); - $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint'); + $object = $this->getMockBuilder('\stdClass')->getMock(); + $constraint1 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock(); + $constraint2 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock(); $options = array( 'validation_groups' => array(), @@ -233,7 +229,7 @@ public function testDontValidateConstraintsIfNoValidationGroups() public function testDontValidateIfNotSynchronized() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $form = $this->getBuilder('name', '\stdClass', array( 'invalid_message' => 'invalid_message_key', @@ -267,7 +263,7 @@ function () { throw new TransformationFailedException(); } public function testAddInvalidErrorEvenIfNoValidationGroups() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $form = $this->getBuilder('name', '\stdClass', array( 'invalid_message' => 'invalid_message_key', @@ -302,9 +298,9 @@ function () { throw new TransformationFailedException(); } public function testDontValidateConstraintsIfNotSynchronized() { - $object = $this->getMock('\stdClass'); - $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint'); - $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint'); + $object = $this->getMockBuilder('\stdClass')->getMock(); + $constraint1 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock(); + $constraint2 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock(); $options = array( 'invalid_message' => 'invalid_message_key', @@ -337,7 +333,7 @@ function () { throw new TransformationFailedException(); } // https://github.com/symfony/symfony/issues/4359 public function testDontMarkInvalidIfAnyChildIsNotSynchronized() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $failingTransformer = new CallbackTransformer( function ($data) { return $data; }, @@ -365,16 +361,30 @@ function () { throw new TransformationFailedException(); } $this->assertNoViolation(); } + public function testHandleGroupSequenceValidationGroups() + { + $object = $this->getMockBuilder('\stdClass')->getMock(); + $options = array('validation_groups' => new GroupSequence(array('group1', 'group2'))); + $form = $this->getBuilder('name', '\stdClass', $options) + ->setData($object) + ->getForm(); + + $this->expectValidateAt(0, 'data', $object, new GroupSequence(array('group1', 'group2'))); + + $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); + } + public function testHandleCallbackValidationGroups() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $options = array('validation_groups' => array($this, 'getValidationGroups')); $form = $this->getBuilder('name', '\stdClass', $options) ->setData($object) ->getForm(); - $this->expectValidateAt(0, 'data', $object, 'group1'); - $this->expectValidateAt(1, 'data', $object, 'group2'); + $this->expectValidateAt(0, 'data', $object, array('group1', 'group2')); $this->validator->validate($form, new Form()); @@ -383,13 +393,13 @@ public function testHandleCallbackValidationGroups() public function testDontExecuteFunctionNames() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $options = array('validation_groups' => 'header'); $form = $this->getBuilder('name', '\stdClass', $options) ->setData($object) ->getForm(); - $this->expectValidateAt(0, 'data', $object, 'header'); + $this->expectValidateAt(0, 'data', $object, array('header')); $this->validator->validate($form, new Form()); @@ -398,7 +408,7 @@ public function testDontExecuteFunctionNames() public function testHandleClosureValidationGroups() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $options = array('validation_groups' => function (FormInterface $form) { return array('group1', 'group2'); }); @@ -406,8 +416,7 @@ public function testHandleClosureValidationGroups() ->setData($object) ->getForm(); - $this->expectValidateAt(0, 'data', $object, 'group1'); - $this->expectValidateAt(1, 'data', $object, 'group2'); + $this->expectValidateAt(0, 'data', $object, array('group1', 'group2')); $this->validator->validate($form, new Form()); @@ -416,7 +425,7 @@ public function testHandleClosureValidationGroups() public function testUseValidationGroupOfClickedButton() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent') ->setCompound(true) @@ -443,7 +452,7 @@ public function testUseValidationGroupOfClickedButton() public function testDontUseValidationGroupOfUnclickedButton() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent') ->setCompound(true) @@ -470,7 +479,7 @@ public function testDontUseValidationGroupOfUnclickedButton() public function testUseInheritedValidationGroup() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parentOptions = array('validation_groups' => 'group'); $parent = $this->getBuilder('parent', null, $parentOptions) @@ -492,7 +501,7 @@ public function testUseInheritedValidationGroup() public function testUseInheritedCallbackValidationGroup() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parentOptions = array('validation_groups' => array($this, 'getValidationGroups')); $parent = $this->getBuilder('parent', null, $parentOptions) @@ -514,7 +523,7 @@ public function testUseInheritedCallbackValidationGroup() public function testUseInheritedClosureValidationGroup() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parentOptions = array( 'validation_groups' => function (FormInterface $form) { @@ -540,12 +549,12 @@ public function testUseInheritedClosureValidationGroup() public function testAppendPropertyPath() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $form = $this->getBuilder('name', '\stdClass') ->setData($object) ->getForm(); - $this->expectValidateAt(0, 'data', $object, 'Default'); + $this->expectValidateAt(0, 'data', $object, array('Default')); $this->validator->validate($form, new Form()); @@ -618,9 +627,9 @@ public function getValidationGroups(FormInterface $form) private function getMockExecutionContext() { - $context = $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface'); - $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); - $contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface'); + $context = $this->getMockBuilder('Symfony\Component\Validator\Context\ExecutionContextInterface')->getMock(); + $validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); + $contextualValidator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock(); $validator->expects($this->any()) ->method('inContext') @@ -668,6 +677,6 @@ private function getSubmitButton($name = 'name', array $options = array()) */ private function getDataMapper() { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); + return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php index 6859074c953cb..499ff4e9cec05 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php @@ -54,10 +54,10 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); - $this->violationMapper = $this->getMock('Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); + $this->violationMapper = $this->getMockBuilder('Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface')->getMock(); $this->listener = new ValidationListener($this->validator, $this->violationMapper); $this->message = 'Message'; $this->messageTemplate = 'Message template'; @@ -87,7 +87,7 @@ private function getForm($name = 'name', $propertyPath = null, $dataClass = null private function getMockForm() { - return $this->getMock('Symfony\Component\Form\Test\FormInterface'); + return $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); } // More specific mapping tests can be found in ViolationMapperTest @@ -161,7 +161,7 @@ public function testValidateWithEmptyViolationList() public function testValidatorInterface() { - $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); + $validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); $listener = new ValidationListener($validator, $this->violationMapper); $this->assertAttributeSame($validator, 'validator', $listener); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php index 01f20c4127cf1..f12b915b9a378 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Form\Tests\Extension\Validator\Type; use Symfony\Component\Form\Test\FormInterface; +use Symfony\Component\Validator\Constraints\GroupSequence; /** * @author Bernhard Schussek @@ -70,5 +71,14 @@ public function testValidationGroupsCanBeSetToClosure() $this->assertInternalType('callable', $form->getConfig()->getOption('validation_groups')); } + public function testValidationGroupsCanBeSetToGroupSequence() + { + $form = $this->createForm(array( + 'validation_groups' => new GroupSequence(array('group1', 'group2')), + )); + + $this->assertInstanceOf('Symfony\Component\Validator\Constraints\GroupSequence', $form->getConfig()->getOption('validation_groups')); + } + abstract protected function createForm(array $options = array()); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php index 9f920003c51f2..2bf10bb36bce2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php @@ -47,7 +47,7 @@ public function testValidConstraint() public function testValidatorInterface() { - $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); + $validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); $formTypeValidatorExtension = new FormTypeValidatorExtension($validator); $this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php index 19b6c1ca0c592..663cdd03395d0 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php @@ -20,7 +20,7 @@ abstract class TypeTestCase extends BaseTypeTestCase protected function setUp() { - $this->validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); + $this->validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $this->validator->expects($this->once())->method('getMetadataFor')->will($this->returnValue($metadata)); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php index dbe13a27456f6..8c0984f7e4e13 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php @@ -19,7 +19,7 @@ class UploadValidatorExtensionTest extends TypeTestCase { public function testPostMaxSizeTranslation() { - $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); + $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); $translator->expects($this->any()) ->method('trans') diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php index 957b59702e0d2..3627f4b9e6c6b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php @@ -31,7 +31,7 @@ public function testGetContentLengthFromSuperglobals() public function testGetContentLengthFromRequest() { $request = Request::create('http://foo', 'GET', array(), array(), array(), array('CONTENT_LENGTH' => 1024)); - $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('getCurrentRequest')); + $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(array('getCurrentRequest'))->getMock(); $requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request)); $serverParams = new ServerParams($requestStack); @@ -41,7 +41,7 @@ public function testGetContentLengthFromRequest() /** @dataProvider getGetPostMaxSizeTestData */ public function testGetPostMaxSize($size, $bytes) { - $serverParams = $this->getMock('Symfony\Component\Form\Extension\Validator\Util\ServerParams', array('getNormalizedIniPostMaxSize')); + $serverParams = $this->getMockBuilder('Symfony\Component\Form\Extension\Validator\Util\ServerParams')->setMethods(array('getNormalizedIniPostMaxSize'))->getMock(); $serverParams ->expects($this->any()) ->method('getNormalizedIniPostMaxSize') diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php index a5e1cb10da508..ba5f0cd51cb18 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php @@ -51,7 +51,7 @@ class ValidatorTypeGuesserTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->metadata = new ClassMetadata(self::TEST_CLASS); - $this->metadataFactory = $this->getMock('Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface'); + $this->metadataFactory = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface')->getMock(); $this->metadataFactory->expects($this->any()) ->method('getMetadataFor') ->with(self::TEST_CLASS) diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php index 74da4aee1c281..314a645dbcc3a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -62,7 +62,7 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $this->mapper = new ViolationMapper(); $this->message = 'Message'; $this->messageTemplate = 'Message template'; @@ -95,7 +95,7 @@ function () { throw new TransformationFailedException(); } */ private function getDataMapper() { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); + return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); } /** diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index 86f50b50ecee0..d8e490a674337 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -23,8 +23,8 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $this->builder = new FormBuilder('name', null, $this->dispatcher, $this->factory); } @@ -120,7 +120,7 @@ public function testMaintainOrderOfLazyAndExplicitChildren() public function testAddFormType() { $this->assertFalse($this->builder->has('foo')); - $this->builder->add('foo', $this->getMock('Symfony\Component\Form\FormTypeInterface')); + $this->builder->add('foo', $this->getMockBuilder('Symfony\Component\Form\FormTypeInterface')->getMock()); $this->assertTrue($this->builder->has('foo')); } diff --git a/src/Symfony/Component/Form/Tests/FormConfigTest.php b/src/Symfony/Component/Form/Tests/FormConfigTest.php index b77632c5055fb..1bfaf4d0e0bd8 100644 --- a/src/Symfony/Component/Form/Tests/FormConfigTest.php +++ b/src/Symfony/Component/Form/Tests/FormConfigTest.php @@ -71,7 +71,7 @@ public function getHtml4Ids() */ public function testNameAcceptsOnlyNamesValidAsIdsInHtml4($name, $accepted) { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); try { new FormConfigBuilder($name, null, $dispatcher); @@ -141,7 +141,7 @@ public function testSetMethodDoesNotAllowOtherValues() private function getConfigBuilder($name = 'name') { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); return new FormConfigBuilder($name, null, $dispatcher); } diff --git a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php index 9d5cb472ab33b..8a26932cf6741 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php @@ -26,7 +26,7 @@ protected function setUp() $this->registry = $factory->getProperty('registry'); $this->registry->setAccessible(true); - $this->guesser = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); + $this->guesser = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); $this->type = new FooType(); } diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php index 22e8884213b0e..27b5e20252641 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -54,11 +54,11 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resolvedTypeFactory = $this->getMock('Symfony\Component\Form\ResolvedFormTypeFactoryInterface'); - $this->guesser1 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); - $this->guesser2 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); - $this->registry = $this->getMock('Symfony\Component\Form\FormRegistryInterface'); - $this->builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface'); + $this->resolvedTypeFactory = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeFactoryInterface')->getMock(); + $this->guesser1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); + $this->guesser2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); + $this->registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock(); + $this->builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock(); $this->factory = new FormFactory($this->registry, $this->resolvedTypeFactory); $this->registry->expects($this->any()) @@ -241,7 +241,7 @@ public function testCreateNamed() public function testCreateBuilderForPropertyWithoutTypeGuesser() { - $registry = $this->getMock('Symfony\Component\Form\FormRegistryInterface'); + $registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock(); $factory = $this->getMockBuilder('Symfony\Component\Form\FormFactory') ->setMethods(array('createNamedBuilder')) ->setConstructorArgs(array($registry, $this->resolvedTypeFactory)) @@ -480,6 +480,6 @@ private function getMockFactory(array $methods = array()) private function getMockResolvedType() { - return $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + return $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); } } diff --git a/src/Symfony/Component/Form/Tests/FormRegistryTest.php b/src/Symfony/Component/Form/Tests/FormRegistryTest.php index cf3cfdc3918ce..84600ef027eed 100644 --- a/src/Symfony/Component/Form/Tests/FormRegistryTest.php +++ b/src/Symfony/Component/Form/Tests/FormRegistryTest.php @@ -58,9 +58,9 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resolvedTypeFactory = $this->getMock('Symfony\Component\Form\ResolvedFormTypeFactory'); - $this->guesser1 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); - $this->guesser2 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); + $this->resolvedTypeFactory = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeFactory')->getMock(); + $this->guesser1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); + $this->guesser2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); $this->extension1 = new TestExtension($this->guesser1); $this->extension2 = new TestExtension($this->guesser2); $this->registry = new FormRegistry(array( @@ -200,7 +200,7 @@ public function testGetTypeGuesser() $this->assertEquals($expectedGuesser, $this->registry->getTypeGuesser()); $registry = new FormRegistry( - array($this->getMock('Symfony\Component\Form\FormExtensionInterface')), + array($this->getMockBuilder('Symfony\Component\Form\FormExtensionInterface')->getMock()), $this->resolvedTypeFactory ); diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 15025e98b5a48..5ab148cf0f06f 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -69,9 +69,9 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->dataMapper = $this->getMock('Symfony\Component\Form\DataMapperInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->dataMapper = $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); $this->parentType = $this->getMockFormType(); $this->type = $this->getMockFormType(); $this->extension1 = $this->getMockFormTypeExtension(); @@ -125,7 +125,7 @@ public function testCreateBuilder() { $givenOptions = array('a' => 'a_custom', 'c' => 'c_custom'); $resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default'); - $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolver'); + $optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolver')->getMock(); $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) @@ -153,7 +153,7 @@ public function testCreateBuilderWithDataClassOption() { $givenOptions = array('data_class' => 'Foo'); $resolvedOptions = array('data_class' => '\stdClass'); - $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolver'); + $optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolver')->getMock(); $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) @@ -190,7 +190,7 @@ public function testBuildForm() }; $options = array('a' => 'Foo', 'b' => 'Bar'); - $builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface'); + $builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock(); // First the form is built for the super type $this->parentType->expects($this->once()) @@ -220,7 +220,7 @@ public function testBuildForm() public function testCreateView() { - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $view = $this->resolvedType->createView($form); @@ -230,8 +230,8 @@ public function testCreateView() public function testCreateViewWithParent() { - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $parentView = $this->getMock('Symfony\Component\Form\FormView'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); + $parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $view = $this->resolvedType->createView($form, $parentView); @@ -242,8 +242,8 @@ public function testCreateViewWithParent() public function testBuildView() { $options = array('a' => '1', 'b' => '2'); - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); + $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $i = 0; @@ -284,8 +284,8 @@ public function testBuildView() public function testFinishView() { $options = array('a' => '1', 'b' => '2'); - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); + $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $i = 0; @@ -361,7 +361,7 @@ public function provideTypeClassBlockPrefixTuples() */ private function getMockFormType($typeClass = 'Symfony\Component\Form\AbstractType') { - return $this->getMock($typeClass, array('getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm')); + return $this->getMockBuilder($typeClass)->setMethods(array('getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm'))->getMock(); } /** @@ -369,7 +369,7 @@ private function getMockFormType($typeClass = 'Symfony\Component\Form\AbstractTy */ private function getMockFormTypeExtension() { - return $this->getMock('Symfony\Component\Form\AbstractTypeExtension', array('getExtendedType', 'configureOptions', 'finishView', 'buildView', 'buildForm')); + return $this->getMockBuilder('Symfony\Component\Form\AbstractTypeExtension')->setMethods(array('getExtendedType', 'configureOptions', 'finishView', 'buildView', 'buildForm'))->getMock(); } /** @@ -377,7 +377,7 @@ private function getMockFormTypeExtension() */ private function getMockFormFactory() { - return $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + return $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); } /** diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 1af99de54ce7a..d5450e1f9e13e 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -684,8 +684,8 @@ public function testSubmitResetsErrors() public function testCreateView() { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); + $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $form = $this->getBuilder()->setType($type)->getForm(); $type->expects($this->once()) @@ -698,10 +698,10 @@ public function testCreateView() public function testCreateViewWithParent() { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); - $parentForm = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $parentView = $this->getMock('Symfony\Component\Form\FormView'); + $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); + $parentForm = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); + $parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $form = $this->getBuilder()->setType($type)->getForm(); $form->setParent($parentForm); @@ -719,9 +719,9 @@ public function testCreateViewWithParent() public function testCreateViewWithExplicitParent() { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); - $parentView = $this->getMock('Symfony\Component\Form\FormView'); + $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); + $parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $form = $this->getBuilder()->setType($type)->getForm(); $type->expects($this->once()) @@ -846,7 +846,7 @@ public function testViewDataMayBeObjectIfDataClassIsNull() public function testViewDataMayBeArrayAccessIfDataClassIsNull() { - $arrayAccess = $this->getMock('\ArrayAccess'); + $arrayAccess = $this->getMockBuilder('\ArrayAccess')->getMock(); $config = new FormConfigBuilder('name', null, $this->dispatcher); $config->addViewTransformer(new FixedDataTransformer(array( '' => '', @@ -908,7 +908,7 @@ public function testSubmittingWrongDataIsIgnored() public function testHandleRequestForwardsToRequestHandler() { - $handler = $this->getMock('Symfony\Component\Form\RequestHandlerInterface'); + $handler = $this->getMockBuilder('Symfony\Component\Form\RequestHandlerInterface')->getMock(); $form = $this->getBuilder() ->setRequestHandler($handler) @@ -1019,7 +1019,7 @@ public function testSubmitIsNeverFiredIfInheritData() public function testInitializeSetsDefaultData() { $config = $this->getBuilder()->setData('DEFAULT')->getFormConfig(); - $form = $this->getMock('Symfony\Component\Form\Form', array('setData'), array($config)); + $form = $this->getMockBuilder('Symfony\Component\Form\Form')->setMethods(array('setData'))->setConstructorArgs(array($config))->getMock(); $form->expects($this->once()) ->method('setData') diff --git a/src/Symfony/Component/HttpFoundation/AcceptHeader.php b/src/Symfony/Component/HttpFoundation/AcceptHeader.php index 226078763ec2c..2aa91dc44cb47 100644 --- a/src/Symfony/Component/HttpFoundation/AcceptHeader.php +++ b/src/Symfony/Component/HttpFoundation/AcceptHeader.php @@ -48,7 +48,7 @@ public function __construct(array $items) * * @param string $headerValue * - * @return AcceptHeader + * @return self */ public static function fromString($headerValue) { @@ -101,7 +101,7 @@ public function get($value) * * @param AcceptHeaderItem $item * - * @return AcceptHeader + * @return $this */ public function add(AcceptHeaderItem $item) { @@ -128,7 +128,7 @@ public function all() * * @param string $pattern * - * @return AcceptHeader + * @return self */ public function filter($pattern) { diff --git a/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php b/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php index 21a5d155f5ab8..fb54b4935a9f3 100644 --- a/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php +++ b/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php @@ -57,7 +57,7 @@ public function __construct($value, array $attributes = array()) * * @param string $itemValue * - * @return AcceptHeaderItem + * @return self */ public static function fromString($itemValue) { @@ -103,7 +103,7 @@ public function __toString() * * @param string $value * - * @return AcceptHeaderItem + * @return $this */ public function setValue($value) { @@ -127,7 +127,7 @@ public function getValue() * * @param float $quality * - * @return AcceptHeaderItem + * @return $this */ public function setQuality($quality) { @@ -151,7 +151,7 @@ public function getQuality() * * @param int $index * - * @return AcceptHeaderItem + * @return $this */ public function setIndex($index) { @@ -211,7 +211,7 @@ public function getAttributes() * @param string $name * @param string $value * - * @return AcceptHeaderItem + * @return $this */ public function setAttribute($name, $value) { diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index f95d90c364051..825c78fedeb30 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -66,7 +66,7 @@ public function __construct($file, $status = 200, $headers = array(), $public = * @param bool $autoEtag Whether the ETag header should be automatically set * @param bool $autoLastModified Whether the Last-Modified header should be automatically set * - * @return BinaryFileResponse The created response + * @return static */ public static function create($file = null, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) { @@ -81,7 +81,7 @@ public static function create($file = null, $status = 200, $headers = array(), $ * @param bool $autoEtag * @param bool $autoLastModified * - * @return BinaryFileResponse + * @return $this * * @throws FileException */ @@ -153,7 +153,7 @@ public function setAutoEtag() * @param string $filename Optionally use this filename instead of the real name of the file * @param string $filenameFallback A fallback filename, containing only ASCII characters. Defaults to an automatically encoded filename * - * @return BinaryFileResponse + * @return $this */ public function setContentDisposition($disposition, $filename = '', $filenameFallback = '') { @@ -348,7 +348,7 @@ public static function trustXSendfileTypeHeader() * * @param bool $shouldDelete * - * @return BinaryFileResponse + * @return $this */ public function deleteFileAfterSend($shouldDelete) { diff --git a/src/Symfony/Component/HttpFoundation/Cookie.php b/src/Symfony/Component/HttpFoundation/Cookie.php index 67e20dd5019fb..c714376afd205 100644 --- a/src/Symfony/Component/HttpFoundation/Cookie.php +++ b/src/Symfony/Component/HttpFoundation/Cookie.php @@ -58,7 +58,7 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom } elseif (!is_numeric($expire)) { $expire = strtotime($expire); - if (false === $expire || -1 === $expire) { + if (false === $expire) { throw new \InvalidArgumentException('The cookie expiration time is not valid.'); } } @@ -66,7 +66,7 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom $this->name = $name; $this->value = $value; $this->domain = $domain; - $this->expire = $expire; + $this->expire = 0 < $expire ? (int) $expire : 0; $this->path = empty($path) ? '/' : $path; $this->secure = (bool) $secure; $this->httpOnly = (bool) $httpOnly; @@ -80,20 +80,20 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom */ public function __toString() { - $str = urlencode($this->getName()).'='; + $str = ($this->isRaw() ? $this->getName() : urlencode($this->getName())).'='; if ('' === (string) $this->getValue()) { $str .= 'deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001); } else { - $str .= urlencode($this->getValue()); + $str .= $this->isRaw() ? $this->getValue() : urlencode($this->getValue()); - if ($this->getExpiresTime() !== 0) { + if (0 !== $this->getExpiresTime()) { $str .= '; expires='.gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime()); } } - if ($this->path) { - $str .= '; path='.$this->path; + if ($this->getPath()) { + $str .= '; path='.$this->getPath(); } if ($this->getDomain()) { @@ -124,7 +124,7 @@ public function getName() /** * Gets the value of the cookie. * - * @return string + * @return string|null */ public function getValue() { @@ -134,7 +134,7 @@ public function getValue() /** * Gets the domain that the cookie is available to. * - * @return string + * @return string|null */ public function getDomain() { diff --git a/src/Symfony/Component/HttpFoundation/File/File.php b/src/Symfony/Component/HttpFoundation/File/File.php index 4736b45c34839..e2a67684fcda6 100644 --- a/src/Symfony/Component/HttpFoundation/File/File.php +++ b/src/Symfony/Component/HttpFoundation/File/File.php @@ -85,7 +85,7 @@ public function getMimeType() * @param string $directory The destination folder * @param string $name The new file name * - * @return File A File object representing the new file + * @return self A File object representing the new file * * @throws FileException if the target file could not be created */ diff --git a/src/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php b/src/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php index ec9b78ab2ad1f..921751f6b5af5 100644 --- a/src/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php +++ b/src/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php @@ -42,7 +42,7 @@ class ExtensionGuesser implements ExtensionGuesserInterface /** * Returns the singleton instance. * - * @return ExtensionGuesser + * @return self */ public static function getInstance() { diff --git a/src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php b/src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php index ecc8a30ac25d1..69c803b4993bc 100644 --- a/src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php +++ b/src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php @@ -56,7 +56,7 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface /** * Returns the singleton instance. * - * @return MimeTypeGuesser + * @return self */ public static function getInstance() { diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index fd0de6cf013c8..533775e85b4f2 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -62,7 +62,7 @@ public function __construct($data = null, $status = 200, $headers = array(), $js * @param int $status The response status code * @param array $headers An array of response headers * - * @return JsonResponse + * @return static */ public static function create($data = null, $status = 200, $headers = array()) { @@ -74,7 +74,7 @@ public static function create($data = null, $status = 200, $headers = array()) * * @param string|null $callback The JSONP callback or null to use none * - * @return JsonResponse + * @return $this * * @throws \InvalidArgumentException When the callback name is not valid */ @@ -109,7 +109,7 @@ public function setCallback($callback = null) * * @param string $json * - * @return JsonResponse + * @return $this * * @throws \InvalidArgumentException */ @@ -125,7 +125,7 @@ public function setJson($json) * * @param mixed $data * - * @return JsonResponse + * @return $this * * @throws \InvalidArgumentException */ @@ -172,7 +172,7 @@ public function getEncodingOptions() * * @param int $encodingOptions * - * @return JsonResponse + * @return $this */ public function setEncodingOptions($encodingOptions) { @@ -184,7 +184,7 @@ public function setEncodingOptions($encodingOptions) /** * Updates the content and headers according to the JSON data and callback. * - * @return JsonResponse + * @return $this */ protected function update() { diff --git a/src/Symfony/Component/HttpFoundation/LICENSE b/src/Symfony/Component/HttpFoundation/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/HttpFoundation/LICENSE +++ b/src/Symfony/Component/HttpFoundation/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/Component/HttpFoundation/RedirectResponse.php b/src/Symfony/Component/HttpFoundation/RedirectResponse.php index 8d2608336afad..5a775ad159f3a 100644 --- a/src/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/src/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -66,7 +66,7 @@ public function getTargetUrl() * * @param string $url The URL to redirect to * - * @return RedirectResponse The current response + * @return $this * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 2cb35c82f521e..00a6251ba9e26 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -261,7 +261,7 @@ public function initialize(array $query = array(), array $request = array(), arr /** * Creates a new request with values from PHP's super globals. * - * @return Request A new request + * @return static */ public static function createFromGlobals() { @@ -304,7 +304,7 @@ public static function createFromGlobals() * @param array $server The server parameters ($_SERVER) * @param string $content The raw body data * - * @return Request A Request instance + * @return static */ public static function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null) { @@ -422,7 +422,7 @@ public static function setFactory($callable) * @param array $files The FILES parameters * @param array $server The SERVER parameters * - * @return Request The duplicated request + * @return static */ public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) { diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 24c52fccc4665..411dcd95d9369 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -215,7 +215,7 @@ public function __construct($content = '', $status = 200, $headers = array()) * @param int $status The response status code * @param array $headers An array of response headers * - * @return Response + * @return static */ public static function create($content = '', $status = 200, $headers = array()) { @@ -258,7 +258,7 @@ public function __clone() * * @param Request $request A Request instance * - * @return Response The current response + * @return $this */ public function prepare(Request $request) { @@ -320,7 +320,7 @@ public function prepare(Request $request) /** * Sends HTTP headers. * - * @return Response + * @return $this */ public function sendHeaders() { @@ -358,7 +358,7 @@ public function sendHeaders() /** * Sends content for the current web response. * - * @return Response + * @return $this */ public function sendContent() { @@ -370,7 +370,7 @@ public function sendContent() /** * Sends HTTP headers and content. * - * @return Response + * @return $this */ public function send() { @@ -393,7 +393,7 @@ public function send() * * @param mixed $content Content that can be cast to string * - * @return Response + * @return $this * * @throws \UnexpectedValueException */ @@ -423,7 +423,7 @@ public function getContent() * * @param string $version The HTTP protocol version * - * @return Response + * @return $this */ public function setProtocolVersion($version) { @@ -451,7 +451,7 @@ public function getProtocolVersion() * If the status text is null it will be automatically populated for the known * status codes and left empty otherwise. * - * @return Response + * @return $this * * @throws \InvalidArgumentException When the HTTP status code is not valid */ @@ -494,7 +494,7 @@ public function getStatusCode() * * @param string $charset Character set * - * @return Response + * @return $this */ public function setCharset($charset) { @@ -567,7 +567,7 @@ public function isValidateable() * * It makes the response ineligible for serving other clients. * - * @return Response + * @return $this */ public function setPrivate() { @@ -582,7 +582,7 @@ public function setPrivate() * * It makes the response eligible for serving other clients. * - * @return Response + * @return $this */ public function setPublic() { @@ -628,7 +628,7 @@ public function getDate() * * @param \DateTime $date A \DateTime instance * - * @return Response + * @return $this */ public function setDate(\DateTime $date) { @@ -655,7 +655,7 @@ public function getAge() /** * Marks the response stale by setting the Age header to be equal to the maximum age of the response. * - * @return Response + * @return $this */ public function expire() { @@ -688,7 +688,7 @@ public function getExpires() * * @param \DateTime|null $date A \DateTime instance or null to remove the header * - * @return Response + * @return $this */ public function setExpires(\DateTime $date = null) { @@ -734,7 +734,7 @@ public function getMaxAge() * * @param int $value Number of seconds * - * @return Response + * @return $this */ public function setMaxAge($value) { @@ -750,7 +750,7 @@ public function setMaxAge($value) * * @param int $value Number of seconds * - * @return Response + * @return $this */ public function setSharedMaxAge($value) { @@ -784,7 +784,7 @@ public function getTtl() * * @param int $seconds Number of seconds * - * @return Response + * @return $this */ public function setTtl($seconds) { @@ -800,7 +800,7 @@ public function setTtl($seconds) * * @param int $seconds Number of seconds * - * @return Response + * @return $this */ public function setClientTtl($seconds) { @@ -828,7 +828,7 @@ public function getLastModified() * * @param \DateTime|null $date A \DateTime instance or null to remove the header * - * @return Response + * @return $this */ public function setLastModified(\DateTime $date = null) { @@ -859,7 +859,7 @@ public function getEtag() * @param string|null $etag The ETag unique identifier or null to remove the header * @param bool $weak Whether you want a weak ETag or not * - * @return Response + * @return $this */ public function setEtag($etag = null, $weak = false) { @@ -883,7 +883,7 @@ public function setEtag($etag = null, $weak = false) * * @param array $options An array of cache options * - * @return Response + * @return $this * * @throws \InvalidArgumentException */ @@ -934,7 +934,7 @@ public function setCache(array $options) * This sets the status, removes the body, and discards any headers * that MUST NOT be included in 304 responses. * - * @return Response + * @return $this * * @see http://tools.ietf.org/html/rfc2616#section-10.3.5 */ @@ -986,7 +986,7 @@ public function getVary() * @param string|array $headers * @param bool $replace Whether to replace the actual value or not (true by default) * - * @return Response + * @return $this */ public function setVary($headers, $replace = true) { diff --git a/src/Symfony/Component/HttpFoundation/StreamedResponse.php b/src/Symfony/Component/HttpFoundation/StreamedResponse.php index b3feb031f4c78..928531309ad0a 100644 --- a/src/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/src/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -55,7 +55,7 @@ public function __construct(callable $callback = null, $status = 200, $headers = * @param int $status The response status code * @param array $headers An array of response headers * - * @return StreamedResponse + * @return static */ public static function create($callback = null, $status = 200, $headers = array()) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index 9134c1570c262..f4263f5d7802d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -52,7 +52,14 @@ public function testInstantiationThrowsExceptionIfCookieNameContainsInvalidChara */ public function testInvalidExpiration() { - $cookie = new Cookie('MyCookie', 'foo', 'bar'); + new Cookie('MyCookie', 'foo', 'bar'); + } + + public function testNegativeExpirationIsNotPossible() + { + $cookie = new Cookie('foo', 'bar', -100); + + $this->assertSame(0, $cookie->getExpiresTime()); } public function testGetValue() @@ -77,6 +84,13 @@ public function testGetExpiresTime() $this->assertEquals(3600, $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date'); } + public function testGetExpiresTimeIsCastToInt() + { + $cookie = new Cookie('foo', 'bar', 3600.9); + + $this->assertSame(3600, $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date as an integer'); + } + public function testConstructorWithDateTime() { $expire = new \DateTime(); @@ -143,21 +157,23 @@ public function testCookieIsCleared() public function testToString() { $cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true); - $this->assertEquals('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure; httponly', $cookie->__toString(), '->__toString() returns string representation of the cookie'); + $this->assertEquals('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure; httponly', (string) $cookie, '->__toString() returns string representation of the cookie'); $cookie = new Cookie('foo', null, 1, '/admin/', '.myfoodomain.com'); - $this->assertEquals('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/admin/; domain=.myfoodomain.com; httponly', $cookie->__toString(), '->__toString() returns string representation of a cleared cookie if value is NULL'); + $this->assertEquals('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/admin/; domain=.myfoodomain.com; httponly', (string) $cookie, '->__toString() returns string representation of a cleared cookie if value is NULL'); $cookie = new Cookie('foo', 'bar', 0, '/', ''); - $this->assertEquals('foo=bar; path=/; httponly', $cookie->__toString()); + $this->assertEquals('foo=bar; path=/; httponly', (string) $cookie); } public function testRawCookie() { - $cookie = new Cookie('foo', 'bar', 3600, '/', '.myfoodomain.com', false, true); + $cookie = new Cookie('foo', 'b a r', 0, '/', null, false, false); $this->assertFalse($cookie->isRaw()); + $this->assertEquals('foo=b+a+r; path=/', (string) $cookie); - $cookie = new Cookie('foo', 'bar', 3600, '/', '.myfoodomain.com', false, true, true); + $cookie = new Cookie('foo', 'b+a+r', 0, '/', null, false, false, true); $this->assertTrue($cookie->isRaw()); + $this->assertEquals('foo=b+a+r; path=/', (string) $cookie); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php index a92f5728846e1..129d99eea43b1 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php @@ -166,7 +166,7 @@ public function testMoveToAnUnexistentDirectory() protected function createMockGuesser($path, $mimeType) { - $guesser = $this->getMock('Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface'); + $guesser = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface')->getMock(); $guesser ->expects($this->once()) ->method('guess') diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php index 8e487d6127ec8..ef91f52af5129 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php @@ -116,11 +116,11 @@ public function testToStringIncludesCookieHeaders() $bag = new ResponseHeaderBag(array()); $bag->setCookie(new Cookie('foo', 'bar')); - $this->assertContains('Set-Cookie: foo=bar; path=/; httponly', explode("\r\n", $bag->__toString())); + $this->assertSetCookieHeader('foo=bar; path=/; httponly', $bag); $bag->clearCookie('foo'); - $this->assertRegExp('#^Set-Cookie: foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; httponly#m', $bag->__toString()); + $this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; httponly', $bag); } public function testClearCookieSecureNotHttpOnly() @@ -129,7 +129,7 @@ public function testClearCookieSecureNotHttpOnly() $bag->clearCookie('foo', '/', null, true, false); - $this->assertRegExp('#^Set-Cookie: foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; secure#m', $bag->__toString()); + $this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; secure', $bag); } public function testReplace() @@ -165,11 +165,10 @@ public function testCookiesWithSameNames() $this->assertCount(4, $bag->getCookies()); - $headers = explode("\r\n", $bag->__toString()); - $this->assertContains('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly', $headers); - $this->assertContains('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly', $headers); - $this->assertContains('Set-Cookie: foo=bar; path=/path/bar; domain=bar.foo; httponly', $headers); - $this->assertContains('Set-Cookie: foo=bar; path=/; httponly', $headers); + $this->assertSetCookieHeader('foo=bar; path=/path/foo; domain=foo.bar; httponly', $bag); + $this->assertSetCookieHeader('foo=bar; path=/path/bar; domain=foo.bar; httponly', $bag); + $this->assertSetCookieHeader('foo=bar; path=/path/bar; domain=bar.foo; httponly', $bag); + $this->assertSetCookieHeader('foo=bar; path=/; httponly', $bag); $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); $this->assertTrue(isset($cookies['foo.bar']['/path/foo']['foo'])); @@ -223,7 +222,7 @@ public function testGetCookiesWithInvalidArgument() { $bag = new ResponseHeaderBag(); - $cookies = $bag->getCookies('invalid_argument'); + $bag->getCookies('invalid_argument'); } /** @@ -294,4 +293,9 @@ public function provideMakeDispositionFail() array('attachment', 'föö.html'), ); } + + private function assertSetCookieHeader($expected, ResponseHeaderBag $actual) + { + $this->assertRegExp('#^Set-Cookie:\s+'.preg_quote($expected, '#').'$#m', str_replace("\r\n", "\n", (string) $actual)); + } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 97674d48fdf55..d73dd3d344c3f 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -442,7 +442,7 @@ public function testSetVary() public function testDefaultContentType() { - $headerMock = $this->getMock('Symfony\Component\HttpFoundation\ResponseHeaderBag', array('set')); + $headerMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->setMethods(array('set'))->getMock(); $headerMock->expects($this->at(0)) ->method('set') ->with('Content-Type', 'text/html'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php index 6745a22455edd..b321a9279c600 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php @@ -35,7 +35,7 @@ protected function setUp() } parent::setUp(); - $this->memcache = $this->getMock('Memcache'); + $this->memcache = $this->getMockBuilder('Memcache')->getMock(); $this->storage = new MemcacheSessionHandler( $this->memcache, array('prefix' => self::PREFIX, 'expiretime' => self::TTL) diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php index bd023ed16579d..2ffd7c15c5f62 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -41,7 +41,7 @@ protected function setUp() $this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower, or 3.0.0b1 or higher'); } - $this->memcached = $this->getMock('Memcached'); + $this->memcached = $this->getMockBuilder('Memcached')->getMock(); $this->storage = new MemcachedSessionHandler( $this->memcached, array('prefix' => self::PREFIX, 'expiretime' => self::TTL) diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index 1f88d00d8fe13..cfc8acebaaf99 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -140,7 +140,7 @@ public function testReadConvertsStreamToString() } $pdo = new MockPdo('pgsql'); - $pdo->prepareResult = $this->getMock('PDOStatement'); + $pdo->prepareResult = $this->getMockBuilder('PDOStatement')->getMock(); $content = 'foobar'; $stream = $this->createStream($content); @@ -161,8 +161,8 @@ public function testReadLockedConvertsStreamToString() } $pdo = new MockPdo('pgsql'); - $selectStmt = $this->getMock('PDOStatement'); - $insertStmt = $this->getMock('PDOStatement'); + $selectStmt = $this->getMockBuilder('PDOStatement')->getMock(); + $insertStmt = $this->getMockBuilder('PDOStatement')->getMock(); $pdo->prepareResult = function ($statement) use ($selectStmt, $insertStmt) { return 0 === strpos($statement, 'INSERT') ? $insertStmt : $selectStmt; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php index 069c887039591..4fbf31aa3ebbd 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php @@ -20,7 +20,7 @@ class WriteCheckSessionHandlerTest extends \PHPUnit_Framework_TestCase { public function test() { - $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); + $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); $wrappedSessionHandlerMock @@ -35,7 +35,7 @@ public function test() public function testWrite() { - $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); + $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); $wrappedSessionHandlerMock @@ -50,7 +50,7 @@ public function testWrite() public function testSkippedWrite() { - $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); + $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); $wrappedSessionHandlerMock @@ -71,7 +71,7 @@ public function testSkippedWrite() public function testNonSkippedWrite() { - $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); + $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); $wrappedSessionHandlerMock diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index bc810a6b209b6..8ed38c90f58df 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -35,7 +35,7 @@ class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mock = $this->getMock('SessionHandlerInterface'); + $this->mock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $this->proxy = new SessionHandlerProxy($this->mock); } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index f274ac79c2c71..ded367b19d58a 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -12,10 +12,8 @@ namespace Symfony\Component\HttpKernel\DataCollector; use Symfony\Component\HttpFoundation\ParameterBag; -use Symfony\Component\HttpFoundation\HeaderBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\ResponseHeaderBag; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; @@ -42,12 +40,8 @@ public function __construct() public function collect(Request $request, Response $response, \Exception $exception = null) { $responseHeaders = $response->headers->all(); - $cookies = array(); foreach ($response->headers->getCookies() as $cookie) { - $cookies[] = $this->getCookieHeader($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); - } - if (count($cookies) > 0) { - $responseHeaders['Set-Cookie'] = $cookies; + $responseHeaders['set-cookie'][] = (string) $cookie; } // attributes are serialized and as they can be anything, they need to be converted to strings. @@ -125,6 +119,18 @@ public function collect(Request $request, Response $response, \Exception $except $this->data['request_request']['_password'] = '******'; } + foreach ($this->data as $key => $value) { + if (!is_array($value)) { + continue; + } + if ('request_headers' === $key || 'response_headers' === $key) { + $value = array_map(function ($v) { return isset($v[0]) && !isset($v[1]) ? $v[0] : $v; }, $value); + } + if ('request_server' !== $key && 'request_cookies' !== $key) { + $this->data[$key] = $value; + } + } + if (isset($this->controllers[$request])) { $this->data['controller'] = $this->parseController($this->controllers[$request]); unset($this->controllers[$request]); @@ -170,7 +176,7 @@ public function getRequestQuery() public function getRequestHeaders() { - return new HeaderBag($this->data['request_headers']); + return new ParameterBag($this->data['request_headers']); } public function getRequestServer() @@ -190,7 +196,7 @@ public function getRequestAttributes() public function getResponseHeaders() { - return new ResponseHeaderBag($this->data['response_headers']); + return new ParameterBag($this->data['response_headers']); } public function getSessionMetadata() @@ -376,41 +382,4 @@ protected function parseController($controller) return is_string($controller) ? $controller : 'n/a'; } - - private function getCookieHeader($name, $value, $expires, $path, $domain, $secure, $httponly) - { - $cookie = sprintf('%s=%s', $name, urlencode($value)); - - if (0 !== $expires) { - if (is_numeric($expires)) { - $expires = (int) $expires; - } elseif ($expires instanceof \DateTime) { - $expires = $expires->getTimestamp(); - } else { - $tmp = strtotime($expires); - if (false === $tmp || -1 == $tmp) { - throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid (%s).', $expires)); - } - $expires = $tmp; - } - - $cookie .= '; expires='.str_replace('+0000', '', \DateTime::createFromFormat('U', $expires, new \DateTimeZone('GMT'))->format('D, d-M-Y H:i:s T')); - } - - if ($domain) { - $cookie .= '; domain='.$domain; - } - - $cookie .= '; path='.$path; - - if ($secure) { - $cookie .= '; secure'; - } - - if ($httponly) { - $cookie .= '; httponly'; - } - - return $cookie; - } } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index a06d4815d44ed..ff4537f788611 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,11 +59,11 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '3.1.8'; - const VERSION_ID = 30108; + const VERSION = '3.1.9'; + const VERSION_ID = 30109; const MAJOR_VERSION = 3; const MINOR_VERSION = 1; - const RELEASE_VERSION = 8; + const RELEASE_VERSION = 9; const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2017'; @@ -498,8 +498,15 @@ protected function initializeContainer() protected function getKernelParameters() { $bundles = array(); + $bundlesMetadata = array(); + foreach ($this->bundles as $name => $bundle) { $bundles[$name] = get_class($bundle); + $bundlesMetadata[$name] = array( + 'parent' => $bundle->getParent(), + 'path' => $bundle->getPath(), + 'namespace' => $bundle->getNamespace(), + ); } return array_merge( @@ -511,6 +518,7 @@ protected function getKernelParameters() 'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(), 'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(), 'kernel.bundles' => $bundles, + 'kernel.bundles_metadata' => $bundlesMetadata, 'kernel.charset' => $this->getCharset(), 'kernel.container_class' => $this->getContainerClass(), ), diff --git a/src/Symfony/Component/HttpKernel/LICENSE b/src/Symfony/Component/HttpKernel/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/HttpKernel/LICENSE +++ b/src/Symfony/Component/HttpKernel/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/Component/HttpKernel/Profiler/Profile.php b/src/Symfony/Component/HttpKernel/Profiler/Profile.php index 1ea045a46f251..18070d0602c06 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/Profile.php +++ b/src/Symfony/Component/HttpKernel/Profiler/Profile.php @@ -76,7 +76,7 @@ public function getToken() /** * Sets the parent token. * - * @param Profile $parent The parent Profile + * @param Profile $parent */ public function setParent(Profile $parent) { @@ -86,7 +86,7 @@ public function setParent(Profile $parent) /** * Returns the parent profile. * - * @return Profile The parent profile + * @return self */ public function getParent() { @@ -191,7 +191,7 @@ public function getStatusCode() /** * Finds children profilers. * - * @return Profile[] An array of Profile + * @return self[] */ public function getChildren() { @@ -201,7 +201,7 @@ public function getChildren() /** * Sets children profiler. * - * @param Profile[] $children An array of Profile + * @param Profile[] $children */ public function setChildren(array $children) { @@ -214,7 +214,7 @@ public function setChildren(array $children) /** * Adds the child token. * - * @param Profile $child The child Profile + * @param Profile $child */ public function addChild(Profile $child) { diff --git a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php index ee0c3128f1a2c..0b11f8253c8b6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php @@ -32,7 +32,7 @@ public function testGetContainerExtension() public function testRegisterCommands() { $cmd = new FooCommand(); - $app = $this->getMock('Symfony\Component\Console\Application'); + $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); $app->expects($this->once())->method('add')->with($this->equalTo($cmd)); $bundle = new ExtensionPresentBundle(); @@ -56,9 +56,9 @@ public function testGetContainerExtensionWithInvalidClass() public function testHttpKernelRegisterCommandsIgnoresCommandsThatAreRegisteredAsServices() { $container = new ContainerBuilder(); - $container->register('console.command.Symfony_Component_HttpKernel_Tests_Fixtures_ExtensionPresentBundle_Command_FooCommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand'); + $container->register('console.command.symfony_component_httpkernel_tests_fixtures_extensionpresentbundle_command_foocommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand'); - $application = $this->getMock('Symfony\Component\Console\Application'); + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); // add() is never called when the found command classes are already registered as services $application->expects($this->never())->method('add'); diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php index b54d169a59988..41af579b06fd5 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php @@ -52,6 +52,6 @@ public function testInjectClearerUsingAdd() protected function getMockClearer() { - return $this->getMock('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface'); + return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock(); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php index b5d2c9cedd893..f12e1e7847881 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php @@ -18,6 +18,9 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpKernel\Tests\Fixtures\TestClient; +/** + * @group time-sensitive + */ class ClientTest extends \PHPUnit_Framework_TestCase { public function testDoRequest() @@ -56,22 +59,38 @@ public function testFilterResponseConvertsCookies() $m = $r->getMethod('filterResponse'); $m->setAccessible(true); - $expected = array( + $expected31 = array( 'foo=bar; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly', 'foo1=bar1; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly', ); + $expected33 = array( + 'foo=bar; expires=Sun, 15-Feb-2009 20:00:00 GMT; max-age='.(strtotime('Sun, 15-Feb-2009 20:00:00 GMT') - time()).'; path=/foo; domain=http://example.com; secure; httponly', + 'foo1=bar1; expires=Sun, 15-Feb-2009 20:00:00 GMT; max-age='.(strtotime('Sun, 15-Feb-2009 20:00:00 GMT') - time()).'; path=/foo; domain=http://example.com; secure; httponly', + ); $response = new Response(); $response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); $domResponse = $m->invoke($client, $response); - $this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie')); + try { + $this->assertEquals($expected31[0], $domResponse->getHeader('Set-Cookie')); + } catch (\PHPUnit_Framework_ExpectationFailedException $e) { + $this->assertEquals($expected33[0], $domResponse->getHeader('Set-Cookie')); + } $response = new Response(); $response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); $response->headers->setCookie(new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); $domResponse = $m->invoke($client, $response); - $this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie')); - $this->assertEquals($expected, $domResponse->getHeader('Set-Cookie', false)); + try { + $this->assertEquals($expected31[0], $domResponse->getHeader('Set-Cookie')); + } catch (\PHPUnit_Framework_ExpectationFailedException $e) { + $this->assertEquals($expected33[0], $domResponse->getHeader('Set-Cookie')); + } + try { + $this->assertEquals($expected31, $domResponse->getHeader('Set-Cookie', false)); + } catch (\PHPUnit_Framework_ExpectationFailedException $e) { + $this->assertEquals($expected33, $domResponse->getHeader('Set-Cookie', false)); + } } public function testFilterResponseSupportsStreamedResponses() diff --git a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php index be59486269e9f..b7babf2c5f631 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php @@ -17,7 +17,7 @@ class FileLocatorTest extends \PHPUnit_Framework_TestCase { public function testLocate() { - $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->atLeastOnce()) ->method('locateResource') @@ -35,7 +35,7 @@ public function testLocate() public function testLocateWithGlobalResourcePath() { - $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->atLeastOnce()) ->method('locateResource') diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php index d89ba605b7646..3be354d794c14 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php @@ -190,7 +190,7 @@ public function testGetVariadicArgumentsWithoutArrayInRequest() public function testGetArgumentWithoutArray() { $factory = new ArgumentMetadataFactory(); - $valueResolver = $this->getMock(ArgumentValueResolverInterface::class); + $valueResolver = $this->getMockBuilder(ArgumentValueResolverInterface::class)->getMock(); $resolver = new ArgumentResolver($factory, array($valueResolver)); $valueResolver->expects($this->any())->method('supports')->willReturn(true); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index 13b496de2009a..afe9261a353f3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -21,7 +21,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase { public function testGetControllerWithoutControllerParameter() { - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing.'); $resolver = $this->createControllerResolver($logger); @@ -219,7 +219,7 @@ public function testGetVariadicArguments() public function testCreateControllerCanReturnAnyCallable() { - $mock = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolver', array('createController')); + $mock = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolver')->setMethods(array('createController'))->getMock(); $mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function')); $request = Request::create('/'); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index 4c1f380d41f8a..451da66216890 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -20,7 +20,7 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase */ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null) { - $logger = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface'); + $logger = $this->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')->getMock(); $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb)); $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs)); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index df5d974fd8c30..8720dca4c97aa 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -36,7 +36,7 @@ public function testCollect() $attributes = $c->getRequestAttributes(); $this->assertSame('request', $c->getName()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag', $c->getRequestHeaders()); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestHeaders()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestServer()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestCookies()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $attributes); @@ -50,7 +50,7 @@ public function testCollect() $this->assertRegExp('/Resource\(stream#\d+\)/', $attributes->get('resource')); $this->assertSame('Object(stdClass)', $attributes->get('object')); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag', $c->getResponseHeaders()); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getResponseHeaders()); $this->assertSame('OK', $c->getStatusText()); $this->assertSame(200, $c->getStatusCode()); $this->assertSame('application/json', $c->getContentType()); @@ -58,7 +58,7 @@ public function testCollect() public function testKernelResponseDoesNotStartSession() { - $kernel = $this->getMock(HttpKernelInterface::class); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $request = new Request(); $session = new Session(new MockArraySessionStorage()); $request->setSession($session); @@ -233,8 +233,8 @@ protected function createResponse() */ protected function injectController($collector, $controller, $request) { - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); - $httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->getMock(ArgumentResolverInterface::class)); + $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); + $httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->getMockBuilder(ArgumentResolverInterface::class)->getMock()); $event = new FilterControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST); $collector->onKernelController($event); } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php index 0bdcccd53d0cb..a07e924d86f29 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -41,7 +41,7 @@ public function testCollect() $c->collect($request, new Response()); $this->assertEquals(0, $c->getStartTime()); - $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456)); $c = new TimeDataCollector($kernel); diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php index d90e9dc11f1fa..51c7d5eaf6ab1 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -110,9 +110,9 @@ public function testListenerCanRemoveItselfWhenExecuted() protected function getHttpKernel($dispatcher, $controller) { - $controllerResolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface'); + $controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock(); $controllerResolver->expects($this->once())->method('getController')->will($this->returnValue($controller)); - $argumentResolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface'); + $argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock(); $argumentResolver->expects($this->once())->method('getArguments')->will($this->returnValue(array())); return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver); diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php index 98266e94005c3..85dad766ed19f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php @@ -30,12 +30,9 @@ public function testContentRendererWithoutInterface() 'my_content_renderer' => array(array('alias' => 'foo')), ); - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); - $builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'getDefinition') - ); + $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock(); $builder->expects($this->any()) ->method('hasDefinition') ->will($this->returnValue(true)); @@ -59,14 +56,14 @@ public function testValidContentRenderer() 'my_content_renderer' => array(array('alias' => 'foo')), ); - $renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $renderer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); $renderer ->expects($this->once()) ->method('addMethodCall') ->with('addRendererService', array('foo', 'my_content_renderer')) ; - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); $definition->expects($this->atLeastOnce()) ->method('getClass') ->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService')); @@ -76,10 +73,7 @@ public function testValidContentRenderer() ->will($this->returnValue(true)) ; - $builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'getDefinition') - ); + $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock(); $builder->expects($this->any()) ->method('hasDefinition') ->will($this->returnValue(true)); diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php index 34bd87a9a9170..12fbf23f9be41 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php @@ -19,14 +19,14 @@ class LazyLoadingFragmentHandlerTest extends \PHPUnit_Framework_TestCase { public function test() { - $renderer = $this->getMock('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface'); + $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); $renderer->expects($this->once())->method('getName')->will($this->returnValue('foo')); $renderer->expects($this->any())->method('render')->will($this->returnValue(new Response())); - $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->once())->method('get')->will($this->returnValue($renderer)); $handler = new LazyLoadingFragmentHandler($container, $requestStack, false); diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php index 895973d7c425b..516813f072de2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php @@ -17,18 +17,8 @@ class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase { public function testAutoloadMainExtension() { - $container = $this->getMock( - 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', - array( - 'getExtensionConfig', - 'loadFromExtension', - 'getParameterBag', - 'getDefinitions', - 'getAliases', - 'getExtensions', - ) - ); - $params = $this->getMock('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag'); + $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')->setMethods(array('getExtensionConfig', 'loadFromExtension', 'getParameterBag', 'getDefinitions', 'getAliases', 'getExtensions'))->getMock(); + $params = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag')->getMock(); $container->expects($this->at(0)) ->method('getExtensionConfig') diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php index 3a82ce0fb6ac7..0f3577cbdb14b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -64,7 +64,7 @@ public function testSetAdditionalFormats() protected function getRequestMock() { - return $this->getMock('Symfony\Component\HttpFoundation\Request'); + return $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); } protected function getGetResponseEventMock(Request $request) diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index 8e1c35b3457d7..2aa284cc71bc2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -36,7 +36,7 @@ class DebugHandlersListenerTest extends \PHPUnit_Framework_TestCase { public function testConfigure() { - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $userHandler = function () {}; $listener = new DebugHandlersListener($userHandler, $logger); $xHandler = new ExceptionHandler(); @@ -70,7 +70,7 @@ public function testConfigureForHttpKernelWithNoTerminateWithException() $listener = new DebugHandlersListener(null); $eHandler = new ErrorHandler(); $event = new KernelEvent( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), Request::create('/'), HttpKernelInterface::MASTER_REQUEST ); @@ -94,7 +94,7 @@ public function testConsoleEvent() { $dispatcher = new EventDispatcher(); $listener = new DebugHandlersListener(null); - $app = $this->getMock('Symfony\Component\Console\Application'); + $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); $app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet())); $command = new Command(__FUNCTION__); $command->setApplication($app); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php index 947af1122850d..94c2557fb1283 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php @@ -105,9 +105,9 @@ public function provider() public function testSubRequestFormat() { - $listener = new ExceptionListener('foo', $this->getMock('Psr\Log\LoggerInterface')); + $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock()); - $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()); })); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php index 7cfce98f2e8f8..b1d7d82c135fd 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php @@ -116,6 +116,6 @@ public function testRemovesPathWithControllerNotDefined() private function createGetResponseEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST) { - return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, $requestType); + return new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, $requestType); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php index a23268ca1de78..46444e660006f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php @@ -22,7 +22,7 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array(), array(), '', false); + $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock(); } public function testDefaultLocaleWithoutSession() @@ -51,10 +51,10 @@ public function testLocaleFromRequestAttribute() public function testLocaleSetForRoutingContext() { // the request context is updated - $context = $this->getMock('Symfony\Component\Routing\RequestContext'); + $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - $router = $this->getMock('Symfony\Component\Routing\Router', array('getContext'), array(), '', false); + $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(array('getContext'))->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); $request = Request::create('/'); @@ -67,10 +67,10 @@ public function testLocaleSetForRoutingContext() public function testRouterResetWithParentRequestOnKernelFinishRequest() { // the request context is updated - $context = $this->getMock('Symfony\Component\Routing\RequestContext'); + $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - $router = $this->getMock('Symfony\Component\Routing\Router', array('getContext'), array(), '', false); + $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(array('getContext'))->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); $parentRequest = Request::create('/'); @@ -78,7 +78,7 @@ public function testRouterResetWithParentRequestOnKernelFinishRequest() $this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\FinishRequestEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')->disableOriginalConstructor()->getMock(); $listener = new LocaleListener($this->requestStack, 'fr', $router); $listener->onKernelFinishRequest($event); @@ -97,6 +97,6 @@ public function testRequestLocaleIsNotOverridden() private function getEvent(Request $request) { - return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST); + return new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php index d452ceb1f4e68..2f25c9b5c1c7e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php @@ -38,7 +38,7 @@ public function testKernelTerminate() ->method('collect') ->will($this->returnValue($profile)); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $masterRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') ->disableOriginalConstructor() diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php index 821688eff4017..e23c2cd1881a7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php @@ -31,7 +31,7 @@ protected function setUp() $listener = new ResponseListener('UTF-8'); $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); - $this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $this->kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); } protected function tearDown() diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php index 0b772e5d11154..645d69d0d8530 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php @@ -23,7 +23,7 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array(), array(), '', false); + $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock(); } /** @@ -67,7 +67,7 @@ public function getPortData() */ private function createGetResponseEventForUri($uri) { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = Request::create($uri); $request->attributes->set('_controller', null); // Prevents going in to routing process @@ -84,11 +84,11 @@ public function testInvalidMatcher() public function testRequestMatcher() { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = Request::create('http://localhost/'); $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); + $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $requestMatcher->expects($this->once()) ->method('matchRequest') ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) @@ -100,11 +100,11 @@ public function testRequestMatcher() public function testSubRequestWithDifferentMethod() { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = Request::create('http://localhost/', 'post'); $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); + $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $requestMatcher->expects($this->any()) ->method('matchRequest') ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) @@ -116,7 +116,7 @@ public function testSubRequestWithDifferentMethod() $listener->onKernelRequest($event); // sub-request with another HTTP method - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = Request::create('http://localhost/', 'get'); $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST); @@ -130,17 +130,17 @@ public function testSubRequestWithDifferentMethod() */ public function testLoggingParameter($parameter, $log, $parameters) { - $requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); + $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $requestMatcher->expects($this->once()) ->method('matchRequest') ->will($this->returnValue($parameter)); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->once()) ->method('info') ->with($this->equalTo($log), $this->equalTo($parameters)); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = Request::create('http://localhost/'); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext(), $logger); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php index 1a0acf92fa3f5..0100131f00b1c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php @@ -25,7 +25,7 @@ class SurrogateListenerTest extends \PHPUnit_Framework_TestCase public function testFilterDoesNothingForSubRequests() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $response = new Response('foo '); $listener = new SurrogateListener(new Esi()); @@ -39,7 +39,7 @@ public function testFilterDoesNothingForSubRequests() public function testFilterWhenThereIsSomeEsiIncludes() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $response = new Response('foo '); $listener = new SurrogateListener(new Esi()); @@ -53,7 +53,7 @@ public function testFilterWhenThereIsSomeEsiIncludes() public function testFilterWhenThereIsNoEsiIncludes() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $response = new Response('foo'); $listener = new SurrogateListener(new Esi()); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php index cbaaf5f93a18d..34f561d1499c9 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php @@ -82,7 +82,7 @@ private function filterResponse(Request $request, $type = HttpKernelInterface::M { $request->setSession($this->session); $response = new Response(); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $event = new FilterResponseEvent($kernel, $request, $type, $response); $this->listener->onKernelResponse($event); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php index c37d64786cc6d..b5b05bb454de4 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php @@ -25,8 +25,8 @@ class TranslatorListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); - $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); + $this->translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); + $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $this->listener = new TranslatorListener($this->translator, $this->requestStack); } @@ -96,7 +96,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() private function createHttpKernel() { - return $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + return $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); } private function createRequest($locale) diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php index b9d8f06f00848..7fcbc3b7e64f7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php @@ -26,7 +26,7 @@ class ValidateRequestListenerTest extends \PHPUnit_Framework_TestCase public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = new Request(); $request->setTrustedProxies(array('1.1.1.1')); diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/BasicTypesController.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/BasicTypesController.php index 1a603c2c08052..e8e0b603467aa 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/BasicTypesController.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/BasicTypesController.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; class BasicTypesController diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/ExtendingRequest.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/ExtendingRequest.php index e90e87c700061..9b4754b46f39d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/ExtendingRequest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/ExtendingRequest.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; use Symfony\Component\HttpFoundation\Request; diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/VariadicController.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/VariadicController.php index a540f9d1e13e4..c39812453bb01 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/VariadicController.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/VariadicController.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; class VariadicController diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php index 79fee3fcb66b5..230c15eda490f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php @@ -74,7 +74,7 @@ public function testRender() protected function getHandler($returnValue, $arguments = array()) { - $renderer = $this->getMock('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface'); + $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); $renderer ->expects($this->any()) ->method('getName') diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php index 2f266dba77cd0..9a9373c6d57d3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -75,7 +75,7 @@ public function testRenderWithAttributesOptions() public function testRenderWithDefaultText() { - $engine = $this->getMock('Symfony\\Component\\Templating\\EngineInterface'); + $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock(); $engine->expects($this->once()) ->method('exists') ->with('default') diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php index b3ebe79cf3ef2..adefd1fbfa1f6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php @@ -57,7 +57,7 @@ public function testRenderWithObjectsAsAttributes() */ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheControllerLegacy() { - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver', array('getController')); + $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver')->setMethods(array('getController'))->getMock(); $resolver ->expects($this->once()) ->method('getController') @@ -78,7 +78,7 @@ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheControllerL */ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController() { - $resolver = $this->getMock(ControllerResolverInterface::class); + $resolver = $this->getMockBuilder(ControllerResolverInterface::class)->getMock(); $resolver ->expects($this->once()) ->method('getController') @@ -111,7 +111,7 @@ public function testRenderWithTrustedHeaderDisabled() */ public function testRenderExceptionNoIgnoreErrors() { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher->expects($this->never())->method('dispatch'); $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher); @@ -121,7 +121,7 @@ public function testRenderExceptionNoIgnoreErrors() public function testRenderExceptionIgnoreErrors() { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher->expects($this->once())->method('dispatch')->with(KernelEvents::EXCEPTION); $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher); @@ -141,7 +141,7 @@ public function testRenderExceptionIgnoreErrorsWithAlt() private function getKernel($returnValue) { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel ->expects($this->any()) ->method('handle') @@ -157,7 +157,7 @@ private function getKernel($returnValue) */ private function getKernelExpectingRequest(Request $request) { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel ->expects($this->any()) ->method('handle') @@ -169,7 +169,7 @@ private function getKernelExpectingRequest(Request $request) public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() { - $controllerResolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); + $controllerResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); $controllerResolver ->expects($this->once()) ->method('getController') @@ -180,7 +180,7 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() })) ; - $argumentResolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface'); + $argumentResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface')->getMock(); $argumentResolver ->expects($this->once()) ->method('getArguments') diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php index 0d52ce89dbc26..dd8955780dcc1 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php @@ -225,7 +225,7 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent() protected function getCache($request, $response) { - $cache = $this->getMock('Symfony\Component\HttpKernel\HttpCache\HttpCache', array('getRequest', 'handle'), array(), '', false); + $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(array('getRequest', 'handle'))->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') ->will($this->returnValue($request)) diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php index 07b70dcee8e9e..357fc56717694 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php @@ -192,7 +192,7 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent() protected function getCache($request, $response) { - $cache = $this->getMock('Symfony\Component\HttpKernel\HttpCache\HttpCache', array('getRequest', 'handle'), array(), '', false); + $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(array('getRequest', 'handle'))->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') ->will($this->returnValue($request)) diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index ee3d999361f8c..92f28027ff1b6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -292,7 +292,7 @@ public function testVerifyRequestStackPushPopDuringHandle() { $request = new Request(); - $stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop')); + $stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(array('push', 'pop'))->getMock(); $stack->expects($this->at(0))->method('push')->with($this->equalTo($request)); $stack->expects($this->at(1))->method('pop'); @@ -328,13 +328,13 @@ private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $contr $controller = function () { return new Response('Hello'); }; } - $controllerResolver = $this->getMock(ControllerResolverInterface::class); + $controllerResolver = $this->getMockBuilder(ControllerResolverInterface::class)->getMock(); $controllerResolver ->expects($this->any()) ->method('getController') ->will($this->returnValue($controller)); - $argumentResolver = $this->getMock(ArgumentResolverInterface::class); + $argumentResolver = $this->getMockBuilder(ArgumentResolverInterface::class)->getMock(); $argumentResolver ->expects($this->any()) ->method('getArguments') diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 2eacb8aeda539..dad52adc54e39 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -64,7 +64,7 @@ public function testBootInitializesBundlesAndContainer() public function testBootSetsTheContainerToTheBundles() { - $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); + $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); $bundle->expects($this->once()) ->method('setContainer'); @@ -161,7 +161,7 @@ public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() public function testShutdownCallsShutdownOnAllBundles() { - $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); + $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); $bundle->expects($this->once()) ->method('shutdown'); @@ -173,7 +173,7 @@ public function testShutdownCallsShutdownOnAllBundles() public function testShutdownGivesNullContainerToAllBundles() { - $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); + $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); $bundle->expects($this->at(3)) ->method('setContainer') ->with(null); diff --git a/src/Symfony/Component/Inflector/LICENSE b/src/Symfony/Component/Inflector/LICENSE index 7bca398c149e6..ac30964e87ccb 100644 --- a/src/Symfony/Component/Inflector/LICENSE +++ b/src/Symfony/Component/Inflector/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2012-2016 Fabien Potencier +Copyright (c) 2012-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/Component/Intl/Collator/Collator.php b/src/Symfony/Component/Intl/Collator/Collator.php index 95f2ac23f59ad..c9c69a0f3bfa2 100644 --- a/src/Symfony/Component/Intl/Collator/Collator.php +++ b/src/Symfony/Component/Intl/Collator/Collator.php @@ -88,7 +88,7 @@ public function __construct($locale) * * @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en") * - * @return Collator + * @return self * * @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed */ diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index e689638573235..51de358617b13 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -173,7 +173,7 @@ public function __construct($locale, $datetype, $timetype, $timezone = null, $ca * One of the calendar constants. * @param string $pattern Optional pattern to use when formatting * - * @return IntlDateFormatter + * @return self * * @see http://www.php.net/manual/en/intldateformatter.create.php * @see http://userguide.icu-project.org/formatparse/datetime diff --git a/src/Symfony/Component/Intl/LICENSE b/src/Symfony/Component/Intl/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Intl/LICENSE +++ b/src/Symfony/Component/Intl/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/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 3938c04b5829b..3ded2d07f2faf 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -304,7 +304,7 @@ public function __construct($locale = 'en', $style = null, $pattern = null) * NumberFormat::PATTERN_RULEBASED. It must conform to the syntax * described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation * - * @return NumberFormatter + * @return self * * @see http://www.php.net/manual/en/numberformatter.create.php * @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php index 90bdc4835ef18..9ddef240a497b 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php @@ -62,7 +62,7 @@ class BundleEntryReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->readerImpl = $this->getMock('Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface'); + $this->readerImpl = $this->getMockBuilder('Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface')->getMock(); $this->reader = new BundleEntryReader($this->readerImpl); } diff --git a/src/Symfony/Component/Intl/Util/SvnRepository.php b/src/Symfony/Component/Intl/Util/SvnRepository.php index 6e5d87b13ffd1..8b5e8f31f859e 100644 --- a/src/Symfony/Component/Intl/Util/SvnRepository.php +++ b/src/Symfony/Component/Intl/Util/SvnRepository.php @@ -42,7 +42,7 @@ class SvnRepository * @param string $url The URL to download from * @param string $targetDir The directory in which to store the repository * - * @return SvnRepository The directory where the data is stored + * @return static * * @throws RuntimeException If an error occurs during the download. */ diff --git a/src/Symfony/Component/Ldap/Adapter/EntryManagerInterface.php b/src/Symfony/Component/Ldap/Adapter/EntryManagerInterface.php index b53e2e0662b3b..9538abfae2b25 100644 --- a/src/Symfony/Component/Ldap/Adapter/EntryManagerInterface.php +++ b/src/Symfony/Component/Ldap/Adapter/EntryManagerInterface.php @@ -12,11 +12,14 @@ namespace Symfony\Component\Ldap\Adapter; use Symfony\Component\Ldap\Entry; +use Symfony\Component\Ldap\Exception\LdapException; +use Symfony\Component\Ldap\Exception\NotBoundException; /** * Entry manager interface. * * @author Charles Sarrazin + * @author Bob van de Vijver */ interface EntryManagerInterface { @@ -24,6 +27,9 @@ interface EntryManagerInterface * Adds a new entry in the Ldap server. * * @param Entry $entry + * + * @throws NotBoundException + * @throws LdapException */ public function add(Entry $entry); @@ -31,6 +37,9 @@ public function add(Entry $entry); * Updates an entry from the Ldap server. * * @param Entry $entry + * + * @throws NotBoundException + * @throws LdapException */ public function update(Entry $entry); @@ -38,6 +47,9 @@ public function update(Entry $entry); * Removes an entry from the Ldap server. * * @param Entry $entry + * + * @throws NotBoundException + * @throws LdapException */ public function remove(Entry $entry); } diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php index 545d5d69a75d4..06dbc81524284 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php @@ -50,7 +50,7 @@ public function getConnection() public function getEntryManager() { if (null === $this->entryManager) { - $this->entryManager = new EntryManager($this->connection); + $this->entryManager = new EntryManager($this->getConnection()); } return $this->entryManager; diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php index 18043ccc9919a..455602c5afa2e 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php @@ -14,9 +14,11 @@ use Symfony\Component\Ldap\Adapter\EntryManagerInterface; use Symfony\Component\Ldap\Entry; use Symfony\Component\Ldap\Exception\LdapException; +use Symfony\Component\Ldap\Exception\NotBoundException; /** * @author Charles Sarrazin + * @author Bob van de Vijver */ class EntryManager implements EntryManagerInterface { @@ -32,7 +34,7 @@ public function __construct(Connection $connection) */ public function add(Entry $entry) { - $con = $this->connection->getResource(); + $con = $this->getConnectionResource(); if (!@ldap_add($con, $entry->getDn(), $entry->getAttributes())) { throw new LdapException(sprintf('Could not add entry "%s": %s', $entry->getDn(), ldap_error($con))); @@ -46,7 +48,7 @@ public function add(Entry $entry) */ public function update(Entry $entry) { - $con = $this->connection->getResource(); + $con = $this->getConnectionResource(); if (!@ldap_modify($con, $entry->getDn(), $entry->getAttributes())) { throw new LdapException(sprintf('Could not update entry "%s": %s', $entry->getDn(), ldap_error($con))); @@ -58,10 +60,23 @@ public function update(Entry $entry) */ public function remove(Entry $entry) { - $con = $this->connection->getResource(); + $con = $this->getConnectionResource(); if (!@ldap_delete($con, $entry->getDn())) { throw new LdapException(sprintf('Could not remove entry "%s": %s', $entry->getDn(), ldap_error($con))); } } + + /** + * Get the connection resource, but first check if the connection is bound. + */ + private function getConnectionResource() + { + // If the connection is not bound, throw an exception. Users should use an explicit bind call first. + if (!$this->connection->isBound()) { + throw new NotBoundException('Query execution is not possible without binding the connection first.'); + } + + return $this->connection->getResource(); + } } diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php index 0e8eae7d21d17..a268630529883 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php @@ -13,13 +13,15 @@ use Symfony\Component\Ldap\Adapter\AbstractQuery; use Symfony\Component\Ldap\Exception\LdapException; +use Symfony\Component\Ldap\Exception\NotBoundException; /** * @author Charles Sarrazin + * @author Bob van de Vijver */ class Query extends AbstractQuery { - /** @var Connection */ + /** @var Connection */ protected $connection; /** @var resource */ @@ -53,9 +55,9 @@ public function __destruct() public function execute() { if (null === $this->search) { - // If the connection is not bound, then we try an anonymous bind. + // If the connection is not bound, throw an exception. Users should use an explicit bind call first. if (!$this->connection->isBound()) { - $this->connection->bind(); + throw new NotBoundException('Query execution is not possible without binding the connection first.'); } $con = $this->connection->getResource(); diff --git a/src/Symfony/Component/Ldap/Adapter/QueryInterface.php b/src/Symfony/Component/Ldap/Adapter/QueryInterface.php index ba26de791efe8..c4cd4329bbe70 100644 --- a/src/Symfony/Component/Ldap/Adapter/QueryInterface.php +++ b/src/Symfony/Component/Ldap/Adapter/QueryInterface.php @@ -12,9 +12,12 @@ namespace Symfony\Component\Ldap\Adapter; use Symfony\Component\Ldap\Entry; +use Symfony\Component\Ldap\Exception\LdapException; +use Symfony\Component\Ldap\Exception\NotBoundException; /** * @author Charles Sarrazin + * @author Bob van de Vijver */ interface QueryInterface { @@ -27,6 +30,9 @@ interface QueryInterface * Executes a query and returns the list of Ldap entries. * * @return CollectionInterface|Entry[] + * + * @throws NotBoundException + * @throws LdapException */ public function execute(); } diff --git a/src/Symfony/Component/Ldap/Exception/NotBoundException.php b/src/Symfony/Component/Ldap/Exception/NotBoundException.php new file mode 100644 index 0000000000000..6eb904e8bbaaf --- /dev/null +++ b/src/Symfony/Component/Ldap/Exception/NotBoundException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Ldap\Exception; + +/** + * NotBoundException is thrown if the connection with the LDAP server is not yet bound. + * + * @author Bob van de Vijver + */ +class NotBoundException extends \RuntimeException implements ExceptionInterface +{ +} diff --git a/src/Symfony/Component/Ldap/LICENSE b/src/Symfony/Component/Ldap/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Ldap/LICENSE +++ b/src/Symfony/Component/Ldap/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/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php index f25d181896d35..a1a80231bd49b 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php @@ -14,6 +14,7 @@ use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter; use Symfony\Component\Ldap\Adapter\ExtLdap\Collection; use Symfony\Component\Ldap\Entry; +use Symfony\Component\Ldap\Exception\NotBoundException; use Symfony\Component\Ldap\LdapInterface; /** @@ -65,4 +66,15 @@ public function testLdapQueryIterator() $this->assertEquals(array('Fabien Potencier'), $entry->getAttribute('cn')); $this->assertEquals(array('fabpot@symfony.com', 'fabien@potencier.com'), $entry->getAttribute('mail')); } + + /** + * @group functional + */ + public function testLdapQueryWithoutBind() + { + $ldap = new Adapter($this->getLdapConfig()); + $this->setExpectedException(NotBoundException::class); + $query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))', array()); + $query->execute(); + } } diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php index fa9c7ba156e81..846d6a313d812 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php @@ -15,6 +15,7 @@ use Symfony\Component\Ldap\Adapter\ExtLdap\Collection; use Symfony\Component\Ldap\Entry; use Symfony\Component\Ldap\Exception\LdapException; +use Symfony\Component\Ldap\Exception\NotBoundException; /** * @requires extension ldap @@ -98,6 +99,39 @@ public function testLdapUpdate() $this->assertNull($entry->getAttribute('email')); } + /** + * @group functional + */ + public function testLdapUnboundAdd() + { + $this->adapter = new Adapter($this->getLdapConfig()); + $this->setExpectedException(NotBoundException::class); + $em = $this->adapter->getEntryManager(); + $em->add(new Entry('')); + } + + /** + * @group functional + */ + public function testLdapUnboundRemove() + { + $this->adapter = new Adapter($this->getLdapConfig()); + $this->setExpectedException(NotBoundException::class); + $em = $this->adapter->getEntryManager(); + $em->remove(new Entry('')); + } + + /** + * @group functional + */ + public function testLdapUnboundUpdate() + { + $this->adapter = new Adapter($this->getLdapConfig()); + $this->setExpectedException(NotBoundException::class); + $em = $this->adapter->getEntryManager(); + $em->update(new Entry('')); + } + /** * @return Collection|Entry[] */ diff --git a/src/Symfony/Component/Ldap/Tests/LdapClientTest.php b/src/Symfony/Component/Ldap/Tests/LdapClientTest.php index 30c5adfd40b1f..176c8f16f9320 100644 --- a/src/Symfony/Component/Ldap/Tests/LdapClientTest.php +++ b/src/Symfony/Component/Ldap/Tests/LdapClientTest.php @@ -29,7 +29,7 @@ class LdapClientTest extends LdapTestCase protected function setUp() { - $this->ldap = $this->getMock(LdapInterface::class); + $this->ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $this->client = new LdapClient(null, 389, 3, false, false, false, $this->ldap); } @@ -66,7 +66,7 @@ public function testLdapQuery() public function testLdapFind() { - $collection = $this->getMock(CollectionInterface::class); + $collection = $this->getMockBuilder(CollectionInterface::class)->getMock(); $collection ->expects($this->once()) ->method('getIterator') @@ -83,7 +83,7 @@ public function testLdapFind() )), )))) ; - $query = $this->getMock(QueryInterface::class); + $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query ->expects($this->once()) ->method('execute') diff --git a/src/Symfony/Component/Ldap/Tests/LdapTest.php b/src/Symfony/Component/Ldap/Tests/LdapTest.php index ddd294f3c2ad0..94978a3ac4583 100644 --- a/src/Symfony/Component/Ldap/Tests/LdapTest.php +++ b/src/Symfony/Component/Ldap/Tests/LdapTest.php @@ -26,13 +26,13 @@ class LdapTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->adapter = $this->getMock(AdapterInterface::class); + $this->adapter = $this->getMockBuilder(AdapterInterface::class)->getMock(); $this->ldap = new Ldap($this->adapter); } public function testLdapBind() { - $connection = $this->getMock(ConnectionInterface::class); + $connection = $this->getMockBuilder(ConnectionInterface::class)->getMock(); $connection ->expects($this->once()) ->method('bind') diff --git a/src/Symfony/Component/OptionsResolver/LICENSE b/src/Symfony/Component/OptionsResolver/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/OptionsResolver/LICENSE +++ b/src/Symfony/Component/OptionsResolver/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/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index bcaea9e4cbc0f..32ac5663fdcb1 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -145,7 +145,7 @@ class OptionsResolver implements Options * @param string $option The name of the option * @param mixed $value The default value of the option * - * @return OptionsResolver This instance + * @return $this * * @throws AccessException If called from a lazy option or normalizer */ @@ -208,7 +208,7 @@ public function setDefault($option, $value) * * @param array $defaults The default values to set * - * @return OptionsResolver This instance + * @return $this * * @throws AccessException If called from a lazy option or normalizer */ @@ -241,7 +241,7 @@ public function hasDefault($option) * * @param string|string[] $optionNames One or more option names * - * @return OptionsResolver This instance + * @return $this * * @throws AccessException If called from a lazy option or normalizer */ @@ -322,7 +322,7 @@ public function getMissingOptions() * * @param string|string[] $optionNames One or more option names * - * @return OptionsResolver This instance + * @return $this * * @throws AccessException If called from a lazy option or normalizer */ @@ -389,7 +389,7 @@ public function getDefinedOptions() * @param string $option The option name * @param \Closure $normalizer The normalizer * - * @return OptionsResolver This instance + * @return $this * * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer @@ -432,7 +432,7 @@ public function setNormalizer($option, \Closure $normalizer) * @param string $option The option name * @param mixed $allowedValues One or more acceptable values/closures * - * @return OptionsResolver This instance + * @return $this * * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer @@ -477,7 +477,7 @@ public function setAllowedValues($option, $allowedValues) * @param string $option The option name * @param mixed $allowedValues One or more acceptable values/closures * - * @return OptionsResolver This instance + * @return $this * * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer @@ -522,7 +522,7 @@ public function addAllowedValues($option, $allowedValues) * @param string $option The option name * @param string|string[] $allowedTypes One or more accepted types * - * @return OptionsResolver This instance + * @return $this * * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer @@ -561,7 +561,7 @@ public function setAllowedTypes($option, $allowedTypes) * @param string $option The option name * @param string|string[] $allowedTypes One or more accepted types * - * @return OptionsResolver This instance + * @return $this * * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer @@ -599,7 +599,7 @@ public function addAllowedTypes($option, $allowedTypes) * * @param string|string[] $optionNames One or more option names * - * @return OptionsResolver This instance + * @return $this * * @throws AccessException If called from a lazy option or normalizer */ @@ -620,7 +620,7 @@ public function remove($optionNames) /** * Removes all options. * - * @return OptionsResolver This instance + * @return $this * * @throws AccessException If called from a lazy option or normalizer */ diff --git a/src/Symfony/Component/Process/LICENSE b/src/Symfony/Component/Process/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Process/LICENSE +++ b/src/Symfony/Component/Process/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/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index d5b7d822839a9..a1ffda2d8a1a4 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -318,7 +318,7 @@ public function start(callable $callback = null) * @param callable|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR * - * @return Process The new process + * @return $this * * @throws RuntimeException When process can't be launched * @throws RuntimeException When process is already running @@ -398,7 +398,7 @@ public function getPid() * * @param int $signal A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php) * - * @return Process + * @return $this * * @throws LogicException In case the process is not running * @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed @@ -414,7 +414,7 @@ public function signal($signal) /** * Disables fetching output and error output from the underlying process. * - * @return Process + * @return $this * * @throws RuntimeException In case the process is already running * @throws LogicException if an idle timeout is set @@ -436,7 +436,7 @@ public function disableOutput() /** * Enables fetching output and error output from the underlying process. * - * @return Process + * @return $this * * @throws RuntimeException In case the process is already running */ @@ -565,7 +565,7 @@ public function getIterator($flags = 0) /** * Clears the process output. * - * @return Process + * @return $this */ public function clearOutput() { @@ -624,7 +624,7 @@ public function getIncrementalErrorOutput() /** * Clears the process output. * - * @return Process + * @return $this */ public function clearErrorOutput() { diff --git a/src/Symfony/Component/Process/ProcessBuilder.php b/src/Symfony/Component/Process/ProcessBuilder.php index 194594afc2775..cd6d9698634fd 100644 --- a/src/Symfony/Component/Process/ProcessBuilder.php +++ b/src/Symfony/Component/Process/ProcessBuilder.php @@ -46,7 +46,7 @@ public function __construct(array $arguments = array()) * * @param string[] $arguments An array of arguments * - * @return ProcessBuilder + * @return static */ public static function create(array $arguments = array()) { @@ -58,7 +58,7 @@ public static function create(array $arguments = array()) * * @param string $argument A command argument * - * @return ProcessBuilder + * @return $this */ public function add($argument) { @@ -74,7 +74,7 @@ public function add($argument) * * @param string|array $prefix A command prefix or an array of command prefixes * - * @return ProcessBuilder + * @return $this */ public function setPrefix($prefix) { @@ -91,7 +91,7 @@ public function setPrefix($prefix) * * @param string[] $arguments * - * @return ProcessBuilder + * @return $this */ public function setArguments(array $arguments) { @@ -105,7 +105,7 @@ public function setArguments(array $arguments) * * @param null|string $cwd The working directory * - * @return ProcessBuilder + * @return $this */ public function setWorkingDirectory($cwd) { @@ -119,7 +119,7 @@ public function setWorkingDirectory($cwd) * * @param bool $inheritEnv * - * @return ProcessBuilder + * @return $this */ public function inheritEnvironmentVariables($inheritEnv = true) { @@ -137,7 +137,7 @@ public function inheritEnvironmentVariables($inheritEnv = true) * @param string $name The variable name * @param null|string $value The variable value * - * @return ProcessBuilder + * @return $this */ public function setEnv($name, $value) { @@ -155,7 +155,7 @@ public function setEnv($name, $value) * * @param array $variables The variables * - * @return ProcessBuilder + * @return $this */ public function addEnvironmentVariables(array $variables) { @@ -169,7 +169,7 @@ public function addEnvironmentVariables(array $variables) * * @param resource|scalar|\Traversable|null $input The input content * - * @return ProcessBuilder + * @return $this * * @throws InvalidArgumentException In case the argument is invalid */ @@ -187,7 +187,7 @@ public function setInput($input) * * @param float|null $timeout * - * @return ProcessBuilder + * @return $this * * @throws InvalidArgumentException */ @@ -216,7 +216,7 @@ public function setTimeout($timeout) * @param string $name The option name * @param string $value The option value * - * @return ProcessBuilder + * @return $this */ public function setOption($name, $value) { @@ -228,7 +228,7 @@ public function setOption($name, $value) /** * Disables fetching output and error output from the underlying process. * - * @return ProcessBuilder + * @return $this */ public function disableOutput() { @@ -240,7 +240,7 @@ public function disableOutput() /** * Enables fetching output and error output from the underlying process. * - * @return ProcessBuilder + * @return $this */ public function enableOutput() { diff --git a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index 963bbb30105d6..e9720c7572404 100644 --- a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -23,11 +23,7 @@ class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase */ public function testProcessFailedExceptionThrowsException() { - $process = $this->getMock( - 'Symfony\Component\Process\Process', - array('isSuccessful'), - array('php') - ); + $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(array('isSuccessful'))->setConstructorArgs(array('php'))->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->will($this->returnValue(true)); @@ -53,11 +49,7 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( $errorOutput = 'FATAL: Unexpected error'; $workingDirectory = getcwd(); - $process = $this->getMock( - 'Symfony\Component\Process\Process', - array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'), - array($cmd) - ); + $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'))->setConstructorArgs(array($cmd))->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->will($this->returnValue(false)); @@ -105,11 +97,7 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() $exitText = 'General error'; $workingDirectory = getcwd(); - $process = $this->getMock( - 'Symfony\Component\Process\Process', - array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'), - array($cmd) - ); + $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'))->setConstructorArgs(array($cmd))->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->will($this->returnValue(false)); diff --git a/src/Symfony/Component/PropertyAccess/LICENSE b/src/Symfony/Component/PropertyAccess/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/PropertyAccess/LICENSE +++ b/src/Symfony/Component/PropertyAccess/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/Component/PropertyAccess/PropertyAccess.php b/src/Symfony/Component/PropertyAccess/PropertyAccess.php index 6c9bb423d021f..66a7e3a43fdf5 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccess.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccess.php @@ -21,7 +21,7 @@ final class PropertyAccess /** * Creates a property accessor with the default configuration. * - * @return PropertyAccessor The new property accessor + * @return PropertyAccessor */ public static function createPropertyAccessor() { @@ -31,7 +31,7 @@ public static function createPropertyAccessor() /** * Creates a property accessor builder. * - * @return PropertyAccessorBuilder The new property accessor builder + * @return PropertyAccessor */ public static function createPropertyAccessorBuilder() { diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php b/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php index fc8ac4ed2dd4f..11e67b091bb69 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php @@ -31,7 +31,7 @@ class PropertyAccessorBuilder /** * Enables the use of "__call" by the PropertyAccessor. * - * @return PropertyAccessorBuilder The builder object + * @return $this */ public function enableMagicCall() { @@ -43,7 +43,7 @@ public function enableMagicCall() /** * Disables the use of "__call" by the PropertyAccessor. * - * @return PropertyAccessorBuilder The builder object + * @return $this */ public function disableMagicCall() { @@ -66,7 +66,7 @@ public function isMagicCallEnabled() * This has no influence on writing non-existing indices with PropertyAccessorInterface::setValue() * which are always created on-the-fly. * - * @return PropertyAccessorBuilder The builder object + * @return $this */ public function enableExceptionOnInvalidIndex() { @@ -80,7 +80,7 @@ public function enableExceptionOnInvalidIndex() * * Instead, null is returned when calling PropertyAccessorInterface::getValue() on a non-existing index. * - * @return PropertyAccessorBuilder The builder object + * @return $this */ public function disableExceptionOnInvalidIndex() { diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php index 6721c2fb166e9..b4dc05dac323f 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php @@ -121,8 +121,8 @@ public function testSetValueCallsAdderAndRemoverForCollections() public function testSetValueCallsAdderAndRemoverForNestedCollections() { - $car = $this->getMock(__CLASS__.'_CompositeCar'); - $structure = $this->getMock(__CLASS__.'_CarStructure'); + $car = $this->getMockBuilder(__CLASS__.'_CompositeCar')->getMock(); + $structure = $this->getMockBuilder(__CLASS__.'_CarStructure')->getMock(); $axesBefore = $this->getContainer(array(1 => 'second', 3 => 'fourth')); $axesAfter = $this->getContainer(array(0 => 'first', 1 => 'second', 2 => 'third')); @@ -152,7 +152,7 @@ public function testSetValueCallsAdderAndRemoverForNestedCollections() */ public function testSetValueFailsIfNoAdderNorRemoverFound() { - $car = $this->getMock(__CLASS__.'_CarNoAdderAndRemover'); + $car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock(); $axesBefore = $this->getContainer(array(1 => 'second', 3 => 'fourth')); $axesAfter = $this->getContainer(array(0 => 'first', 1 => 'second', 2 => 'third')); @@ -165,25 +165,25 @@ public function testSetValueFailsIfNoAdderNorRemoverFound() public function testIsWritableReturnsTrueIfAdderAndRemoverExists() { - $car = $this->getMock(__CLASS__.'_Car'); + $car = $this->getMockBuilder(__CLASS__.'_Car')->getMock(); $this->assertTrue($this->propertyAccessor->isWritable($car, 'axes')); } public function testIsWritableReturnsFalseIfOnlyAdderExists() { - $car = $this->getMock(__CLASS__.'_CarOnlyAdder'); + $car = $this->getMockBuilder(__CLASS__.'_CarOnlyAdder')->getMock(); $this->assertFalse($this->propertyAccessor->isWritable($car, 'axes')); } public function testIsWritableReturnsFalseIfOnlyRemoverExists() { - $car = $this->getMock(__CLASS__.'_CarOnlyRemover'); + $car = $this->getMockBuilder(__CLASS__.'_CarOnlyRemover')->getMock(); $this->assertFalse($this->propertyAccessor->isWritable($car, 'axes')); } public function testIsWritableReturnsFalseIfNoAdderNorRemoverExists() { - $car = $this->getMock(__CLASS__.'_CarNoAdderAndRemover'); + $car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock(); $this->assertFalse($this->propertyAccessor->isWritable($car, 'axes')); } @@ -193,7 +193,7 @@ public function testIsWritableReturnsFalseIfNoAdderNorRemoverExists() */ public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable() { - $car = $this->getMock(__CLASS__.'_Car'); + $car = $this->getMockBuilder(__CLASS__.'_Car')->getMock(); $this->propertyAccessor->setValue($car, 'axes', 'Not an array or Traversable'); } diff --git a/src/Symfony/Component/PropertyInfo/LICENSE b/src/Symfony/Component/PropertyInfo/LICENSE index f2b04702db438..2ca4d6305bf2a 100644 --- a/src/Symfony/Component/PropertyInfo/LICENSE +++ b/src/Symfony/Component/PropertyInfo/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2016 Fabien Potencier +Copyright (c) 2015-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/Component/PropertyInfo/Type.php b/src/Symfony/Component/PropertyInfo/Type.php index 8a55a7cbc29e4..ad21f917241f8 100644 --- a/src/Symfony/Component/PropertyInfo/Type.php +++ b/src/Symfony/Component/PropertyInfo/Type.php @@ -148,7 +148,7 @@ public function isCollection() * * Only applicable for a collection type. * - * @return Type|null + * @return self|null */ public function getCollectionKeyType() { @@ -160,7 +160,7 @@ public function getCollectionKeyType() * * Only applicable for a collection type. * - * @return Type|null + * @return self|null */ public function getCollectionValueType() { diff --git a/src/Symfony/Component/Routing/LICENSE b/src/Symfony/Component/Routing/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Routing/LICENSE +++ b/src/Symfony/Component/Routing/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/Component/Routing/Matcher/Dumper/DumperCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php index 0f2815b73e46b..b24c8512ce1c9 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php @@ -38,7 +38,7 @@ class DumperCollection implements \IteratorAggregate /** * Returns the children routes and collections. * - * @return DumperCollection[]|DumperRoute[] Array of DumperCollection|DumperRoute + * @return self[]|DumperRoute[] */ public function all() { @@ -86,7 +86,7 @@ public function getIterator() /** * Returns the root of the collection. * - * @return DumperCollection The root collection + * @return self The root collection */ public function getRoot() { @@ -96,7 +96,7 @@ public function getRoot() /** * Returns the parent collection. * - * @return DumperCollection|null The parent collection or null if the collection has no parent + * @return self|null The parent collection or null if the collection has no parent */ protected function getParent() { diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php index dd1a0d90e13ef..5ea622c7d49ca 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php @@ -50,7 +50,7 @@ public function setPrefix($prefix) * * @param DumperRoute $route The route * - * @return DumperPrefixCollection The node the route was added to + * @return self * * @throws \LogicException */ diff --git a/src/Symfony/Component/Routing/RequestContext.php b/src/Symfony/Component/Routing/RequestContext.php index 862b824d4588d..9b15cd07d54a3 100644 --- a/src/Symfony/Component/Routing/RequestContext.php +++ b/src/Symfony/Component/Routing/RequestContext.php @@ -66,7 +66,7 @@ public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', * * @param Request $request A Request instance * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function fromRequest(Request $request) { @@ -97,7 +97,7 @@ public function getBaseUrl() * * @param string $baseUrl The base URL * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function setBaseUrl($baseUrl) { @@ -121,7 +121,7 @@ public function getPathInfo() * * @param string $pathInfo The path info * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function setPathInfo($pathInfo) { @@ -147,7 +147,7 @@ public function getMethod() * * @param string $method The HTTP method * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function setMethod($method) { @@ -173,7 +173,7 @@ public function getHost() * * @param string $host The HTTP host * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function setHost($host) { @@ -197,7 +197,7 @@ public function getScheme() * * @param string $scheme The HTTP scheme * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function setScheme($scheme) { @@ -221,7 +221,7 @@ public function getHttpPort() * * @param int $httpPort The HTTP port * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function setHttpPort($httpPort) { @@ -245,7 +245,7 @@ public function getHttpsPort() * * @param int $httpsPort The HTTPS port * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function setHttpsPort($httpsPort) { @@ -269,7 +269,7 @@ public function getQueryString() * * @param string $queryString The query string (after "?") * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function setQueryString($queryString) { @@ -294,7 +294,7 @@ public function getParameters() * * @param array $parameters The parameters * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function setParameters(array $parameters) { @@ -333,7 +333,7 @@ public function hasParameter($name) * @param string $name A parameter name * @param mixed $parameter The parameter value * - * @return RequestContext The current instance, implementing a fluent interface + * @return $this */ public function setParameter($name, $parameter) { diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index ad006961ee299..9cbf08d11fe70 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -149,7 +149,7 @@ public function getPath() * * @param string $pattern The path pattern * - * @return Route The current Route instance + * @return $this */ public function setPath($pattern) { @@ -178,7 +178,7 @@ public function getHost() * * @param string $pattern The host pattern * - * @return Route The current Route instance + * @return $this */ public function setHost($pattern) { @@ -207,7 +207,7 @@ public function getSchemes() * * @param string|array $schemes The scheme or an array of schemes * - * @return Route The current Route instance + * @return $this */ public function setSchemes($schemes) { @@ -248,7 +248,7 @@ public function getMethods() * * @param string|array $methods The method or an array of methods * - * @return Route The current Route instance + * @return $this */ public function setMethods($methods) { @@ -275,7 +275,7 @@ public function getOptions() * * @param array $options The options * - * @return Route The current Route instance + * @return $this */ public function setOptions(array $options) { @@ -293,7 +293,7 @@ public function setOptions(array $options) * * @param array $options The options * - * @return Route The current Route instance + * @return $this */ public function addOptions(array $options) { @@ -313,7 +313,7 @@ public function addOptions(array $options) * @param string $name An option name * @param mixed $value The option value * - * @return Route The current Route instance + * @return $this */ public function setOption($name, $value) { @@ -364,7 +364,7 @@ public function getDefaults() * * @param array $defaults The defaults * - * @return Route The current Route instance + * @return $this */ public function setDefaults(array $defaults) { @@ -380,7 +380,7 @@ public function setDefaults(array $defaults) * * @param array $defaults The defaults * - * @return Route The current Route instance + * @return $this */ public function addDefaults(array $defaults) { @@ -422,7 +422,7 @@ public function hasDefault($name) * @param string $name A variable name * @param mixed $default The default value * - * @return Route The current Route instance + * @return $this */ public function setDefault($name, $default) { @@ -449,7 +449,7 @@ public function getRequirements() * * @param array $requirements The requirements * - * @return Route The current Route instance + * @return $this */ public function setRequirements(array $requirements) { @@ -465,7 +465,7 @@ public function setRequirements(array $requirements) * * @param array $requirements The requirements * - * @return Route The current Route instance + * @return $this */ public function addRequirements(array $requirements) { @@ -507,7 +507,7 @@ public function hasRequirement($key) * @param string $key The key * @param string $regex The regex * - * @return Route The current Route instance + * @return $this */ public function setRequirement($key, $regex) { @@ -534,7 +534,7 @@ public function getCondition() * * @param string $condition The condition * - * @return Route The current Route instance + * @return $this */ public function setCondition($condition) { diff --git a/src/Symfony/Component/Routing/RouteCollectionBuilder.php b/src/Symfony/Component/Routing/RouteCollectionBuilder.php index 5f0256ac00ff6..726dfa9022cfb 100644 --- a/src/Symfony/Component/Routing/RouteCollectionBuilder.php +++ b/src/Symfony/Component/Routing/RouteCollectionBuilder.php @@ -55,7 +55,7 @@ public function __construct(LoaderInterface $loader = null) * @param string|null $prefix * @param string $type * - * @return RouteCollectionBuilder + * @return self * * @throws FileLoaderLoadException */ @@ -101,7 +101,7 @@ public function add($path, $controller, $name = null) /** * Returns a RouteCollectionBuilder that can be configured and then added with mount(). * - * @return RouteCollectionBuilder + * @return self */ public function createBuilder() { diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 8b6c0d1417540..84fac0e6e5811 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -208,7 +208,7 @@ public function testGenerateForRouteWithInvalidOptionalParameterNonStrict() public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger() { $routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+'))); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->once()) ->method('error'); $generator = $this->getGenerator($routes, array(), $logger); diff --git a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php index 5d66446f0fe23..ed7c5a4ba73d8 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php @@ -18,7 +18,7 @@ class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase { public function testSupports() { - $loader = new PhpFileLoader($this->getMock('Symfony\Component\Config\FileLocator')); + $loader = new PhpFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock()); $this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable'); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index 048d3ae904c9b..ef6e98a1e28ae 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -19,7 +19,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase { public function testSupports() { - $loader = new XmlFileLoader($this->getMock('Symfony\Component\Config\FileLocator')); + $loader = new XmlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock()); $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php index a6ae50b15287c..90d2a955cd0c6 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php @@ -19,7 +19,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase { public function testSupports() { - $loader = new YamlFileLoader($this->getMock('Symfony\Component\Config\FileLocator')); + $loader = new YamlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock()); $this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable'); $this->assertTrue($loader->supports('foo.yaml'), '->supports() returns true if the resource is loadable'); diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php index b944ffe80805e..ece28746e9fa0 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php @@ -20,8 +20,8 @@ class RouteCollectionBuilderTest extends \PHPUnit_Framework_TestCase { public function testImport() { - $resolvedLoader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); - $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface'); + $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('admin_routing.yml', 'yaml') @@ -38,7 +38,7 @@ public function testImport() ->with('admin_routing.yml', 'yaml') ->will($this->returnValue($expectedCollection)); - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->any()) ->method('getResolver') ->will($this->returnValue($resolver)); @@ -89,7 +89,7 @@ public function testFlushOrdering() $importedCollection->add('imported_route1', new Route('/imported/foo1')); $importedCollection->add('imported_route2', new Route('/imported/foo2')); - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); // make this loader able to do the import - keeps mocking simple $loader->expects($this->any()) ->method('supports') @@ -252,7 +252,7 @@ public function providePrefixTests() public function testFlushSetsPrefixedWithMultipleLevels() { - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $routes = new RouteCollectionBuilder($loader); $routes->add('homepage', 'MainController::homepageAction', 'homepage'); diff --git a/src/Symfony/Component/Routing/Tests/RouterTest.php b/src/Symfony/Component/Routing/Tests/RouterTest.php index 9a1c568ee37cd..fd418e1300e45 100644 --- a/src/Symfony/Component/Routing/Tests/RouterTest.php +++ b/src/Symfony/Component/Routing/Tests/RouterTest.php @@ -22,7 +22,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $this->loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $this->router = new Router($this->loader, 'routing.yml'); } @@ -82,7 +82,7 @@ public function testThatRouteCollectionIsLoaded() { $this->router->setOption('resource_type', 'ResourceType'); - $routeCollection = $this->getMock('Symfony\Component\Routing\RouteCollection'); + $routeCollection = $this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock(); $this->loader->expects($this->once()) ->method('load')->with('routing.yml', 'ResourceType') @@ -100,7 +100,7 @@ public function testMatcherIsCreatedIfCacheIsNotConfigured($option) $this->loader->expects($this->once()) ->method('load')->with('routing.yml', null) - ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RouteCollection'))); + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock())); $this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher()); } @@ -122,7 +122,7 @@ public function testGeneratorIsCreatedIfCacheIsNotConfigured($option) $this->loader->expects($this->once()) ->method('load')->with('routing.yml', null) - ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RouteCollection'))); + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock())); $this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator()); } @@ -137,7 +137,7 @@ public function provideGeneratorOptionsPreventingCaching() public function testMatchRequestWithUrlMatcherInterface() { - $matcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); $matcher->expects($this->once())->method('match'); $p = new \ReflectionProperty($this->router, 'matcher'); @@ -149,7 +149,7 @@ public function testMatchRequestWithUrlMatcherInterface() public function testMatchRequestWithRequestMatcherInterface() { - $matcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); + $matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $matcher->expects($this->once())->method('matchRequest'); $p = new \ReflectionProperty($this->router, 'matcher'); diff --git a/src/Symfony/Component/Security/Core/LICENSE b/src/Symfony/Component/Security/Core/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Security/Core/LICENSE +++ b/src/Symfony/Component/Security/Core/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/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php index cc8b7c02027c4..274992ed049ec 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php @@ -44,7 +44,7 @@ public function testAuthenticateWhenNoProviderSupportsToken() )); try { - $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $this->fail(); } catch (ProviderNotFoundException $e) { $this->assertSame($token, $e->getToken()); @@ -58,7 +58,7 @@ public function testAuthenticateWhenProviderReturnsAccountStatusException() )); try { - $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $this->fail(); } catch (AccountStatusException $e) { $this->assertSame($token, $e->getToken()); @@ -72,7 +72,7 @@ public function testAuthenticateWhenProviderReturnsAuthenticationException() )); try { - $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $this->fail(); } catch (AuthenticationException $e) { $this->assertSame($token, $e->getToken()); @@ -83,26 +83,26 @@ public function testAuthenticateWhenOneReturnsAuthenticationExceptionButNotAll() { $manager = new AuthenticationProviderManager(array( $this->getAuthenticationProvider(true, null, 'Symfony\Component\Security\Core\Exception\AuthenticationException'), - $this->getAuthenticationProvider(true, $expected = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')), + $this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()), )); - $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $this->assertSame($expected, $token); } public function testAuthenticateReturnsTokenOfTheFirstMatchingProvider() { - $second = $this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface'); + $second = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock(); $second ->expects($this->never()) ->method('supports') ; $manager = new AuthenticationProviderManager(array( - $this->getAuthenticationProvider(true, $expected = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')), + $this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()), $second, )); - $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $this->assertSame($expected, $token); } @@ -112,20 +112,20 @@ public function testEraseCredentialFlag() $this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')), )); - $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $this->assertEquals('', $token->getCredentials()); $manager = new AuthenticationProviderManager(array( $this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')), ), false); - $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $this->assertEquals('bar', $token->getCredentials()); } protected function getAuthenticationProvider($supports, $token = null, $exception = null) { - $provider = $this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface'); + $provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock(); $provider->expects($this->once()) ->method('supports') ->will($this->returnValue($supports)) @@ -139,7 +139,7 @@ protected function getAuthenticationProvider($supports, $token = null, $exceptio } elseif (null !== $exception) { $provider->expects($this->once()) ->method('authenticate') - ->will($this->throwException($this->getMock($exception, null, array(), ''))) + ->will($this->throwException($this->getMockBuilder($exception)->setMethods(null)->getMock())) ; } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php index 36409811c726e..e3f7f5f18bb75 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php @@ -47,17 +47,17 @@ public function testisFullFledged() protected function getToken() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } protected function getAnonymousToken() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', null, array('', '')); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(array('', ''))->getMock(); } protected function getRememberMeToken() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('setPersistent'), array(), '', false); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('setPersistent'))->disableOriginalConstructor()->getMock(); } protected function getResolver() diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php index 8f4b39278a9c4..f22227b0e2722 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php @@ -20,14 +20,14 @@ public function testSupports() $provider = $this->getProvider('foo'); $this->assertTrue($provider->supports($this->getSupportedToken('foo'))); - $this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))); + $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); } public function testAuthenticateWhenTokenIsNotSupported() { $provider = $this->getProvider('foo'); - $this->assertNull($provider->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))); + $this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); } /** @@ -50,7 +50,7 @@ public function testAuthenticate() protected function getSupportedToken($secret) { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', array('getSecret'), array(), '', false); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(array('getSecret'))->disableOriginalConstructor()->getMock(); $token->expects($this->any()) ->method('getSecret') ->will($this->returnValue($secret)) diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php index 3eedb8e5842ac..8edf1b02d4500 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php @@ -34,13 +34,13 @@ public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface() */ public function testRetrieveUserWhenUsernameIsNotFound() { - $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface'); + $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider->expects($this->once()) ->method('loadUserByUsername') ->will($this->throwException(new UsernameNotFoundException())) ; - $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')); + $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $method = new \ReflectionMethod($provider, 'retrieveUser'); $method->setAccessible(true); @@ -52,13 +52,13 @@ public function testRetrieveUserWhenUsernameIsNotFound() */ public function testRetrieveUserWhenAnExceptionOccurs() { - $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface'); + $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider->expects($this->once()) ->method('loadUserByUsername') ->will($this->throwException(new \RuntimeException())) ; - $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')); + $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $method = new \ReflectionMethod($provider, 'retrieveUser'); $method->setAccessible(true); @@ -67,19 +67,19 @@ public function testRetrieveUserWhenAnExceptionOccurs() public function testRetrieveUserReturnsUserFromTokenOnReauthentication() { - $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface'); + $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider->expects($this->never()) ->method('loadUserByUsername') ; - $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'); + $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getUser') ->will($this->returnValue($user)) ; - $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')); + $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $reflection = new \ReflectionMethod($provider, 'retrieveUser'); $reflection->setAccessible(true); $result = $reflection->invoke($provider, null, $token); @@ -89,15 +89,15 @@ public function testRetrieveUserReturnsUserFromTokenOnReauthentication() public function testRetrieveUser() { - $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'); + $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); - $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface'); + $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider->expects($this->once()) ->method('loadUserByUsername') ->will($this->returnValue($user)) ; - $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')); + $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $method = new \ReflectionMethod($provider, 'retrieveUser'); $method->setAccessible(true); @@ -109,7 +109,7 @@ public function testRetrieveUser() */ public function testCheckAuthenticationWhenCredentialsAreEmpty() { - $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface'); + $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder ->expects($this->never()) ->method('isPasswordValid') @@ -128,14 +128,14 @@ public function testCheckAuthenticationWhenCredentialsAreEmpty() $method->invoke( $provider, - $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'), + $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token ); } public function testCheckAuthenticationWhenCredentialsAre0() { - $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface'); + $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder ->expects($this->once()) ->method('isPasswordValid') @@ -155,7 +155,7 @@ public function testCheckAuthenticationWhenCredentialsAre0() $method->invoke( $provider, - $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'), + $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token ); } @@ -165,7 +165,7 @@ public function testCheckAuthenticationWhenCredentialsAre0() */ public function testCheckAuthenticationWhenCredentialsAreNotValid() { - $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface'); + $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder->expects($this->once()) ->method('isPasswordValid') ->will($this->returnValue(false)) @@ -181,7 +181,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid() ->will($this->returnValue('foo')) ; - $method->invoke($provider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'), $token); + $method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token); } /** @@ -189,7 +189,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid() */ public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged() { - $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'); + $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $user->expects($this->once()) ->method('getPassword') ->will($this->returnValue('foo')) @@ -200,7 +200,7 @@ public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChang ->method('getUser') ->will($this->returnValue($user)); - $dbUser = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'); + $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $dbUser->expects($this->once()) ->method('getPassword') ->will($this->returnValue('newFoo')) @@ -214,7 +214,7 @@ public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChang public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithoutOriginalCredentials() { - $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'); + $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $user->expects($this->once()) ->method('getPassword') ->will($this->returnValue('foo')) @@ -225,7 +225,7 @@ public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithou ->method('getUser') ->will($this->returnValue($user)); - $dbUser = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'); + $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $dbUser->expects($this->once()) ->method('getPassword') ->will($this->returnValue('foo')) @@ -239,7 +239,7 @@ public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithou public function testCheckAuthentication() { - $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface'); + $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder->expects($this->once()) ->method('isPasswordValid') ->will($this->returnValue(true)) @@ -255,12 +255,12 @@ public function testCheckAuthentication() ->will($this->returnValue('foo')) ; - $method->invoke($provider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'), $token); + $method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token); } protected function getSupportedToken() { - $mock = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken', array('getCredentials', 'getUser', 'getProviderKey'), array(), '', false); + $mock = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken')->setMethods(array('getCredentials', 'getUser', 'getProviderKey'))->disableOriginalConstructor()->getMock(); $mock ->expects($this->any()) ->method('getProviderKey') @@ -272,7 +272,7 @@ protected function getSupportedToken() protected function getProvider($user = null, $userChecker = null, $passwordEncoder = null) { - $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface'); + $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); if (null !== $user) { $userProvider->expects($this->once()) ->method('loadUserByUsername') @@ -281,14 +281,14 @@ protected function getProvider($user = null, $userChecker = null, $passwordEncod } if (null === $userChecker) { - $userChecker = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(); } if (null === $passwordEncoder) { $passwordEncoder = new PlaintextPasswordEncoder(); } - $encoderFactory = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'); + $encoderFactory = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock(); $encoderFactory ->expects($this->any()) ->method('getEncoder') diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php index da3068f654d14..9359f869f02f3 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php @@ -30,9 +30,9 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase */ public function testEmptyPasswordShouldThrowAnException() { - $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); $reflection = new \ReflectionMethod($provider, 'checkAuthentication'); @@ -47,14 +47,14 @@ public function testEmptyPasswordShouldThrowAnException() */ public function testBindFailureShouldThrowAnException() { - $userProvider = $this->getMock(UserProviderInterface::class); - $ldap = $this->getMock(LdapInterface::class); + $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock(); + $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) ->method('bind') ->will($this->throwException(new ConnectionException())) ; - $userChecker = $this->getMock(UserCheckerInterface::class); + $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock(); $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); $reflection = new \ReflectionMethod($provider, 'checkAuthentication'); @@ -65,15 +65,15 @@ public function testBindFailureShouldThrowAnException() public function testRetrieveUser() { - $userProvider = $this->getMock(UserProviderInterface::class); + $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock(); $userProvider ->expects($this->once()) ->method('loadUserByUsername') ->with('foo') ; - $ldap = $this->getMock(LdapInterface::class); + $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); - $userChecker = $this->getMock(UserCheckerInterface::class); + $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock(); $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); $reflection = new \ReflectionMethod($provider, 'retrieveUser'); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php index 5fd7b05ef0c48..27d8566e6874a 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php @@ -21,7 +21,7 @@ public function testSupports() $provider = $this->getProvider(); $this->assertTrue($provider->supports($this->getSupportedToken())); - $this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))); + $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken') ->disableOriginalConstructor() @@ -39,7 +39,7 @@ public function testAuthenticateWhenTokenIsNotSupported() { $provider = $this->getProvider(); - $this->assertNull($provider->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))); + $this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); } /** @@ -53,7 +53,7 @@ public function testAuthenticateWhenNoUserIsSet() public function testAuthenticate() { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -75,9 +75,9 @@ public function testAuthenticate() */ public function testAuthenticateWhenUserCheckerThrowsException() { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) ->method('checkPostAuth') ->will($this->throwException(new LockedException())) @@ -90,7 +90,7 @@ public function testAuthenticateWhenUserCheckerThrowsException() protected function getSupportedToken($user = false, $credentials = false) { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken', array('getUser', 'getCredentials', 'getProviderKey'), array(), '', false); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')->setMethods(array('getUser', 'getCredentials', 'getProviderKey'))->disableOriginalConstructor()->getMock(); if (false !== $user) { $token->expects($this->once()) ->method('getUser') @@ -117,7 +117,7 @@ protected function getSupportedToken($user = false, $credentials = false) protected function getProvider($user = null, $userChecker = null) { - $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); if (null !== $user) { $userProvider->expects($this->once()) ->method('loadUserByUsername') @@ -126,7 +126,7 @@ protected function getProvider($user = null, $userChecker = null) } if (null === $userChecker) { - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); } return new PreAuthenticatedAuthenticationProvider($userProvider, $userChecker, 'key'); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php index 735d195d0c49c..2099d9835f3ea 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php @@ -22,14 +22,14 @@ public function testSupports() $provider = $this->getProvider(); $this->assertTrue($provider->supports($this->getSupportedToken())); - $this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))); + $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); } public function testAuthenticateWhenTokenIsNotSupported() { $provider = $this->getProvider(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $this->assertNull($provider->authenticate($token)); } @@ -49,7 +49,7 @@ public function testAuthenticateWhenSecretsDoNotMatch() */ public function testAuthenticateWhenPreChecksFails() { - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) ->method('checkPreAuth') ->will($this->throwException(new DisabledException())); @@ -61,7 +61,7 @@ public function testAuthenticateWhenPreChecksFails() public function testAuthenticate() { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->exactly(2)) ->method('getRoles') ->will($this->returnValue(array('ROLE_FOO'))); @@ -80,14 +80,14 @@ public function testAuthenticate() protected function getSupportedToken($user = null, $secret = 'test') { if (null === $user) { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->any()) ->method('getRoles') ->will($this->returnValue(array())); } - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('getProviderKey'), array($user, 'foo', $secret)); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('getProviderKey'))->setConstructorArgs(array($user, 'foo', $secret))->getMock(); $token ->expects($this->once()) ->method('getProviderKey') @@ -99,7 +99,7 @@ protected function getSupportedToken($user = null, $secret = 'test') protected function getProvider($userChecker = null, $key = 'test') { if (null === $userChecker) { - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); } return new RememberMeAuthenticationProvider($userChecker, $key, 'foo'); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php index 05030543e6410..0a78ee8c77faf 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php @@ -25,14 +25,14 @@ public function testSupports() $provider = $this->getProvider(); $this->assertTrue($provider->supports($this->getSupportedToken())); - $this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))); + $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); } public function testAuthenticateWhenTokenIsNotSupported() { $provider = $this->getProvider(); - $this->assertNull($provider->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))); + $this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); } /** @@ -82,7 +82,7 @@ public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface() */ public function testAuthenticateWhenPreChecksFails() { - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) ->method('checkPreAuth') ->will($this->throwException(new CredentialsExpiredException())) @@ -91,7 +91,7 @@ public function testAuthenticateWhenPreChecksFails() $provider = $this->getProvider($userChecker); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) ; $provider->authenticate($this->getSupportedToken()); @@ -102,7 +102,7 @@ public function testAuthenticateWhenPreChecksFails() */ public function testAuthenticateWhenPostChecksFails() { - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) ->method('checkPostAuth') ->will($this->throwException(new AccountExpiredException())) @@ -111,7 +111,7 @@ public function testAuthenticateWhenPostChecksFails() $provider = $this->getProvider($userChecker); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) ; $provider->authenticate($this->getSupportedToken()); @@ -126,7 +126,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFails() $provider = $this->getProvider(); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) ; $provider->expects($this->once()) ->method('checkAuthentication') @@ -145,7 +145,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFailsWithHideFalse() $provider = $this->getProvider(false, false); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) ; $provider->expects($this->once()) ->method('checkAuthentication') @@ -157,7 +157,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFailsWithHideFalse() public function testAuthenticate() { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->once()) ->method('getRoles') ->will($this->returnValue(array('ROLE_FOO'))) @@ -191,7 +191,7 @@ public function testAuthenticate() public function testAuthenticateWithPreservingRoleSwitchUserRole() { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->once()) ->method('getRoles') ->will($this->returnValue(array('ROLE_FOO'))) @@ -209,7 +209,7 @@ public function testAuthenticateWithPreservingRoleSwitchUserRole() ->will($this->returnValue('foo')) ; - $switchUserRole = new SwitchUserRole('foo', $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $switchUserRole = new SwitchUserRole('foo', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $token->expects($this->once()) ->method('getRoles') ->will($this->returnValue(array($switchUserRole))) @@ -227,7 +227,7 @@ public function testAuthenticateWithPreservingRoleSwitchUserRole() protected function getSupportedToken() { - $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', array('getCredentials', 'getProviderKey', 'getRoles'), array(), '', false); + $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken')->setMethods(array('getCredentials', 'getProviderKey', 'getRoles'))->disableOriginalConstructor()->getMock(); $mock ->expects($this->any()) ->method('getProviderKey') @@ -242,7 +242,7 @@ protected function getSupportedToken() protected function getProvider($userChecker = false, $hide = true) { if (false === $userChecker) { - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); } return $this->getMockForAbstractClass('Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider', array($userChecker, 'key', $hide)); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php index 1a786d7c4543e..896ea37f1e941 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php @@ -68,7 +68,7 @@ public function testGetUsername() $token->setUser(new TestUser('fabien')); $this->assertEquals('fabien', $token->getUsername()); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->once())->method('getUsername')->will($this->returnValue('fabien')); $token->setUser($user); $this->assertEquals('fabien', $token->getUsername()); @@ -78,7 +78,7 @@ public function testEraseCredentials() { $token = $this->getToken(array('ROLE_FOO')); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->once())->method('eraseCredentials'); $token->setUser($user); @@ -168,8 +168,8 @@ public function testSetUser($user) public function getUsers() { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $advancedUser = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $advancedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); return array( array($advancedUser), @@ -197,8 +197,8 @@ public function testSetUserSetsAuthenticatedToFalseWhenUserChanges($firstUser, $ public function getUserChanges() { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $advancedUser = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $advancedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); return array( array( diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php index b83de4a984570..882f222476154 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php @@ -54,7 +54,7 @@ public function testConstructorSecretCannotBeEmptyString() protected function getUser($roles = array('ROLE_FOO')) { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getRoles') diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php index d06e3f03c6b62..a3bcc96fdf804 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php @@ -19,7 +19,7 @@ public function testGetSetToken() { $tokenStorage = new TokenStorage(); $this->assertNull($tokenStorage->getToken()); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $tokenStorage->setToken($token); $this->assertSame($token, $tokenStorage->getToken()); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php index 0e77c75f93522..8aace2116aac2 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php @@ -29,7 +29,7 @@ public function testSetUnsupportedStrategy() */ public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions, $expected) { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $manager = new AccessDecisionManager($voters, $strategy, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions); $this->assertSame($expected, $manager->decide($token, array('ROLE_FOO'))); @@ -47,7 +47,7 @@ public function testStrategiesWith2Roles($token, $strategy, $voter, $expected) public function getStrategiesWith2RolesTests() { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); return array( array($token, 'affirmative', $this->getVoter(VoterInterface::ACCESS_DENIED), false), @@ -65,7 +65,7 @@ public function getStrategiesWith2RolesTests() protected function getVoterFor2Roles($token, $vote1, $vote2) { - $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface'); + $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock(); $voter->expects($this->any()) ->method('vote') ->will($this->returnValueMap(array( @@ -130,7 +130,7 @@ protected function getVoters($grants, $denies, $abstains) protected function getVoter($vote) { - $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface'); + $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock(); $voter->expects($this->any()) ->method('vote') ->will($this->returnValue($vote)); diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php index aafc12fd90d45..eed361cbada93 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php @@ -23,8 +23,8 @@ class AuthorizationCheckerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); - $this->accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); + $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $this->accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); $this->tokenStorage = new TokenStorage(); $this->authorizationChecker = new AuthorizationChecker( @@ -36,10 +36,10 @@ protected function setUp() public function testVoteAuthenticatesTokenIfNecessary() { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $this->tokenStorage->setToken($token); - $newToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $newToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $this->authenticationManager ->expects($this->once()) @@ -78,7 +78,7 @@ public function testVoteWithoutAuthenticationToken() */ public function testIsGranted($decide) { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('isAuthenticated') diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php index f90f7769ba4c9..bbca8baa99998 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php @@ -23,7 +23,7 @@ class DebugAccessDecisionManagerTest extends \PHPUnit_Framework_TestCase public function testDecideLog($expectedLog, $object) { $adm = new DebugAccessDecisionManager(new AccessDecisionManager()); - $adm->decide($this->getMock(TokenInterface::class), array('ATTRIBUTE_1'), $object); + $adm->decide($this->getMockBuilder(TokenInterface::class)->getMock(), array('ATTRIBUTE_1'), $object); $this->assertSame($expectedLog, $adm->getDecisionLog()); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php index 60e2a1959f944..d685f0f017fd5 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php @@ -62,11 +62,11 @@ protected function getResolver() protected function getToken($authenticated) { if ('fully' === $authenticated) { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } elseif ('remembered' === $authenticated) { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('setPersistent'), array(), '', false); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('setPersistent'))->disableOriginalConstructor()->getMock(); } else { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', null, array('', '')); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(array('', ''))->getMock(); } } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php index 529629690b86e..714e6a04842ad 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php @@ -45,7 +45,7 @@ protected function getToken(array $roles, $tokenExpectsGetRoles = true) foreach ($roles as $i => $role) { $roles[$i] = new Role($role); } - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); if ($tokenExpectsGetRoles) { $token->expects($this->once()) @@ -58,7 +58,7 @@ protected function getToken(array $roles, $tokenExpectsGetRoles = true) protected function createExpressionLanguage($expressionLanguageExpectsEvaluate = true) { - $mock = $this->getMock('Symfony\Component\Security\Core\Authorization\ExpressionLanguage'); + $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\ExpressionLanguage')->getMock(); if ($expressionLanguageExpectsEvaluate) { $mock->expects($this->once()) @@ -71,12 +71,12 @@ protected function createExpressionLanguage($expressionLanguageExpectsEvaluate = protected function createTrustResolver() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(); } protected function createRoleHierarchy() { - return $this->getMock('Symfony\Component\Security\Core\Role\RoleHierarchyInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleHierarchyInterface')->getMock(); } protected function createExpression() diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php index 45535ca427b22..5918fd8518894 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php @@ -50,7 +50,7 @@ protected function getToken(array $roles) foreach ($roles as $i => $role) { $roles[$i] = new Role($role); } - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->once()) ->method('getRoles') ->will($this->returnValue($roles)); diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php index 4bac44d981893..cbd2755d5a6b6 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php @@ -21,7 +21,7 @@ class VoterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } public function getTests() diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php index 21aaae4fb4f20..191a4d877059f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php @@ -26,7 +26,7 @@ public function testGetEncoderWithMessageDigestEncoder() 'arguments' => array('sha512', true, 5), ))); - $encoder = $factory->getEncoder($this->getMock('Symfony\Component\Security\Core\User\UserInterface')); + $encoder = $factory->getEncoder($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()); $expectedEncoder = new MessageDigestPasswordEncoder('sha512', true, 5); $this->assertEquals($expectedEncoder->encodePassword('foo', 'moo'), $encoder->encodePassword('foo', 'moo')); @@ -38,7 +38,7 @@ public function testGetEncoderWithService() 'Symfony\Component\Security\Core\User\UserInterface' => new MessageDigestPasswordEncoder('sha1'), )); - $encoder = $factory->getEncoder($this->getMock('Symfony\Component\Security\Core\User\UserInterface')); + $encoder = $factory->getEncoder($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()); $expectedEncoder = new MessageDigestPasswordEncoder('sha1'); $this->assertEquals($expectedEncoder->encodePassword('foo', ''), $encoder->encodePassword('foo', '')); diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php index 590652da0420b..e8adb9b33dce0 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php @@ -17,18 +17,18 @@ class UserPasswordEncoderTest extends \PHPUnit_Framework_TestCase { public function testEncodePassword() { - $userMock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $userMock->expects($this->any()) ->method('getSalt') ->will($this->returnValue('userSalt')); - $mockEncoder = $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface'); + $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock(); $mockEncoder->expects($this->any()) ->method('encodePassword') ->with($this->equalTo('plainPassword'), $this->equalTo('userSalt')) ->will($this->returnValue('encodedPassword')); - $mockEncoderFactory = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface'); + $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock(); $mockEncoderFactory->expects($this->any()) ->method('getEncoder') ->with($this->equalTo($userMock)) @@ -42,7 +42,7 @@ public function testEncodePassword() public function testIsPasswordValid() { - $userMock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $userMock->expects($this->any()) ->method('getSalt') ->will($this->returnValue('userSalt')); @@ -50,13 +50,13 @@ public function testIsPasswordValid() ->method('getPassword') ->will($this->returnValue('encodedPassword')); - $mockEncoder = $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface'); + $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock(); $mockEncoder->expects($this->any()) ->method('isPasswordValid') ->with($this->equalTo('encodedPassword'), $this->equalTo('plainPassword'), $this->equalTo('userSalt')) ->will($this->returnValue(true)); - $mockEncoderFactory = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface'); + $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock(); $mockEncoderFactory->expects($this->any()) ->method('getEncoder') ->with($this->equalTo($userMock)) diff --git a/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php b/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php index f0ce468637478..fff5ff21f50c9 100644 --- a/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php @@ -17,14 +17,14 @@ class SwitchUserRoleTest extends \PHPUnit_Framework_TestCase { public function testGetSource() { - $role = new SwitchUserRole('FOO', $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $role = new SwitchUserRole('FOO', $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $this->assertSame($token, $role->getSource()); } public function testGetRole() { - $role = new SwitchUserRole('FOO', $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $role = new SwitchUserRole('FOO', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $this->assertEquals('FOO', $role->getRole()); } diff --git a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php index ab01f476eba01..dae58ae9add31 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php @@ -173,11 +173,11 @@ public function testSupportsClassWhenNotSupported() protected function getAccount() { - return $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); } protected function getProvider() { - return $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); } } diff --git a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php index b942e76da1154..a1ef0bbf19e8e 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php @@ -28,7 +28,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase */ public function testLoadUserByUsernameFailsIfCantConnectToLdap() { - $ldap = $this->getMock(LdapInterface::class); + $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) ->method('bind') @@ -44,8 +44,8 @@ public function testLoadUserByUsernameFailsIfCantConnectToLdap() */ public function testLoadUserByUsernameFailsIfNoLdapEntries() { - $result = $this->getMock(CollectionInterface::class); - $query = $this->getMock(QueryInterface::class); + $result = $this->getMockBuilder(CollectionInterface::class)->getMock(); + $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query ->expects($this->once()) ->method('execute') @@ -56,7 +56,7 @@ public function testLoadUserByUsernameFailsIfNoLdapEntries() ->method('count') ->will($this->returnValue(0)) ; - $ldap = $this->getMock(LdapInterface::class); + $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) ->method('escape') @@ -77,8 +77,8 @@ public function testLoadUserByUsernameFailsIfNoLdapEntries() */ public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry() { - $result = $this->getMock(CollectionInterface::class); - $query = $this->getMock(QueryInterface::class); + $result = $this->getMockBuilder(CollectionInterface::class)->getMock(); + $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query ->expects($this->once()) ->method('execute') @@ -89,7 +89,7 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry() ->method('count') ->will($this->returnValue(2)) ; - $ldap = $this->getMock(LdapInterface::class); + $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) ->method('escape') @@ -110,14 +110,14 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry() */ public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry() { - $result = $this->getMock(CollectionInterface::class); - $query = $this->getMock(QueryInterface::class); + $result = $this->getMockBuilder(CollectionInterface::class)->getMock(); + $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query ->expects($this->once()) ->method('execute') ->will($this->returnValue($result)) ; - $ldap = $this->getMock(LdapInterface::class); + $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') @@ -156,14 +156,14 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry() */ public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute() { - $result = $this->getMock(CollectionInterface::class); - $query = $this->getMock(QueryInterface::class); + $result = $this->getMockBuilder(CollectionInterface::class)->getMock(); + $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query ->expects($this->once()) ->method('execute') ->will($this->returnValue($result)) ; - $ldap = $this->getMock(LdapInterface::class); + $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') @@ -198,14 +198,14 @@ public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute() public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute() { - $result = $this->getMock(CollectionInterface::class); - $query = $this->getMock(QueryInterface::class); + $result = $this->getMockBuilder(CollectionInterface::class)->getMock(); + $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query ->expects($this->once()) ->method('execute') ->will($this->returnValue($result)) ; - $ldap = $this->getMock(LdapInterface::class); + $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') @@ -240,14 +240,14 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute() public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute() { - $result = $this->getMock(CollectionInterface::class); - $query = $this->getMock(QueryInterface::class); + $result = $this->getMockBuilder(CollectionInterface::class)->getMock(); + $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query ->expects($this->once()) ->method('execute') ->will($this->returnValue($result)) ; - $ldap = $this->getMock(LdapInterface::class); + $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') diff --git a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php index ac217814ea09b..4b6e52717e717 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php @@ -19,14 +19,14 @@ public function testCheckPostAuthNotAdvancedUserInterface() { $checker = new UserChecker(); - $this->assertNull($checker->checkPostAuth($this->getMock('Symfony\Component\Security\Core\User\UserInterface'))); + $this->assertNull($checker->checkPostAuth($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())); } public function testCheckPostAuthPass() { $checker = new UserChecker(); - $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(true)); $this->assertNull($checker->checkPostAuth($account)); @@ -39,7 +39,7 @@ public function testCheckPostAuthCredentialsExpired() { $checker = new UserChecker(); - $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(false)); $checker->checkPostAuth($account); @@ -49,14 +49,14 @@ public function testCheckPreAuthNotAdvancedUserInterface() { $checker = new UserChecker(); - $this->assertNull($checker->checkPreAuth($this->getMock('Symfony\Component\Security\Core\User\UserInterface'))); + $this->assertNull($checker->checkPreAuth($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())); } public function testCheckPreAuthPass() { $checker = new UserChecker(); - $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); $account->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); $account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(true)); @@ -71,7 +71,7 @@ public function testCheckPreAuthAccountLocked() { $checker = new UserChecker(); - $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(false)); $checker->checkPreAuth($account); @@ -84,7 +84,7 @@ public function testCheckPreAuthDisabled() { $checker = new UserChecker(); - $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); $account->expects($this->once())->method('isEnabled')->will($this->returnValue(false)); @@ -98,7 +98,7 @@ public function testCheckPreAuthAccountExpired() { $checker = new UserChecker(); - $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); $account->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); $account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(false)); diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php index 047c929904bfd..7ebe65c647d99 100644 --- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php @@ -95,7 +95,7 @@ public function testPasswordIsNotValid() */ public function testUserIsNotValid() { - $user = $this->getMock('Foo\Bar\User'); + $user = $this->getMockBuilder('Foo\Bar\User')->getMock(); $this->tokenStorage = $this->createTokenStorage($user); $this->validator = $this->createValidator(); @@ -106,7 +106,7 @@ public function testUserIsNotValid() protected function createUser() { - $mock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $mock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $mock ->expects($this->any()) @@ -125,12 +125,12 @@ protected function createUser() protected function createPasswordEncoder($isPasswordValid = true) { - return $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock(); } protected function createEncoderFactory($encoder = null) { - $mock = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface'); + $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock(); $mock ->expects($this->any()) @@ -145,7 +145,7 @@ protected function createTokenStorage($user = null) { $token = $this->createAuthenticationToken($user); - $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $mock ->expects($this->any()) ->method('getToken') @@ -157,7 +157,7 @@ protected function createTokenStorage($user = null) protected function createAuthenticationToken($user = null) { - $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $mock ->expects($this->any()) ->method('getUser') diff --git a/src/Symfony/Component/Security/Csrf/LICENSE b/src/Symfony/Component/Security/Csrf/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Security/Csrf/LICENSE +++ b/src/Symfony/Component/Security/Csrf/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/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php index 3112038eee700..16baec13659ff 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php @@ -36,8 +36,8 @@ class CsrfTokenManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->generator = $this->getMock('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface'); - $this->storage = $this->getMock('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface'); + $this->generator = $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface')->getMock(); + $this->storage = $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface')->getMock(); $this->manager = new CsrfTokenManager($this->generator, $this->storage); } diff --git a/src/Symfony/Component/Security/Guard/LICENSE b/src/Symfony/Component/Security/Guard/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Security/Guard/LICENSE +++ b/src/Symfony/Component/Security/Guard/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/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php index 3224fee78d7be..dee7ad16957e7 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php @@ -31,8 +31,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase public function testHandleSuccess() { - $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticateToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticateToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $providerKey = 'my_firewall'; $credentials = array('username' => 'weaverryan', 'password' => 'all_your_base'); @@ -81,8 +81,8 @@ public function testHandleSuccess() public function testHandleSuccessStopsAfterResponseIsSet() { - $authenticator1 = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticator2 = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $authenticator1 = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticator2 = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); // mock the first authenticator to fail, and set a Response $authenticator1 @@ -111,8 +111,8 @@ public function testHandleSuccessStopsAfterResponseIsSet() public function testHandleSuccessWithRememberMe() { - $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticateToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticateToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $providerKey = 'my_firewall_with_rememberme'; $authenticator @@ -154,7 +154,7 @@ public function testHandleSuccessWithRememberMe() public function testHandleCatchesAuthenticationException() { - $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); $providerKey = 'my_firewall2'; $authException = new AuthenticationException('Get outta here crazy user with a bad password!'); @@ -186,8 +186,8 @@ public function testHandleCatchesAuthenticationException() public function testReturnNullToSkipAuth() { - $authenticatorA = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticatorB = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $authenticatorA = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticatorB = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); $providerKey = 'my_firewall3'; $authenticatorA @@ -240,8 +240,8 @@ protected function setUp() ->method('getRequest') ->will($this->returnValue($this->request)); - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->rememberMeServices = $this->getMock('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface'); + $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $this->rememberMeServices = $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock(); } protected function tearDown() diff --git a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php index 6f36702df1a3f..58a3e1790ee5c 100644 --- a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php @@ -123,11 +123,11 @@ public function getTokenClearingTests() protected function setUp() { - $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $this->request = new Request(array(), array(), array(), array(), array(), array()); - $this->guardAuthenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $this->guardAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); } protected function tearDown() diff --git a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php index bfcf24b7709e7..e7e323a1782eb 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php @@ -27,9 +27,9 @@ public function testAuthenticate() { $providerKey = 'my_cool_firewall'; - $authenticatorA = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticatorB = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticatorC = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $authenticatorA = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticatorB = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticatorC = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); $authenticators = array($authenticatorA, $authenticatorB, $authenticatorC); // called 2 times - for authenticator A and B (stops on B because of match) @@ -52,7 +52,7 @@ public function testAuthenticate() $authenticatorC->expects($this->never()) ->method('getUser'); - $mockedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $authenticatorB->expects($this->once()) ->method('getUser') ->with($enteredCredentials, $this->userProvider) @@ -63,7 +63,7 @@ public function testAuthenticate() ->with($enteredCredentials, $mockedUser) // authentication works! ->will($this->returnValue(true)); - $authedToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $authedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $authenticatorB->expects($this->once()) ->method('createAuthenticatedToken') ->with($mockedUser, $providerKey) @@ -89,7 +89,7 @@ public function testCheckCredentialsReturningNonTrueFailsAuthentication() { $providerKey = 'my_uncool_firewall'; - $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); // make sure the authenticator is used $this->preAuthenticationToken->expects($this->any()) @@ -101,7 +101,7 @@ public function testCheckCredentialsReturningNonTrueFailsAuthentication() ->method('getCredentials') ->will($this->returnValue('non-null-value')); - $mockedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $authenticator->expects($this->once()) ->method('getUser') ->will($this->returnValue($mockedUser)); @@ -124,7 +124,7 @@ public function testGuardWithNoLongerAuthenticatedTriggersLogout() // create a token and mark it as NOT authenticated anymore // this mimics what would happen if a user "changed" between request - $mockedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $token = new PostAuthenticationGuardToken($mockedUser, $providerKey, array('ROLE_USER')); $token->setAuthenticated(false); @@ -134,8 +134,8 @@ public function testGuardWithNoLongerAuthenticatedTriggersLogout() protected function setUp() { - $this->userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); - $this->userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $this->preAuthenticationToken = $this->getMockBuilder('Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken') ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/Security/Http/LICENSE b/src/Symfony/Component/Security/Http/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Security/Http/LICENSE +++ b/src/Symfony/Component/Security/Http/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/Component/Security/Http/Tests/AccessMapTest.php b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php index d8ab7aae90d59..b71ad8561cfde 100644 --- a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php +++ b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php @@ -17,7 +17,7 @@ class AccessMapTest extends \PHPUnit_Framework_TestCase { public function testReturnsFirstMatchedPattern() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $requestMatcher1 = $this->getRequestMatcher($request, false); $requestMatcher2 = $this->getRequestMatcher($request, true); @@ -30,7 +30,7 @@ public function testReturnsFirstMatchedPattern() public function testReturnsEmptyPatternIfNoneMatched() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $requestMatcher = $this->getRequestMatcher($request, false); $map = new AccessMap(); @@ -41,7 +41,7 @@ public function testReturnsEmptyPatternIfNoneMatched() private function getRequestMatcher($request, $matches) { - $requestMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcherInterface'); + $requestMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcherInterface')->getMock(); $requestMatcher->expects($this->once()) ->method('matches')->with($request) ->will($this->returnValue($matches)); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php index c97ee6926ebcd..cb5fb51c32fbc 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php @@ -27,14 +27,14 @@ class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCas protected function setUp() { - $this->httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $this->httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); + $this->httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $this->httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); + $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $this->session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); - $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); + $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $this->request->expects($this->any())->method('getSession')->will($this->returnValue($this->session)); - $this->exception = $this->getMock('Symfony\Component\Security\Core\Exception\AuthenticationException', array('getMessage')); + $this->exception = $this->getMockBuilder('Symfony\Component\Security\Core\Exception\AuthenticationException')->setMethods(array('getMessage'))->getMock(); } public function testForward() @@ -181,8 +181,8 @@ public function testFailurePathParameterCanBeOverwritten() private function getRequest() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $request->attributes = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request->attributes = $this->getMockBuilder('Symfony\Component\HttpFoundation\ParameterBag')->getMock(); return $request; } diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php index 537299343ccd9..8b937c5fc5973 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php @@ -24,10 +24,10 @@ class DefaultAuthenticationSuccessHandlerTest extends \PHPUnit_Framework_TestCas protected function setUp() { - $this->httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); - $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $this->request->headers = $this->getMock('Symfony\Component\HttpFoundation\HeaderBag'); - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); + $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $this->request->headers = $this->getMockBuilder('Symfony\Component\HttpFoundation\HeaderBag')->getMock(); + $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } public function testRequestIsRedirected() @@ -101,7 +101,7 @@ public function testTargetPathParameterIsCustomised() public function testTargetPathIsTakenFromTheSession() { - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session->expects($this->once()) ->method('get')->with('_security.admin.target_path') ->will($this->returnValue('/admin/dashboard')); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php index 8a3188689bd04..330b21a488236 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php @@ -34,11 +34,11 @@ class SimpleAuthenticationHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->successHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface'); - $this->failureHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface'); + $this->successHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(); + $this->failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); - $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); // No methods are invoked on the exception; we just assert on its class $this->authenticationException = new AuthenticationException(); @@ -47,7 +47,7 @@ protected function setUp() public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNotASuccessHandler() { - $authenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $this->successHandler->expects($this->once()) ->method('onAuthenticationSuccess') @@ -117,7 +117,7 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsRetu public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNotAFailureHandler() { - $authenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $this->failureHandler->expects($this->once()) ->method('onAuthenticationFailure') diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php index ca5922c8df0f1..359c6de532adc 100644 --- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php @@ -18,7 +18,7 @@ class BasicAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase { public function testStart() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $authException = new AuthenticationException('The exception message'); @@ -31,7 +31,7 @@ public function testStart() public function testStartWithoutAuthException() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $entryPoint = new BasicAuthenticationEntryPoint('TheRealmName'); diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php index 4082986e1c922..e9c7f10820904 100644 --- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php @@ -19,7 +19,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase { public function testStart() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $authenticationException = new AuthenticationException('TheAuthenticationExceptionMessage'); @@ -32,7 +32,7 @@ public function testStart() public function testStartWithNoException() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $entryPoint = new DigestAuthenticationEntryPoint('TheRealmName', 'TheSecret'); $response = $entryPoint->start($request); @@ -43,7 +43,7 @@ public function testStartWithNoException() public function testStartWithNonceExpiredException() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $nonceExpiredException = new NonceExpiredException('TheNonceExpiredExceptionMessage'); diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php index 75a6be4dfae8a..0247e5fc4b20c 100644 --- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php @@ -19,11 +19,11 @@ class FormAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase { public function testStart() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $response = new Response(); - $httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); + $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils ->expects($this->once()) ->method('createRedirectResponse') @@ -38,11 +38,11 @@ public function testStart() public function testStartWithUseForward() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); - $subRequest = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); + $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $response = new Response('', 200); - $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); + $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils ->expects($this->once()) ->method('createRequest') @@ -50,7 +50,7 @@ public function testStartWithUseForward() ->will($this->returnValue($subRequest)) ; - $httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $httpKernel ->expects($this->once()) ->method('handle') diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php index 61f086a55582a..fa8a583e0c1bc 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php @@ -24,9 +24,9 @@ public function testHandleWithValidValues() $request = new Request(array(), array(), array(), array(), array(), array()); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -38,7 +38,7 @@ public function testHandleWithValidValues() ->with($this->equalTo($token)) ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -56,7 +56,7 @@ public function testHandleWithValidValues() ->method('getPreAuthenticatedData') ->will($this->returnValue($userCredentials)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -72,7 +72,7 @@ public function testHandleWhenAuthenticationFails() $request = new Request(array(), array(), array(), array(), array(), array()); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -84,7 +84,7 @@ public function testHandleWhenAuthenticationFails() ; $exception = new AuthenticationException('Authentication failed.'); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -102,7 +102,7 @@ public function testHandleWhenAuthenticationFails() ->method('getPreAuthenticatedData') ->will($this->returnValue($userCredentials)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -120,7 +120,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken() $request = new Request(array(), array(), array(), array(), array(), array()); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -132,7 +132,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken() ; $exception = new AuthenticationException('Authentication failed.'); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -150,7 +150,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken() ->method('getPreAuthenticatedData') ->will($this->returnValue($userCredentials)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -168,14 +168,14 @@ public function testHandleWithASimilarAuthenticatedToken() $token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO')); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') ->will($this->returnValue($token)) ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->never()) ->method('authenticate') @@ -191,7 +191,7 @@ public function testHandleWithASimilarAuthenticatedToken() ->method('getPreAuthenticatedData') ->will($this->returnValue($userCredentials)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -209,7 +209,7 @@ public function testHandleWithAnInvalidSimilarToken() $token = new PreAuthenticatedToken('AnotherUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO')); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -222,7 +222,7 @@ public function testHandleWithAnInvalidSimilarToken() ; $exception = new AuthenticationException('Authentication failed.'); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -240,7 +240,7 @@ public function testHandleWithAnInvalidSimilarToken() ->method('getPreAuthenticatedData') ->will($this->returnValue($userCredentials)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php index af9d56546262c..7f8eceaadde92 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php @@ -20,9 +20,9 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase */ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -30,21 +30,21 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() ->will($this->returnValue(array(array('foo' => 'bar'), null))) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->any()) ->method('isAuthenticated') ->will($this->returnValue(true)) ; - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') ->will($this->returnValue($token)) ; - $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); + $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); $accessDecisionManager ->expects($this->once()) ->method('decide') @@ -56,10 +56,10 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() $tokenStorage, $accessDecisionManager, $accessMap, - $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface') + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -71,9 +71,9 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() public function testHandleWhenTheTokenIsNotAuthenticated() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -81,21 +81,21 @@ public function testHandleWhenTheTokenIsNotAuthenticated() ->will($this->returnValue(array(array('foo' => 'bar'), null))) ; - $notAuthenticatedToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $notAuthenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $notAuthenticatedToken ->expects($this->any()) ->method('isAuthenticated') ->will($this->returnValue(false)) ; - $authenticatedToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $authenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $authenticatedToken ->expects($this->any()) ->method('isAuthenticated') ->will($this->returnValue(true)) ; - $authManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authManager ->expects($this->once()) ->method('authenticate') @@ -103,7 +103,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated() ->will($this->returnValue($authenticatedToken)) ; - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -115,7 +115,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated() ->with($this->equalTo($authenticatedToken)) ; - $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); + $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); $accessDecisionManager ->expects($this->once()) ->method('decide') @@ -130,7 +130,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated() $authManager ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -142,9 +142,9 @@ public function testHandleWhenTheTokenIsNotAuthenticated() public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -152,13 +152,13 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() ->will($this->returnValue(array(null, null))) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->never()) ->method('isAuthenticated') ; - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -167,12 +167,12 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() $listener = new AccessListener( $tokenStorage, - $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(), $accessMap, - $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface') + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -187,7 +187,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() */ public function testHandleWhenTheSecurityTokenStorageHasNoToken() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -196,12 +196,12 @@ public function testHandleWhenTheSecurityTokenStorageHasNoToken() $listener = new AccessListener( $tokenStorage, - $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'), - $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'), - $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface') + $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(), + $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $listener->handle($event); } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php index d99b56239f8a1..ba740c4157abe 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php @@ -18,30 +18,30 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase { public function testHandleWithTokenStorageHavingAToken() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) ; $tokenStorage ->expects($this->never()) ->method('setToken') ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->never()) ->method('authenticate') ; $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', null, $authenticationManager); - $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); + $listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock()); } public function testHandleWithTokenStorageHavingNoToken() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -50,7 +50,7 @@ public function testHandleWithTokenStorageHavingNoToken() $anonymousToken = new AnonymousToken('TheSecret', 'anon.', array()); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -67,21 +67,21 @@ public function testHandleWithTokenStorageHavingNoToken() ; $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', null, $authenticationManager); - $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); + $listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock()); } public function testHandledEventIsLogged() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->once()) ->method('info') ->with('Populated the TokenStorage with an anonymous Token.') ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', $logger, $authenticationManager); - $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); + $listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock()); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php index 8901cb2d7993c..62c23f619cb53 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php @@ -27,9 +27,9 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() 'PHP_AUTH_PW' => 'ThePassword', )); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -41,7 +41,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() ->with($this->equalTo($token)) ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -53,10 +53,10 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() $tokenStorage, $authenticationManager, 'TheProviderKey', - $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface') + $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -73,9 +73,9 @@ public function testHandleWhenAuthenticationFails() 'PHP_AUTH_PW' => 'ThePassword', )); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -88,7 +88,7 @@ public function testHandleWhenAuthenticationFails() $response = new Response(); - $authenticationEntryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $authenticationEntryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $authenticationEntryPoint ->expects($this->any()) ->method('start') @@ -98,12 +98,12 @@ public function testHandleWhenAuthenticationFails() $listener = new BasicAuthenticationListener( $tokenStorage, - new AuthenticationProviderManager(array($this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface'))), + new AuthenticationProviderManager(array($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock())), 'TheProviderKey', $authenticationEntryPoint ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -122,7 +122,7 @@ public function testHandleWithNoUsernameServerParameter() { $request = new Request(); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->never()) ->method('getToken') @@ -130,12 +130,12 @@ public function testHandleWithNoUsernameServerParameter() $listener = new BasicAuthenticationListener( $tokenStorage, - $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), 'TheProviderKey', - $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface') + $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -151,14 +151,14 @@ public function testHandleWithASimilarAuthenticatedToken() $token = new UsernamePasswordToken('TheUsername', 'ThePassword', 'TheProviderKey', array('ROLE_FOO')); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') ->will($this->returnValue($token)) ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->never()) ->method('authenticate') @@ -168,10 +168,10 @@ public function testHandleWithASimilarAuthenticatedToken() $tokenStorage, $authenticationManager, 'TheProviderKey', - $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface') + $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -188,10 +188,10 @@ public function testHandleWithASimilarAuthenticatedToken() public function testItRequiresProviderKey() { new BasicAuthenticationListener( - $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), - $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), '', - $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface') + $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() ); } @@ -204,7 +204,7 @@ public function testHandleWithADifferentAuthenticatedToken() $token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO')); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -217,7 +217,7 @@ public function testHandleWithADifferentAuthenticatedToken() $response = new Response(); - $authenticationEntryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $authenticationEntryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $authenticationEntryPoint ->expects($this->any()) ->method('start') @@ -227,12 +227,12 @@ public function testHandleWithADifferentAuthenticatedToken() $listener = new BasicAuthenticationListener( $tokenStorage, - new AuthenticationProviderManager(array($this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface'))), + new AuthenticationProviderManager(array($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock())), 'TheProviderKey', $authenticationEntryPoint ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php index 1465224e78436..ae6c39f3b95b5 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php @@ -18,14 +18,14 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase { public function testHandleWithNotSecuredRequestAndHttpChannel() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') ->will($this->returnValue(false)) ; - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -33,13 +33,13 @@ public function testHandleWithNotSecuredRequestAndHttpChannel() ->will($this->returnValue(array(array(), 'http'))) ; - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint ->expects($this->never()) ->method('start') ; - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -56,14 +56,14 @@ public function testHandleWithNotSecuredRequestAndHttpChannel() public function testHandleWithSecuredRequestAndHttpsChannel() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') ->will($this->returnValue(true)) ; - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -71,13 +71,13 @@ public function testHandleWithSecuredRequestAndHttpsChannel() ->will($this->returnValue(array(array(), 'https'))) ; - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint ->expects($this->never()) ->method('start') ; - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -94,7 +94,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel() public function testHandleWithNotSecuredRequestAndHttpsChannel() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') @@ -103,7 +103,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() $response = new Response(); - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -111,7 +111,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() ->will($this->returnValue(array(array(), 'https'))) ; - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint ->expects($this->once()) ->method('start') @@ -119,7 +119,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() ->will($this->returnValue($response)) ; - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -137,7 +137,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() public function testHandleWithSecuredRequestAndHttpChannel() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') @@ -146,7 +146,7 @@ public function testHandleWithSecuredRequestAndHttpChannel() $response = new Response(); - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -154,7 +154,7 @@ public function testHandleWithSecuredRequestAndHttpChannel() ->will($this->returnValue(array(array(), 'http'))) ; - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint ->expects($this->once()) ->method('start') @@ -162,7 +162,7 @@ public function testHandleWithSecuredRequestAndHttpChannel() ->will($this->returnValue($response)) ; - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index 02133307fdb79..3af62014c29f5 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -33,7 +33,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase public function testItRequiresContextKey() { new ContextListener( - $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), array(), '' ); @@ -46,7 +46,7 @@ public function testItRequiresContextKey() public function testUserProvidersNeedToImplementAnInterface() { new ContextListener( - $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), array(new \stdClass()), 'key123' ); @@ -102,7 +102,7 @@ public function testOnKernelResponseWithoutSession() $request->setSession($session); $event = new FilterResponseEvent( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST, new Response() @@ -121,7 +121,7 @@ public function testOnKernelResponseWithoutSessionNorToken() $request->setSession($session); $event = new FilterResponseEvent( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST, new Response() @@ -138,12 +138,12 @@ public function testOnKernelResponseWithoutSessionNorToken() */ public function testInvalidTokenInSession($token) { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') ->disableOriginalConstructor() ->getMock(); - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $event->expects($this->any()) ->method('getRequest') @@ -177,8 +177,8 @@ public function provideInvalidToken() public function testHandleAddsKernelResponseListener() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') ->disableOriginalConstructor() ->getMock(); @@ -190,7 +190,7 @@ public function testHandleAddsKernelResponseListener() ->will($this->returnValue(true)); $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($this->getMock('Symfony\Component\HttpFoundation\Request'))); + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock())); $dispatcher->expects($this->once()) ->method('addListener') @@ -201,15 +201,15 @@ public function testHandleAddsKernelResponseListener() public function testOnKernelResponseListenerRemovesItself() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent') ->disableOriginalConstructor() ->getMock(); $listener = new ContextListener($tokenStorage, array(), 'key123', null, $dispatcher); - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->expects($this->any()) ->method('hasSession') ->will($this->returnValue(true)); @@ -230,7 +230,7 @@ public function testOnKernelResponseListenerRemovesItself() public function testHandleRemovesTokenIfNoPreviousSessionWasFound() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->expects($this->any())->method('hasPreviousSession')->will($this->returnValue(false)); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') @@ -238,7 +238,7 @@ public function testHandleRemovesTokenIfNoPreviousSessionWasFound() ->getMock(); $event->expects($this->any())->method('getRequest')->will($this->returnValue($request)); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage->expects($this->once())->method('setToken')->with(null); $listener = new ContextListener($tokenStorage, array(), 'key123'); @@ -261,7 +261,7 @@ protected function runSessionOnKernelResponse($newToken, $original = null) $request->cookies->set('MOCKSESSID', true); $event = new FilterResponseEvent( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST, new Response() diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php index 80b2dc41343a8..2a29db7012df5 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php @@ -34,12 +34,12 @@ public function testHandleWithValidDigest() $entryPoint = new DigestAuthenticationEntryPoint($realm, $secret); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->method('getPassword')->willReturn($password); $providerKey = 'TheProviderKey'; - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->once()) ->method('getToken') @@ -51,12 +51,12 @@ public function testHandleWithValidDigest() ->with($this->equalTo(new UsernamePasswordToken($user, $password, $providerKey))) ; - $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); $userProvider->method('loadUserByUsername')->willReturn($user); $listener = new DigestAuthenticationListener($tokenStorage, $userProvider, $providerKey, $entryPoint); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index db0a242d4adbf..c1f31d7ccad94 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -69,7 +69,7 @@ public function testExceptionWhenEntryPointReturnsBadValue() { $event = $this->createEvent(new AuthenticationException()); - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint->expects($this->once())->method('start')->will($this->returnValue('NOT A RESPONSE')); $listener = $this->createExceptionListener(null, null, null, $entryPoint); @@ -98,12 +98,12 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle */ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandlerAndWithErrorPage(\Exception $exception, \Exception $eventException = null) { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel->expects($this->once())->method('handle')->will($this->returnValue(new Response('error'))); $event = $this->createEvent($exception, $kernel); - $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); + $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils->expects($this->once())->method('createRequest')->will($this->returnValue(Request::create('/error'))); $listener = $this->createExceptionListener(null, $this->createTrustResolver(true), $httpUtils, null, '/error'); @@ -120,7 +120,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithAccessDeniedHandlerAn { $event = $this->createEvent($exception); - $accessDeniedHandler = $this->getMock('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface'); + $accessDeniedHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface')->getMock(); $accessDeniedHandler->expects($this->once())->method('handle')->will($this->returnValue(new Response('error'))); $listener = $this->createExceptionListener(null, $this->createTrustResolver(true), null, null, null, $accessDeniedHandler); @@ -137,8 +137,8 @@ public function testAccessDeniedExceptionNotFullFledged(\Exception $exception, \ { $event = $this->createEvent($exception); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); $listener = $this->createExceptionListener($tokenStorage, $this->createTrustResolver(false), null, $this->createEntryPoint()); $listener->onKernelException($event); @@ -160,7 +160,7 @@ public function getAccessDeniedExceptionProvider() private function createEntryPoint() { - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint->expects($this->once())->method('start')->will($this->returnValue(new Response('OK'))); return $entryPoint; @@ -168,7 +168,7 @@ private function createEntryPoint() private function createTrustResolver($fullFledged) { - $trustResolver = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'); + $trustResolver = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(); $trustResolver->expects($this->once())->method('isFullFledged')->will($this->returnValue($fullFledged)); return $trustResolver; @@ -177,7 +177,7 @@ private function createTrustResolver($fullFledged) private function createEvent(\Exception $exception, $kernel = null) { if (null === $kernel) { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); } return new GetResponseForExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $exception); @@ -186,9 +186,9 @@ private function createEvent(\Exception $exception, $kernel = null) private function createExceptionListener(TokenStorageInterface $tokenStorage = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null) { return new ExceptionListener( - $tokenStorage ?: $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), - $trustResolver ?: $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'), - $httpUtils ?: $this->getMock('Symfony\Component\Security\Http\HttpUtils'), + $tokenStorage ?: $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), + $trustResolver ?: $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(), + $httpUtils ?: $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(), 'key', $authenticationEntryPoint, $errorPage, diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php index 367c810f51f39..8f6db59d4129e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php @@ -172,12 +172,12 @@ public function testCsrfValidationFails() private function getTokenManager() { - return $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); } private function getTokenStorage() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); } private function getGetResponseEvent() @@ -195,7 +195,7 @@ private function getGetResponseEvent() private function getHandler() { - return $this->getMock('Symfony\Component\Security\Http\Logout\LogoutHandlerInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Http\Logout\LogoutHandlerInterface')->getMock(); } private function getHttpUtils() @@ -225,11 +225,11 @@ private function getListener($successHandler = null, $tokenManager = null) private function getSuccessHandler() { - return $this->getMock('Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface')->getMock(); } private function getToken() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php index cd2f1b8735b86..141b4cc2adf0a 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php @@ -25,7 +25,7 @@ public function testOnCoreSecurityDoesNotTryToPopulateNonEmptyTokenStorage() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) ; $tokenStorage @@ -75,7 +75,7 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) ; $service @@ -117,7 +117,7 @@ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExcepti $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) ; $service @@ -152,7 +152,7 @@ public function testOnCoreSecurity() ->will($this->returnValue(null)) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -191,7 +191,7 @@ public function testSessionStrategy() ->will($this->returnValue(null)) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -210,14 +210,14 @@ public function testSessionStrategy() ->will($this->returnValue($token)) ; - $session = $this->getMock('\Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session ->expects($this->once()) ->method('isStarted') ->will($this->returnValue(true)) ; - $request = $this->getMock('\Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Request')->getMock(); $request ->expects($this->once()) ->method('hasSession') @@ -256,7 +256,7 @@ public function testSessionIsMigratedByDefault() ->will($this->returnValue(null)) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -275,7 +275,7 @@ public function testSessionIsMigratedByDefault() ->will($this->returnValue($token)) ; - $session = $this->getMock('\Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session ->expects($this->once()) ->method('isStarted') @@ -286,7 +286,7 @@ public function testSessionIsMigratedByDefault() ->method('migrate') ; - $request = $this->getMock('\Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Request')->getMock(); $request ->expects($this->any()) ->method('hasSession') @@ -319,7 +319,7 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI ->will($this->returnValue(null)) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -360,12 +360,12 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI protected function getGetResponseEvent() { - return $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + return $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); } protected function getFilterResponseEvent() { - return $this->getMock('Symfony\Component\HttpKernel\Event\FilterResponseEvent', array(), array(), '', false); + return $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent')->disableOriginalConstructor()->getMock(); } protected function getListener($withDispatcher = false, $catchExceptions = true, $withSessionStrategy = false) @@ -385,31 +385,31 @@ protected function getListener($withDispatcher = false, $catchExceptions = true, protected function getLogger() { - return $this->getMock('Psr\Log\LoggerInterface'); + return $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); } protected function getManager() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); } protected function getService() { - return $this->getMock('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock(); } protected function getTokenStorage() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); } protected function getDispatcher() { - return $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + return $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); } private function getSessionStrategy() { - return $this->getMock('\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface'); + return $this->getMockBuilder('\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php index dad7aadcdc0ba..985152c770afb 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php @@ -24,9 +24,9 @@ public function testGetPreAuthenticatedData() $request = new Request(array(), array(), array(), array(), array(), $serverVars); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, @@ -48,9 +48,9 @@ public function testGetPreAuthenticatedDataNoUser() { $request = new Request(array(), array(), array(), array(), array(), array()); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, @@ -71,9 +71,9 @@ public function testGetPreAuthenticatedDataWithDifferentKeys() $request = new Request(array(), array(), array(), array(), array(), array( 'TheUserKey' => 'TheUser', )); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php index adf91b1c4d1b0..90ce1e6f241c4 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php @@ -42,7 +42,7 @@ public function testHandle() ->will($this->returnValue($this->token)) ; - $simpleAuthenticator = $this->getMock('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface'); + $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock(); $simpleAuthenticator ->expects($this->once()) ->method('createToken') @@ -79,7 +79,7 @@ public function testHandlecatchAuthenticationException() ->with($this->equalTo(null)) ; - $simpleAuthenticator = $this->getMock('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface'); + $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock(); $simpleAuthenticator ->expects($this->once()) ->method('createToken') @@ -99,20 +99,20 @@ protected function setUp() ->getMock() ; - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $this->request = new Request(array(), array(), array(), array(), array(), array()); - $this->event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $this->event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $this->event ->expects($this->any()) ->method('getRequest') ->will($this->returnValue($this->request)) ; - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } protected function tearDown() diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php index 28d73e0c3b217..b80f8c608fef6 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php @@ -31,13 +31,13 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $this->userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); - $this->userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); - $this->accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); - $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $this->request->query = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag'); - $this->request->server = $this->getMock('Symfony\Component\HttpFoundation\ServerBag'); + $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $this->accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); + $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $this->request->query = $this->getMockBuilder('Symfony\Component\HttpFoundation\ParameterBag')->getMock(); + $this->request->server = $this->getMockBuilder('Symfony\Component\HttpFoundation\ServerBag')->getMock(); $this->event = $this->getEvent($this->request); } @@ -66,7 +66,7 @@ public function testEventIsIgnoredIfUsernameIsNotPassedWithTheRequest() */ public function testExitUserThrowsAuthenticationExceptionIfOriginalTokenCannotBeFound() { - $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface'))); + $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock())); $this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token)); $this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('_exit')); @@ -104,8 +104,8 @@ public function testExitUserUpdatesToken() public function testExitUserDispatchesEventWithRefreshedUser() { - $originalUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $refreshedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $originalUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $refreshedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $this ->userProvider ->expects($this->any()) @@ -145,7 +145,7 @@ public function testExitUserDispatchesEventWithRefreshedUser() ->method('all') ->will($this->returnValue(array())); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher ->expects($this->once()) ->method('dispatch') @@ -201,7 +201,7 @@ public function testExitUserDoesNotDispatchEventWithStringUser() ->method('getUri') ->willReturn('/'); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher ->expects($this->never()) ->method('dispatch') @@ -216,7 +216,7 @@ public function testExitUserDoesNotDispatchEventWithStringUser() */ public function testSwitchUserIsDisallowed() { - $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface'))); + $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock())); $this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token)); $this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('kuba')); @@ -231,8 +231,8 @@ public function testSwitchUserIsDisallowed() public function testSwitchUser() { - $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface'))); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock())); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->any())->method('getRoles')->will($this->returnValue(array())); $this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token)); @@ -261,8 +261,8 @@ public function testSwitchUser() public function testSwitchUserKeepsOtherQueryStringParameters() { - $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface'))); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock())); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->any())->method('getRoles')->will($this->returnValue(array())); $this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token)); @@ -303,7 +303,7 @@ private function getEvent($request) private function getToken(array $roles = array()) { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->any()) ->method('getRoles') ->will($this->returnValue($roles)); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php index 66690d971074f..3e58e69e08556 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php @@ -31,9 +31,9 @@ public function testGetPreAuthenticatedData($user, $credentials) $request = new Request(array(), array(), array(), array(), array(), $serverVars); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey'); @@ -60,9 +60,9 @@ public function testGetPreAuthenticatedDataNoUser($emailAddress) $credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress; $request = new Request(array(), array(), array(), array(), array(), array('SSL_CLIENT_S_DN' => $credentials)); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey'); @@ -88,9 +88,9 @@ public function testGetPreAuthenticatedDataNoData() { $request = new Request(array(), array(), array(), array(), array(), array()); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey'); @@ -108,9 +108,9 @@ public function testGetPreAuthenticatedDataWithDifferentKeys() 'TheUserKey' => 'TheUser', 'TheCredentialsKey' => 'TheCredentials', )); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey', 'TheUserKey', 'TheCredentialsKey'); diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php index 85a57ab82cebd..016c72df45ae3 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php @@ -22,7 +22,7 @@ public function testGetListeners() $request = new Request(); - $notMatchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') @@ -30,27 +30,27 @@ public function testGetListeners() ->will($this->returnValue(false)) ; - $map->add($notMatchingMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'))); + $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); - $matchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $matchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $matchingMatcher ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) ->will($this->returnValue(true)) ; - $theListener = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'); - $theException = $this->getMock('Symfony\Component\Security\Http\Firewall\ExceptionListener', array(), array(), '', false); + $theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); + $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); $map->add($matchingMatcher, array($theListener), $theException); - $tooLateMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $tooLateMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $tooLateMatcher ->expects($this->never()) ->method('matches') ; - $map->add($tooLateMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'))); + $map->add($tooLateMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); list($listeners, $exception) = $map->getListeners($request); @@ -64,7 +64,7 @@ public function testGetListenersWithAnEntryHavingNoRequestMatcher() $request = new Request(); - $notMatchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') @@ -72,20 +72,20 @@ public function testGetListenersWithAnEntryHavingNoRequestMatcher() ->will($this->returnValue(false)) ; - $map->add($notMatchingMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'))); + $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); - $theListener = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'); - $theException = $this->getMock('Symfony\Component\Security\Http\Firewall\ExceptionListener', array(), array(), '', false); + $theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); + $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); $map->add(null, array($theListener), $theException); - $tooLateMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $tooLateMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $tooLateMatcher ->expects($this->never()) ->method('matches') ; - $map->add($tooLateMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'))); + $map->add($tooLateMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); list($listeners, $exception) = $map->getListeners($request); @@ -99,7 +99,7 @@ public function testGetListenersWithNoMatchingEntry() $request = new Request(); - $notMatchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') @@ -107,7 +107,7 @@ public function testGetListenersWithNoMatchingEntry() ->will($this->returnValue(false)) ; - $map->add($notMatchingMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'))); + $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); list($listeners, $exception) = $map->getListeners($request); diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php index 1e0c1ef0dd083..20da3ae31acd9 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php @@ -20,18 +20,18 @@ class FirewallTest extends \PHPUnit_Framework_TestCase { public function testOnKernelRequestRegistersExceptionListener() { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - $listener = $this->getMock('Symfony\Component\Security\Http\Firewall\ExceptionListener', array(), array(), '', false); + $listener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); $listener ->expects($this->once()) ->method('register') ->with($this->equalTo($dispatcher)) ; - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $map = $this->getMock('Symfony\Component\Security\Http\FirewallMapInterface'); + $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); $map ->expects($this->once()) ->method('getListeners') @@ -39,7 +39,7 @@ public function testOnKernelRequestRegistersExceptionListener() ->will($this->returnValue(array(array(), $listener))) ; - $event = new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $firewall = new Firewall($map, $dispatcher); $firewall->onKernelRequest($event); @@ -49,59 +49,59 @@ public function testOnKernelRequestStopsWhenThereIsAResponse() { $response = new Response(); - $first = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'); + $first = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); $first ->expects($this->once()) ->method('handle') ; - $second = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'); + $second = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); $second ->expects($this->never()) ->method('handle') ; - $map = $this->getMock('Symfony\Component\Security\Http\FirewallMapInterface'); + $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); $map ->expects($this->once()) ->method('getListeners') ->will($this->returnValue(array(array($first, $second), null))) ; - $event = $this->getMock( - 'Symfony\Component\HttpKernel\Event\GetResponseEvent', - array('hasResponse'), - array( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), - $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false), + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') + ->setMethods(array('hasResponse')) + ->setConstructorArgs(array( + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), + $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(), HttpKernelInterface::MASTER_REQUEST, - ) - ); + )) + ->getMock() + ; $event ->expects($this->once()) ->method('hasResponse') ->will($this->returnValue(true)) ; - $firewall = new Firewall($map, $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface')); + $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock()); $firewall->onKernelRequest($event); } public function testOnKernelRequestWithSubRequest() { - $map = $this->getMock('Symfony\Component\Security\Http\FirewallMapInterface'); + $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); $map ->expects($this->never()) ->method('getListeners') ; $event = new GetResponseEvent( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), - $this->getMock('Symfony\Component\HttpFoundation\Request'), + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), + $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(), HttpKernelInterface::SUB_REQUEST ); - $firewall = new Firewall($map, $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface')); + $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock()); $firewall->onKernelRequest($event); $this->assertFalse($event->hasResponse()); diff --git a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php index 45a0281591b95..bb432a0c52dc2 100644 --- a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php +++ b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php @@ -39,7 +39,7 @@ public function testCreateRedirectResponseWithAbsoluteUrl() public function testCreateRedirectResponseWithRouteName() { - $utils = new HttpUtils($urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')); + $utils = new HttpUtils($urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()); $urlGenerator ->expects($this->any()) @@ -50,7 +50,7 @@ public function testCreateRedirectResponseWithRouteName() $urlGenerator ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())) ; $response = $utils->createRedirectResponse($this->getRequest(), 'foobar'); @@ -73,7 +73,7 @@ public function testCreateRequestWithPath() public function testCreateRequestWithRouteName() { - $utils = new HttpUtils($urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')); + $utils = new HttpUtils($urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()); $urlGenerator ->expects($this->once()) @@ -83,7 +83,7 @@ public function testCreateRequestWithRouteName() $urlGenerator ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())) ; $subRequest = $utils->createRequest($this->getRequest(), 'foobar'); @@ -93,7 +93,7 @@ public function testCreateRequestWithRouteName() public function testCreateRequestWithAbsoluteUrl() { - $utils = new HttpUtils($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')); + $utils = new HttpUtils($this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()); $subRequest = $utils->createRequest($this->getRequest(), 'http://symfony.com/'); $this->assertEquals('/', $subRequest->getPathInfo()); @@ -102,7 +102,7 @@ public function testCreateRequestWithAbsoluteUrl() public function testCreateRequestPassesSessionToTheNewRequest() { $request = $this->getRequest(); - $request->setSession($session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface')); + $request->setSession($session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $utils = new HttpUtils($this->getUrlGenerator()); $subRequest = $utils->createRequest($request, '/foobar'); @@ -148,7 +148,7 @@ public function testCheckRequestPath() public function testCheckRequestPathWithUrlMatcherAndResourceNotFound() { - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); $urlMatcher ->expects($this->any()) ->method('match') @@ -163,7 +163,7 @@ public function testCheckRequestPathWithUrlMatcherAndResourceNotFound() public function testCheckRequestPathWithUrlMatcherAndMethodNotAllowed() { $request = $this->getRequest(); - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); + $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $urlMatcher ->expects($this->any()) ->method('matchRequest') @@ -177,7 +177,7 @@ public function testCheckRequestPathWithUrlMatcherAndMethodNotAllowed() public function testCheckRequestPathWithUrlMatcherAndResourceFoundByUrl() { - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); $urlMatcher ->expects($this->any()) ->method('match') @@ -192,7 +192,7 @@ public function testCheckRequestPathWithUrlMatcherAndResourceFoundByUrl() public function testCheckRequestPathWithUrlMatcherAndResourceFoundByRequest() { $request = $this->getRequest(); - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); + $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $urlMatcher ->expects($this->any()) ->method('matchRequest') @@ -209,7 +209,7 @@ public function testCheckRequestPathWithUrlMatcherAndResourceFoundByRequest() */ public function testCheckRequestPathWithUrlMatcherLoadingException() { - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); $urlMatcher ->expects($this->any()) ->method('match') @@ -250,7 +250,7 @@ public function testUrlGeneratorIsRequiredToGenerateUrl() private function getUrlGenerator($generatedUrl = '/foo/bar') { - $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); + $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $urlGenerator ->expects($this->any()) ->method('generate') diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php index 84745040c8aef..300f28dc6a657 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php @@ -22,7 +22,7 @@ public function testLogout() { $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $handler = new CookieClearingLogoutHandler(array('foo' => array('path' => '/foo', 'domain' => 'foo.foo'), 'foo2' => array('path' => null, 'domain' => null))); diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php index 8a94e5332d047..7f20f67b2b15f 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php @@ -18,10 +18,10 @@ class DefaultLogoutSuccessHandlerTest extends \PHPUnit_Framework_TestCase { public function testLogout() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $response = new Response(); - $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); + $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils->expects($this->once()) ->method('createRedirectResponse') ->with($request, '/dashboard') diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php index c3429951fc893..6a435d74baca0 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php @@ -20,9 +20,9 @@ public function testLogout() { $handler = new SessionLogoutHandler(); - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $response = new Response(); - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session', array(), array(), '', false); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); $request ->expects($this->once()) @@ -35,6 +35,6 @@ public function testLogout() ->method('invalidate') ; - $handler->logout($request, $response, $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $handler->logout($request, $response, $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); } } diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php index 7495398ec2825..84d11e78f40e0 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php @@ -62,7 +62,7 @@ public function testAutoLogin() $request = new Request(); $request->cookies->set('foo', 'foo'); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -90,7 +90,7 @@ public function testLogout(array $options) $service = $this->getService(null, $options); $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service->logout($request, $response, $token); $cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Cookie', $cookie); @@ -125,8 +125,8 @@ public function testLoginSuccessIsNotProcessedWhenTokenDoesNotContainUserInterfa $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null)); $request = new Request(); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -148,8 +148,8 @@ public function testLoginSuccessIsNotProcessedWhenRememberMeIsNotRequested() $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => false, 'remember_me_parameter' => 'foo', 'path' => null, 'domain' => null)); $request = new Request(); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -172,8 +172,8 @@ public function testLoginSuccessWhenRememberMeAlwaysIsTrue() $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null)); $request = new Request(); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -199,8 +199,8 @@ public function testLoginSuccessWhenRememberMeParameterWithPathIsPositive($value $request = new Request(); $request->request->set('foo', array('bar' => $value)); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -226,8 +226,8 @@ public function testLoginSuccessWhenRememberMeParameterIsPositive($value) $request = new Request(); $request->request->set('foo', $value); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -290,7 +290,7 @@ protected function getService($userProvider = null, $options = array(), $logger protected function getProvider() { - $provider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); $provider ->expects($this->any()) ->method('supportsClass') diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index 30cf4a231bdc8..6628b5bb5cb34 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -60,7 +60,7 @@ public function testAutoLoginThrowsExceptionOnNonExistentToken() $tokenValue = 'foovalue', ))); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -79,7 +79,7 @@ public function testAutoLoginReturnsNullOnNonExistentUser() $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -104,7 +104,7 @@ public function testAutoLoginThrowsExceptionOnStolenCookieAndRemovesItFromThePer $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $service->setTokenProvider($tokenProvider); $tokenProvider @@ -135,7 +135,7 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie() $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -150,7 +150,7 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie() public function testAutoLogin() { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -169,7 +169,7 @@ public function testAutoLogin() $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -192,9 +192,9 @@ public function testLogout() $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('deleteTokenBySeries') @@ -218,9 +218,9 @@ public function testLogoutSimplyIgnoresNonSetRequestCookie() $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null)); $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->never()) ->method('deleteTokenBySeries') @@ -241,9 +241,9 @@ public function testLogoutSimplyIgnoresInvalidCookie() $request = new Request(); $request->cookies->set('foo', 'somefoovalue'); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->never()) ->method('deleteTokenBySeries') @@ -271,20 +271,20 @@ public function testLoginSuccessSetsCookieWhenLoggedInWithNonRememberMeTokenInte $request = new Request(); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $account ->expects($this->once()) ->method('getUsername') ->will($this->returnValue('foo')) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->any()) ->method('getUser') ->will($this->returnValue($account)) ; - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('createNewToken') @@ -326,7 +326,7 @@ protected function getService($userProvider = null, $options = array(), $logger protected function getProvider() { - $provider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); $provider ->expects($this->any()) ->method('supportsClass') diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php index 23f7df70d3b60..0db86e7433996 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php @@ -83,7 +83,7 @@ private function getRequest(array $attributes = array()) private function getResponse() { $response = new Response(); - $response->headers = $this->getMock('Symfony\Component\HttpFoundation\ResponseHeaderBag'); + $response->headers = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->getMock(); return $response; } diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php index ee8a99e3da76e..ce1048e3ea039 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php @@ -62,7 +62,7 @@ public function testAutoLoginDoesNotAcceptCookieWithInvalidHash() $request = new Request(); $request->cookies->set('foo', base64_encode('class:'.base64_encode('foouser').':123456789:fooHash')); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getPassword') @@ -87,7 +87,7 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie() $request = new Request(); $request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time() - 1, 'foopass')); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getPassword') @@ -112,7 +112,7 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie() */ public function testAutoLogin($username) { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -156,7 +156,7 @@ public function testLogout() $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null, 'secure' => true, 'httponly' => false)); $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service->logout($request, $response, $token); @@ -186,7 +186,7 @@ public function testLoginSuccessIgnoresTokensWhichDoNotContainAnUserInterfaceImp $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null)); $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -208,8 +208,8 @@ public function testLoginSuccess() $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getPassword') @@ -272,7 +272,7 @@ protected function getService($userProvider = null, $options = array(), $logger protected function getProvider() { - $provider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); $provider ->expects($this->any()) ->method('supportsClass') diff --git a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php index a1f960fde4818..2d540748548cc 100644 --- a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php @@ -39,7 +39,7 @@ public function testUnsupportedStrategy() public function testSessionIsMigrated() { - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session->expects($this->once())->method('migrate')->with($this->equalTo(true)); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE); @@ -48,7 +48,7 @@ public function testSessionIsMigrated() public function testSessionIsInvalidated() { - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session->expects($this->once())->method('invalidate'); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::INVALIDATE); @@ -57,7 +57,7 @@ public function testSessionIsInvalidated() private function getRequest($session = null) { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); if (null !== $session) { $request->expects($this->any())->method('getSession')->will($this->returnValue($session)); @@ -68,6 +68,6 @@ private function getRequest($session = null) private function getToken() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } } diff --git a/src/Symfony/Component/Security/LICENSE b/src/Symfony/Component/Security/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Security/LICENSE +++ b/src/Symfony/Component/Security/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/Component/Security/Tests/Http/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index eca14d3c254aa..22ba421a7fedb 100644 --- a/src/Symfony/Component/Security/Tests/Http/Firewall/UsernamePasswordFormAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Firewall/UsernamePasswordFormAuthenticationListenerTest.php @@ -24,16 +24,16 @@ class UsernamePasswordFormAuthenticationListenerTest extends \PHPUnit_Framework_ public function testHandleWhenUsernameLength($username, $ok) { $request = Request::create('/login_check', 'POST', array('_username' => $username)); - $request->setSession($this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface')); + $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); - $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); + $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils ->expects($this->any()) ->method('checkRequestPath') ->will($this->returnValue(true)) ; - $failureHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface'); + $failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); $failureHandler ->expects($ok ? $this->never() : $this->once()) ->method('onAuthenticationFailure') @@ -48,17 +48,17 @@ public function testHandleWhenUsernameLength($username, $ok) ; $listener = new UsernamePasswordFormAuthenticationListener( - $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), $authenticationManager, - $this->getMock('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface'), + $this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(), $httpUtils, 'TheProviderKey', - $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface'), + $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(), $failureHandler, array('require_previous_session' => false) ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') diff --git a/src/Symfony/Component/Serializer/Annotation/MaxDepth.php b/src/Symfony/Component/Serializer/Annotation/MaxDepth.php index 69fd806753e86..1f41948d6da25 100644 --- a/src/Symfony/Component/Serializer/Annotation/MaxDepth.php +++ b/src/Symfony/Component/Serializer/Annotation/MaxDepth.php @@ -30,8 +30,8 @@ class MaxDepth public function __construct(array $data) { - if (!isset($data['value']) || !$data['value']) { - throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', get_class($this))); + if (!isset($data['value'])) { + throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', get_class($this))); } if (!is_int($data['value']) || $data['value'] <= 0) { diff --git a/src/Symfony/Component/Serializer/LICENSE b/src/Symfony/Component/Serializer/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Serializer/LICENSE +++ b/src/Symfony/Component/Serializer/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/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index 937154a89b3cd..9edd332481736 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Serializer\Normalizer; use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException; +use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Exception\CircularReferenceException; use Symfony\Component\Serializer\Exception\LogicException; use Symfony\Component\Serializer\Exception\UnexpectedValueException; @@ -260,6 +261,16 @@ private function validateAndDenormalize($currentClass, $attribute, $data, $forma } } + // JSON only has a Number type corresponding to both int and float PHP types. + // PHP's json_encode, JavaScript's JSON.stringify, Go's json.Marshal as well as most other JSON encoders convert + // floating-point numbers like 12.0 to 12 (the decimal part is dropped when possible). + // PHP's json_decode automatically converts Numbers without a decimal part to integers. + // To circumvent this behavior, integers are converted to floats when denormalizing JSON based formats and when + // a float is expected. + if (Type::BUILTIN_TYPE_FLOAT === $builtinType && is_int($data) && false !== strpos($format, JsonEncoder::FORMAT)) { + return (float) $data; + } + if (call_user_func('is_'.$builtinType, $data)) { return $data; } diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php index 5594cb5f1b9d8..d281c1d269a27 100644 --- a/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php +++ b/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php @@ -20,26 +20,32 @@ class MaxDepthTest extends \PHPUnit_Framework_TestCase { /** * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException + * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" should be set. */ public function testNotSetMaxDepthParameter() { new MaxDepth(array()); } - /** - * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException - */ - public function testEmptyMaxDepthParameter() + public function provideInvalidValues() { - new MaxDepth(array('value' => '')); + return array( + array(''), + array('foo'), + array('1'), + array(0), + ); } /** + * @dataProvider provideInvalidValues + * * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException + * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" must be a positive integer. */ - public function testNotAnIntMaxDepthParameter() + public function testNotAnIntMaxDepthParameter($value) { - new MaxDepth(array('value' => 'foo')); + new MaxDepth(array('value' => $value)); } public function testMaxDepthParameters() diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php index 629c17b788d23..9ce3d020bc1c5 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php @@ -28,10 +28,10 @@ public function testAttributeMetadata() { $classMetadata = new ClassMetadata('c'); - $a1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface'); + $a1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock(); $a1->method('getName')->willReturn('a1'); - $a2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface'); + $a2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock(); $a2->method('getName')->willReturn('a2'); $classMetadata->addAttributeMetadata($a1); @@ -45,11 +45,11 @@ public function testMerge() $classMetadata1 = new ClassMetadata('c1'); $classMetadata2 = new ClassMetadata('c2'); - $ac1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface'); + $ac1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock(); $ac1->method('getName')->willReturn('a1'); $ac1->method('getGroups')->willReturn(array('a', 'b')); - $ac2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface'); + $ac2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock(); $ac2->method('getName')->willReturn('a1'); $ac2->method('getGroups')->willReturn(array('b', 'c')); @@ -67,10 +67,10 @@ public function testSerialize() { $classMetadata = new ClassMetadata('a'); - $a1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface'); + $a1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock(); $a1->method('getName')->willReturn('b1'); - $a2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface'); + $a2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock(); $a2->method('getName')->willReturn('b2'); $classMetadata->addAttributeMetadata($a1); diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php index e6b9a60d1de86..01888dc42a9f9 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php @@ -26,7 +26,7 @@ public function testGetMetadataFor() { $metadata = new ClassMetadata(Dummy::class); - $decorated = $this->getMock(ClassMetadataFactoryInterface::class); + $decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); $decorated ->expects($this->once()) ->method('getMetadataFor') @@ -42,7 +42,7 @@ public function testGetMetadataFor() public function testHasMetadataFor() { - $decorated = $this->getMock(ClassMetadataFactoryInterface::class); + $decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); $decorated ->expects($this->once()) ->method('hasMetadataFor') @@ -59,7 +59,7 @@ public function testHasMetadataFor() */ public function testInvalidClassThrowsException() { - $decorated = $this->getMock(ClassMetadataFactoryInterface::class); + $decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter()); $factory->getMetadataFor('Not\Exist'); diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php index a237c32313b12..1219da680eeaa 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php @@ -50,7 +50,7 @@ public function testHasMetadataFor() */ public function testCacheExists() { - $cache = $this->getMock('Doctrine\Common\Cache\Cache'); + $cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock(); $cache ->expects($this->once()) ->method('fetch') @@ -66,7 +66,7 @@ public function testCacheExists() */ public function testCacheNotExists() { - $cache = $this->getMock('Doctrine\Common\Cache\Cache'); + $cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock(); $cache->method('fetch')->will($this->returnValue(false)); $cache->method('save'); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php index 66ac992350319..6f550369f663e 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php @@ -29,8 +29,8 @@ class AbstractNormalizerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $loader = $this->getMock('Symfony\Component\Serializer\Mapping\Loader\LoaderChain', array(), array(array())); - $this->classMetadata = $this->getMock('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory', array(), array($loader)); + $loader = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\Loader\LoaderChain')->setConstructorArgs(array(array()))->getMock(); + $this->classMetadata = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory')->setConstructorArgs(array($loader))->getMock(); $this->normalizer = new AbstractNormalizerDummy($this->classMetadata); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php index 23014f300ec7c..5edb2235774dc 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php @@ -28,7 +28,7 @@ class ArrayDenormalizerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->serializer = $this->getMock('Symfony\Component\Serializer\Serializer'); + $this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')->getMock(); $this->denormalizer = new ArrayDenormalizer(); $this->denormalizer->setSerializer($this->serializer); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 959e2dbf57dd7..0e697b4b90b1d 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -37,7 +37,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->serializer = $this->getMock(__NAMESPACE__.'\SerializerNormalizer'); + $this->serializer = $this->getMockBuilder(__NAMESPACE__.'\SerializerNormalizer')->getMock(); $this->normalizer = new GetSetMethodNormalizer(); $this->normalizer->setSerializer($this->serializer); } @@ -394,7 +394,7 @@ public function provideCallbacks() */ public function testUnableToNormalizeObjectAttribute() { - $serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface'); + $serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock(); $this->normalizer->setSerializer($serializer); $obj = new GetSetDummy(); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php index 2ef6eaa0e36ea..818e9c8b8d9b2 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php @@ -33,7 +33,7 @@ class JsonSerializableNormalizerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->serializer = $this->getMock(JsonSerializerNormalizer::class); + $this->serializer = $this->getMockBuilder(JsonSerializerNormalizer::class)->getMock(); $this->normalizer = new JsonSerializableNormalizer(); $this->normalizer->setSerializer($this->serializer); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 7a04da0da64ba..72f035462cdb9 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -45,7 +45,7 @@ class ObjectNormalizerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->serializer = $this->getMock(__NAMESPACE__.'\ObjectSerializerNormalizer'); + $this->serializer = $this->getMockBuilder(__NAMESPACE__.'\ObjectSerializerNormalizer')->getMock(); $this->normalizer = new ObjectNormalizer(); $this->normalizer->setSerializer($this->serializer); } @@ -394,7 +394,7 @@ public function provideCallbacks() */ public function testUnableToNormalizeObjectAttribute() { - $serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface'); + $serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock(); $this->normalizer->setSerializer($serializer); $obj = new ObjectDummy(); @@ -537,11 +537,21 @@ public function testDenomalizeRecursive() 'inners' => array(array('foo' => 1), array('foo' => 2)), ), ObjectOuter::class); - $this->assertEquals('foo', $obj->getInner()->foo); - $this->assertEquals('bar', $obj->getInner()->bar); - $this->assertEquals('1988-01-21', $obj->getDate()->format('Y-m-d')); - $this->assertEquals(1, $obj->getInners()[0]->foo); - $this->assertEquals(2, $obj->getInners()[1]->foo); + $this->assertSame('foo', $obj->getInner()->foo); + $this->assertSame('bar', $obj->getInner()->bar); + $this->assertSame('1988-01-21', $obj->getDate()->format('Y-m-d')); + $this->assertSame(1, $obj->getInners()[0]->foo); + $this->assertSame(2, $obj->getInners()[1]->foo); + } + + public function testAcceptJsonNumber() + { + $extractor = new PropertyInfoExtractor(array(), array(new PhpDocExtractor(), new ReflectionExtractor())); + $normalizer = new ObjectNormalizer(null, null, null, $extractor); + $serializer = new Serializer(array(new ArrayDenormalizer(), new DateTimeNormalizer(), $normalizer)); + + $this->assertSame(10.0, $serializer->denormalize(array('number' => 10), JsonNumber::class, 'json')->number); + $this->assertSame(10.0, $serializer->denormalize(array('number' => 10), JsonNumber::class, 'jsonld')->number); } /** @@ -820,3 +830,11 @@ protected function isAllowedAttribute($classOrObject, $attribute, $format = null return false; } } + +class JsonNumber +{ + /** + * @var float + */ + public $number; +} diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php index 9da80e36936ed..5ac378a1ff78b 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php @@ -36,7 +36,7 @@ class PropertyNormalizerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface'); + $this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock(); $this->normalizer = new PropertyNormalizer(); $this->normalizer->setSerializer($this->serializer); } @@ -353,7 +353,7 @@ public function testDenormalizeShouldIgnoreStaticProperty() */ public function testUnableToNormalizeObjectAttribute() { - $serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface'); + $serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock(); $this->normalizer->setSerializer($serializer); $obj = new PropertyDummy(); diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index 362357864c463..1a9a6b4b5496c 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -45,7 +45,7 @@ public function testInterface() */ public function testNormalizeNoMatch() { - $serializer = new Serializer(array($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer'))); + $serializer = new Serializer(array($this->getMockBuilder('Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock())); $serializer->normalize(new \stdClass(), 'xml'); } @@ -77,7 +77,7 @@ public function testNormalizeOnDenormalizer() */ public function testDenormalizeNoMatch() { - $serializer = new Serializer(array($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer'))); + $serializer = new Serializer(array($this->getMockBuilder('Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock())); $serializer->denormalize('foo', 'stdClass'); } @@ -102,14 +102,14 @@ public function testCustomNormalizerCanNormalizeCollectionsAndScalar() public function testNormalizeWithSupportOnData() { - $normalizer1 = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface'); + $normalizer1 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\NormalizerInterface')->getMock(); $normalizer1->method('supportsNormalization') ->willReturnCallback(function ($data, $format) { return isset($data->test); }); $normalizer1->method('normalize')->willReturn('test1'); - $normalizer2 = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface'); + $normalizer2 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\NormalizerInterface')->getMock(); $normalizer2->method('supportsNormalization') ->willReturn(true); $normalizer2->method('normalize')->willReturn('test2'); @@ -125,14 +125,14 @@ public function testNormalizeWithSupportOnData() public function testDenormalizeWithSupportOnData() { - $denormalizer1 = $this->getMock('Symfony\Component\Serializer\Normalizer\DenormalizerInterface'); + $denormalizer1 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\DenormalizerInterface')->getMock(); $denormalizer1->method('supportsDenormalization') ->willReturnCallback(function ($data, $type, $format) { return isset($data['test1']); }); $denormalizer1->method('denormalize')->willReturn('test1'); - $denormalizer2 = $this->getMock('Symfony\Component\Serializer\Normalizer\DenormalizerInterface'); + $denormalizer2 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\DenormalizerInterface')->getMock(); $denormalizer2->method('supportsDenormalization') ->willReturn(true); $denormalizer2->method('denormalize')->willReturn('test2'); @@ -319,7 +319,7 @@ public function testDeserializeArray() public function testNormalizerAware() { - $normalizerAware = $this->getMock(NormalizerAwareInterface::class); + $normalizerAware = $this->getMockBuilder(NormalizerAwareInterface::class)->getMock(); $normalizerAware->expects($this->once()) ->method('setNormalizer') ->with($this->isInstanceOf(NormalizerInterface::class)); @@ -329,7 +329,7 @@ public function testNormalizerAware() public function testDenormalizerAware() { - $denormalizerAware = $this->getMock(DenormalizerAwareInterface::class); + $denormalizerAware = $this->getMockBuilder(DenormalizerAwareInterface::class)->getMock(); $denormalizerAware->expects($this->once()) ->method('setDenormalizer') ->with($this->isInstanceOf(DenormalizerInterface::class)); diff --git a/src/Symfony/Component/Stopwatch/LICENSE b/src/Symfony/Component/Stopwatch/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Stopwatch/LICENSE +++ b/src/Symfony/Component/Stopwatch/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/Component/Stopwatch/Section.php b/src/Symfony/Component/Stopwatch/Section.php index fb416efedce23..2337e03140c7f 100644 --- a/src/Symfony/Component/Stopwatch/Section.php +++ b/src/Symfony/Component/Stopwatch/Section.php @@ -53,7 +53,7 @@ public function __construct($origin = null) * * @param string $id The child section identifier * - * @return Section|null The child section or null when none found + * @return self|null The child section or null when none found */ public function get($id) { @@ -69,7 +69,7 @@ public function get($id) * * @param string|null $id null to create a new section, the identifier to re-open an existing one * - * @return Section A child section + * @return self */ public function open($id) { @@ -93,7 +93,7 @@ public function getId() * * @param string $id The session identifier * - * @return Section The current section + * @return $this */ public function setId($id) { diff --git a/src/Symfony/Component/Stopwatch/Stopwatch.php b/src/Symfony/Component/Stopwatch/Stopwatch.php index 44f18d5e4252f..8ad93165bfd74 100644 --- a/src/Symfony/Component/Stopwatch/Stopwatch.php +++ b/src/Symfony/Component/Stopwatch/Stopwatch.php @@ -90,7 +90,7 @@ public function stopSection($id) * @param string $name The event name * @param string $category The event category * - * @return StopwatchEvent A StopwatchEvent instance + * @return StopwatchEvent */ public function start($name, $category = null) { @@ -114,7 +114,7 @@ public function isStarted($name) * * @param string $name The event name * - * @return StopwatchEvent A StopwatchEvent instance + * @return StopwatchEvent */ public function stop($name) { @@ -126,7 +126,7 @@ public function stop($name) * * @param string $name The event name * - * @return StopwatchEvent A StopwatchEvent instance + * @return StopwatchEvent */ public function lap($name) { @@ -138,7 +138,7 @@ public function lap($name) * * @param string $name The event name * - * @return StopwatchEvent A StopwatchEvent instance + * @return StopwatchEvent */ public function getEvent($name) { @@ -150,7 +150,7 @@ public function getEvent($name) * * @param string $id A section identifier * - * @return StopwatchEvent[] An array of StopwatchEvent instances + * @return StopwatchEvent[] */ public function getSectionEvents($id) { diff --git a/src/Symfony/Component/Stopwatch/StopwatchEvent.php b/src/Symfony/Component/Stopwatch/StopwatchEvent.php index 957a5d0dae0a8..16a30db2aa50e 100644 --- a/src/Symfony/Component/Stopwatch/StopwatchEvent.php +++ b/src/Symfony/Component/Stopwatch/StopwatchEvent.php @@ -75,7 +75,7 @@ public function getOrigin() /** * Starts a new event period. * - * @return StopwatchEvent The event + * @return $this */ public function start() { @@ -87,7 +87,7 @@ public function start() /** * Stops the last started event period. * - * @return StopwatchEvent The event + * @return $this * * @throws \LogicException When stop() is called without a matching call to start() */ @@ -115,7 +115,7 @@ public function isStarted() /** * Stops the current period and then starts a new one. * - * @return StopwatchEvent The event + * @return $this */ public function lap() { diff --git a/src/Symfony/Component/Templating/LICENSE b/src/Symfony/Component/Templating/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Templating/LICENSE +++ b/src/Symfony/Component/Templating/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/Component/Templating/TemplateReferenceInterface.php b/src/Symfony/Component/Templating/TemplateReferenceInterface.php index c687c5350b0d3..45d9421f6b406 100644 --- a/src/Symfony/Component/Templating/TemplateReferenceInterface.php +++ b/src/Symfony/Component/Templating/TemplateReferenceInterface.php @@ -31,7 +31,7 @@ public function all(); * @param string $name The parameter name * @param string $value The parameter value * - * @return TemplateReferenceInterface The TemplateReferenceInterface instance + * @return $this * * @throws \InvalidArgumentException if the parameter name is not supported */ diff --git a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php index e9cb5fc472066..bf82ed51fcfc1 100644 --- a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php @@ -126,7 +126,7 @@ public function testGetInvalidEngine() 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') diff --git a/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php index 01896c2e18e1f..344f3d07cf06f 100644 --- a/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php +++ b/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php @@ -34,7 +34,7 @@ public function testLoad() $loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir); $this->assertFalse($loader->load(new TemplateReference('foo', 'php')), '->load() returns false if the embed loader is not able to load the template'); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger ->expects($this->once()) ->method('debug') @@ -42,7 +42,7 @@ public function testLoad() $loader->setLogger($logger); $loader->load(new TemplateReference('index')); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger ->expects($this->once()) ->method('debug') diff --git a/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php index 939d6753a75d7..b7e1197960726 100644 --- a/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php @@ -58,7 +58,7 @@ public function testLoad() $this->assertInstanceOf('Symfony\Component\Templating\Storage\FileStorage', $storage, '->load() returns a FileStorage if you pass a relative template that exists'); $this->assertEquals($path.'/foo.php', (string) $storage, '->load() returns a FileStorage pointing to the absolute path of the template'); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->exactly(2))->method('debug'); $loader = new ProjectTemplateLoader2($pathPattern); diff --git a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php index d198bdda5f257..de2e992119f62 100644 --- a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php @@ -19,7 +19,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase public function testGetSetLogger() { $loader = new ProjectTemplateLoader4(); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $loader->setLogger($logger); $this->assertSame($logger, $loader->getLogger(), '->setLogger() sets the logger instance'); } diff --git a/src/Symfony/Component/Translation/LICENSE b/src/Symfony/Component/Translation/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Translation/LICENSE +++ b/src/Symfony/Component/Translation/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/Component/Translation/MessageCatalogueInterface.php b/src/Symfony/Component/Translation/MessageCatalogueInterface.php index b1b516dc289c9..40054f05c4c18 100644 --- a/src/Symfony/Component/Translation/MessageCatalogueInterface.php +++ b/src/Symfony/Component/Translation/MessageCatalogueInterface.php @@ -105,7 +105,7 @@ public function add($messages, $domain = 'messages'); * * The two catalogues must have the same locale. * - * @param MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance + * @param self $catalogue */ public function addCatalogue(MessageCatalogueInterface $catalogue); @@ -115,14 +115,14 @@ public function addCatalogue(MessageCatalogueInterface $catalogue); * * This is used to provide default translations when they do not exist for the current locale. * - * @param MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance + * @param self $catalogue */ public function addFallbackCatalogue(MessageCatalogueInterface $catalogue); /** * Gets the fallback catalogue. * - * @return MessageCatalogueInterface|null A MessageCatalogueInterface instance or null when no fallback has been set + * @return self|null A MessageCatalogueInterface instance or null when no fallback has been set */ public function getFallbackCatalogue(); diff --git a/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php b/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php index 9f3e849bf4fda..66e9d587dedfd 100644 --- a/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php @@ -19,7 +19,7 @@ class LoggingTranslatorTest extends \PHPUnit_Framework_TestCase { public function testTransWithNoTranslationIsLogged() { - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->exactly(2)) ->method('warning') ->with('Translation not found.') @@ -33,7 +33,7 @@ public function testTransWithNoTranslationIsLogged() public function testTransChoiceFallbackIsLogged() { - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->once()) ->method('debug') ->with('Translation use fallback catalogue.') diff --git a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php index e5bb9810045f0..eb18dae0a1e7e 100644 --- a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php @@ -82,10 +82,10 @@ public function testReplace() public function testAddCatalogue() { - $r = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface'); + $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); $r->expects($this->any())->method('__toString')->will($this->returnValue('r')); - $r1 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface'); + $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1')); $catalogue = new MessageCatalogue('en', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar'))); @@ -104,13 +104,13 @@ public function testAddCatalogue() public function testAddFallbackCatalogue() { - $r = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface'); + $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); $r->expects($this->any())->method('__toString')->will($this->returnValue('r')); - $r1 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface'); + $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1')); - $r2 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface'); + $r2 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); $r2->expects($this->any())->method('__toString')->will($this->returnValue('r2')); $catalogue = new MessageCatalogue('fr_FR', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar'))); @@ -169,11 +169,11 @@ public function testAddCatalogueWhenLocaleIsNotTheSameAsTheCurrentOne() public function testGetAddResource() { $catalogue = new MessageCatalogue('en'); - $r = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface'); + $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); $r->expects($this->any())->method('__toString')->will($this->returnValue('r')); $catalogue->addResource($r); $catalogue->addResource($r); - $r1 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface'); + $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1')); $catalogue->addResource($r1); diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php index 75093580b472b..3726ccfdc0965 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php @@ -95,7 +95,7 @@ public function testCatalogueIsReloadedWhenResourcesAreNoLongerFresh() $catalogue->addResource(new StaleResource()); // better use a helper class than a mock, because it gets serialized in the cache and re-loaded /** @var LoaderInterface|\PHPUnit_Framework_MockObject_MockObject $loader */ - $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader ->expects($this->exactly(2)) ->method('load') @@ -228,8 +228,8 @@ public function testPrimaryAndFallbackCataloguesContainTheSameMessagesRegardless public function testRefreshCacheWhenResourcesAreNoLongerFresh() { - $resource = $this->getMock('Symfony\Component\Config\Resource\SelfCheckingResourceInterface'); - $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); + $resource = $this->getMockBuilder('Symfony\Component\Config\Resource\SelfCheckingResourceInterface')->getMock(); + $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $resource->method('isFresh')->will($this->returnValue(false)); $loader ->expects($this->exactly(2)) @@ -272,7 +272,7 @@ public function runForDebugAndProduction() */ private function createFailingLoader() { - $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/Component/Translation/Tests/Writer/TranslationWriterTest.php b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php index f7a8a83d2437e..041a83679a080 100644 --- a/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php +++ b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php @@ -19,7 +19,7 @@ class TranslationWriterTest extends \PHPUnit_Framework_TestCase { public function testWriteTranslations() { - $dumper = $this->getMock('Symfony\Component\Translation\Dumper\DumperInterface'); + $dumper = $this->getMockBuilder('Symfony\Component\Translation\Dumper\DumperInterface')->getMock(); $dumper ->expects($this->once()) ->method('dump'); diff --git a/src/Symfony/Component/Validator/LICENSE b/src/Symfony/Component/Validator/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Validator/LICENSE +++ b/src/Symfony/Component/Validator/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/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 2819ce1553ce2..2f19a3fed8bcb 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -219,7 +219,7 @@ public function addConstraint(Constraint $constraint) * @param string $property The name of the property * @param Constraint $constraint The constraint * - * @return ClassMetadata This object + * @return $this */ public function addPropertyConstraint($property, Constraint $constraint) { @@ -240,7 +240,7 @@ public function addPropertyConstraint($property, Constraint $constraint) * @param string $property * @param Constraint[] $constraints * - * @return ClassMetadata + * @return $this */ public function addPropertyConstraints($property, array $constraints) { @@ -260,7 +260,7 @@ public function addPropertyConstraints($property, array $constraints) * @param string $property The name of the property * @param Constraint $constraint The constraint * - * @return ClassMetadata This object + * @return $this */ public function addGetterConstraint($property, Constraint $constraint) { @@ -281,7 +281,7 @@ public function addGetterConstraint($property, Constraint $constraint) * @param string $property * @param Constraint[] $constraints * - * @return ClassMetadata + * @return $this */ public function addGetterConstraints($property, array $constraints) { @@ -304,11 +304,18 @@ public function mergeConstraints(ClassMetadata $source) } foreach ($source->getConstrainedProperties() as $property) { + if ($this->hasPropertyMetadata($property)) { + continue; + } + foreach ($source->getPropertyMetadata($property) as $member) { $member = clone $member; foreach ($member->getConstraints() as $constraint) { - $member->constraintsByGroup[$this->getDefaultGroup()][] = $constraint; + if (in_array($constraint::DEFAULT_GROUP, $constraint->groups, true)) { + $member->constraintsByGroup[$this->getDefaultGroup()][] = $constraint; + } + $constraint->addImplicitGroupName($this->getDefaultGroup()); } @@ -360,7 +367,7 @@ public function getConstrainedProperties() * * @param array $groupSequence An array of group names * - * @return ClassMetadata + * @return $this * * @throws GroupDefinitionException */ diff --git a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php index f5894f49b093a..79ad1f228b79f 100644 --- a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php +++ b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php @@ -99,8 +99,11 @@ public function getMetadataFor($value) return $this->loadedClasses[$class]; } - if (null !== $this->cache && false !== ($this->loadedClasses[$class] = $this->cache->read($class))) { - return $this->loadedClasses[$class]; + if (null !== $this->cache && false !== ($metadata = $this->cache->read($class))) { + // Include constraints from the parent class + $this->mergeConstraints($metadata); + + return $this->loadedClasses[$class] = $metadata; } if (!class_exists($class) && !interface_exists($class)) { @@ -109,6 +112,22 @@ public function getMetadataFor($value) $metadata = new ClassMetadata($class); + if (null !== $this->loader) { + $this->loader->loadClassMetadata($metadata); + } + + if (null !== $this->cache) { + $this->cache->write($metadata); + } + + // Include constraints from the parent class + $this->mergeConstraints($metadata); + + return $this->loadedClasses[$class] = $metadata; + } + + private function mergeConstraints(ClassMetadata $metadata) + { // Include constraints from the parent class if ($parent = $metadata->getReflectionClass()->getParentClass()) { $metadata->mergeConstraints($this->getMetadataFor($parent->name)); @@ -139,16 +158,6 @@ public function getMetadataFor($value) } $metadata->mergeConstraints($this->getMetadataFor($interface->name)); } - - if (null !== $this->loader) { - $this->loader->loadClassMetadata($metadata); - } - - if (null !== $this->cache) { - $this->cache->write($metadata); - } - - return $this->loadedClasses[$class] = $metadata; } /** diff --git a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php index 147c021b21594..ff1cb6d37f89e 100644 --- a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php @@ -116,7 +116,7 @@ public function __clone() * * @param Constraint $constraint The constraint to add * - * @return GenericMetadata This object + * @return $this * * @throws ConstraintDefinitionException When trying to add the * {@link Traverse} constraint @@ -157,7 +157,7 @@ public function addConstraint(Constraint $constraint) * * @param Constraint[] $constraints The constraints to add * - * @return GenericMetadata This object + * @return $this */ public function addConstraints(array $constraints) { diff --git a/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php index 77a556b5b8eeb..8bcdf9f97ef94 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php @@ -84,7 +84,7 @@ protected function parseConstraints(\SimpleXMLElement $nodes) $options = array(); } } elseif (strlen((string) $node) > 0) { - $options = trim($node); + $options = XmlUtils::phpize(trim($node)); } else { $options = null; } diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf index c7061470dc16a..ce8db48639efc 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf @@ -310,6 +310,10 @@ This value does not match the expected {{ charset }} charset. Nilai ini tidak memenuhi set karakter {{ charset }} yang diharapkan. + + This is not a valid Business Identifier Code (BIC). + Ini bukan Business Identifier Code (BIC) yang sah. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf index 5a9347652a911..250576531cfe4 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf @@ -12,11 +12,11 @@ This value should be of type {{ type }}. - Verdien må være av typen {{ type }}. + Verdien skal ha typen {{ type }}. This value should be blank. - Verdien må være blank. + Verdien skal være blank. The value you selected is not a valid choice. @@ -88,19 +88,19 @@ This value should not be blank. - Verdien må ikke være blank. + Verdien kan ikke være blank. This value should not be null. - Verdien må ikke være tom (null). + Verdien kan ikke være tom (null). This value should be null. - Verdien må være tom (null). + Verdien skal være tom (null). This value is not valid. - Verdien er ikke gyldig. + Verdien er ugyldig. This value is not a valid time. @@ -112,7 +112,7 @@ The two values should be equal. - Verdiene må være identiske. + Verdiene skal være identiske. The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. @@ -128,7 +128,7 @@ This value should be a valid number. - Verdien må være et gyldig tall. + Verdien skal være et gyldig tall. This file is not a valid image. @@ -176,11 +176,11 @@ This value should be the user's current password. - Verdien må være brukerens sitt nåværende passord. + Verdien skal være brukerens sitt nåværende passord. This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. - Verdien må være nøyaktig {{ limit }} tegn. + Verdien skal være nøyaktig {{ limit }} tegn. The file was only partially uploaded. @@ -220,11 +220,11 @@ Unsupported card type or invalid card number. - Korttypen er ikke støttet eller ugyldig kortnummer. + Korttypen er ikke støttet eller kortnummeret er ugyldig. This is not a valid International Bank Account Number (IBAN). - Dette er ikke en gyldig IBAN. + Dette er ikke et gyldig IBAN-nummer. This value is not a valid ISBN-10. @@ -248,43 +248,43 @@ This value should be equal to {{ compared_value }}. - Verdien må være lik {{ compared_value }}. + Verdien skal være lik {{ compared_value }}. This value should be greater than {{ compared_value }}. - Verdien må være større enn {{ compared_value }}. + Verdien skal være større enn {{ compared_value }}. This value should be greater than or equal to {{ compared_value }}. - Verdien må være større enn eller lik {{ compared_value }}. + Verdien skal være større enn eller lik {{ compared_value }}. This value should be identical to {{ compared_value_type }} {{ compared_value }}. - Verdien må være identisk med {{ compared_value_type }} {{ compared_value }}. + Verdien skal være identisk med {{ compared_value_type }} {{ compared_value }}. This value should be less than {{ compared_value }}. - Verdien må være mindre enn {{ compared_value }}. + Verdien skal være mindre enn {{ compared_value }}. This value should be less than or equal to {{ compared_value }}. - Verdien må være mindre enn eller lik {{ compared_value }}. + Verdien skal være mindre enn eller lik {{ compared_value }}. This value should not be equal to {{ compared_value }}. - Verdien må ikke være lik {{ compared_value }}. + Verdien skal ikke være lik {{ compared_value }}. This value should not be identical to {{ compared_value_type }} {{ compared_value }}. - Verdien må ikke være identisk med {{ compared_value_type }} {{ compared_value }}. + Verdien skal ikke være identisk med {{ compared_value_type }} {{ compared_value }}. The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}. - Bildeforholdet er for stort ({{ ratio }}). Tillatt maksimumsbildeforhold er {{ max_ratio }}. + Bildeforholdet er for stort ({{ ratio }}). Tillatt bildeforhold er maks {{ max_ratio }}. The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}. - Bildeforholdet er for lite ({{ ratio }}). Forventet maksimumsbildeforhold er {{ min_ratio }}. + Bildeforholdet er for lite ({{ ratio }}). Forventet bildeforhold er minst {{ min_ratio }}. The image is square ({{ width }}x{{ height }}px). Square images are not allowed. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf index c40f76ee88eda..ae4ed1df73c26 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf @@ -36,11 +36,11 @@ This field was not expected. - To pole nie spodziewano. + Tego pola się nie spodziewano. This field is missing. - To pole jest chybianie. + Tego pola brakuje. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php index 3772a4d506aed..3dc2b9499e2b9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php @@ -91,9 +91,9 @@ protected function restoreDefaultTimezone() protected function createContext() { - $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); - $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); - $contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface'); + $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); + $validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); + $contextualValidator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock(); $context = new ExecutionContext($validator, $this->root, $translator); $context->setGroup($this->group); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index c76920fbb20d4..d333a0a1cbb8b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -217,7 +217,7 @@ public function testExpressionLanguageUsage() 'expression' => 'false', )); - $expressionLanguage = $this->getMock('Symfony\Component\ExpressionLanguage\ExpressionLanguage'); + $expressionLanguage = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ExpressionLanguage')->getMock(); $used = false; diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php index 34c62445a428b..99b15aa9a4cc8 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Validator\Tests\Mapping; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\GreaterThan; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; @@ -134,6 +135,7 @@ public function testMergeConstraintsMergesMemberConstraints() { $parent = new ClassMetadata(self::PARENTCLASS); $parent->addPropertyConstraint('firstName', new ConstraintA()); + $parent->addPropertyConstraint('firstName', new ConstraintB(array('groups' => 'foo'))); $this->metadata->mergeConstraints($parent); $this->metadata->addPropertyConstraint('firstName', new ConstraintA()); @@ -147,9 +149,13 @@ public function testMergeConstraintsMergesMemberConstraints() 'Default', 'Entity', ))); + $constraintB = new ConstraintB(array( + 'groups' => array('foo'), + )); $constraints = array( $constraintA1, + $constraintB, $constraintA2, ); @@ -165,6 +171,9 @@ public function testMergeConstraintsMergesMemberConstraints() $constraintA1, $constraintA2, ), + 'foo' => array( + $constraintB, + ), ); $members = $this->metadata->getPropertyMetadata('firstName'); @@ -295,4 +304,29 @@ public function testGetPropertyMetadataReturnsEmptyArrayWithoutConfiguredMetadat { $this->assertCount(0, $this->metadata->getPropertyMetadata('foo'), '->getPropertyMetadata() returns an empty collection if no metadata is configured for the given property'); } + + public function testMergeDoesOverrideConstraintsFromParentClassIfPropertyIsOverriddenInChildClass() + { + $parentMetadata = new ClassMetadata('\Symfony\Component\Validator\Tests\Mapping\ParentClass'); + $parentMetadata->addPropertyConstraint('example', new GreaterThan(0)); + + $childMetadata = new ClassMetadata('\Symfony\Component\Validator\Tests\Mapping\ChildClass'); + $childMetadata->addPropertyConstraint('example', new GreaterThan(1)); + $childMetadata->mergeConstraints($parentMetadata); + + $expectedMetadata = new ClassMetadata('\Symfony\Component\Validator\Tests\Mapping\ChildClass'); + $expectedMetadata->addPropertyConstraint('example', new GreaterThan(1)); + + $this->assertEquals($expectedMetadata, $childMetadata); + } +} + +class ParentClass +{ + public $example = 0; +} + +class ChildClass extends ParentClass +{ + public $example = 1; // overrides parent property of same name } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php index c1aaa9f8c7bf2..9696744166537 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Mapping\Factory; +use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; @@ -30,8 +31,8 @@ public function testLoadClassMetadataWithInterface() $metadata = $factory->getMetadataFor(self::PARENT_CLASS); $constraints = array( - new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA', 'EntityParent'))), new ConstraintA(array('groups' => array('Default', 'EntityParent'))), + new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA', 'EntityParent'))), ); $this->assertEquals($constraints, $metadata->getConstraints()); @@ -45,8 +46,6 @@ public function testMergeParentConstraints() $constraints = array( new ConstraintA(array('groups' => array( 'Default', - 'EntityInterfaceA', - 'EntityParent', 'Entity', ))), new ConstraintA(array('groups' => array( @@ -56,8 +55,8 @@ public function testMergeParentConstraints() ))), new ConstraintA(array('groups' => array( 'Default', - 'EntityParentInterface', - 'EntityInterfaceB', + 'EntityInterfaceA', + 'EntityParent', 'Entity', ))), new ConstraintA(array('groups' => array( @@ -67,6 +66,8 @@ public function testMergeParentConstraints() ))), new ConstraintA(array('groups' => array( 'Default', + 'EntityParentInterface', + 'EntityInterfaceB', 'Entity', ))), ); @@ -76,12 +77,12 @@ public function testMergeParentConstraints() public function testWriteMetadataToCache() { - $cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface'); + $cache = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock(); $factory = new LazyLoadingMetadataFactory(new TestLoader(), $cache); $parentClassConstraints = array( - new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA', 'EntityParent'))), new ConstraintA(array('groups' => array('Default', 'EntityParent'))), + new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA', 'EntityParent'))), ); $interfaceAConstraints = array( new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA'))), @@ -115,24 +116,58 @@ public function testWriteMetadataToCache() public function testReadMetadataFromCache() { - $loader = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface'); - $cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); + $cache = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock(); $factory = new LazyLoadingMetadataFactory($loader, $cache); $metadata = new ClassMetadata(self::PARENT_CLASS); $metadata->addConstraint(new ConstraintA()); + $parentClass = self::PARENT_CLASS; + $interfaceClass = self::INTERFACE_A_CLASS; + $loader->expects($this->never()) ->method('loadClassMetadata'); $cache->expects($this->never()) ->method('has'); - $cache->expects($this->once()) + $cache->expects($this->exactly(2)) ->method('read') - ->will($this->returnValue($metadata)); + ->withConsecutive( + array(self::PARENT_CLASS), + array(self::INTERFACE_A_CLASS) + ) + ->willReturnCallback(function ($name) use ($metadata, $parentClass, $interfaceClass) { + if ($parentClass == $name) { + return $metadata; + } + + return new ClassMetadata($interfaceClass); + }); $this->assertEquals($metadata, $factory->getMetadataFor(self::PARENT_CLASS)); } + + public function testMetadataCacheWithRuntimeConstraint() + { + $cache = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock(); + $factory = new LazyLoadingMetadataFactory(new TestLoader(), $cache); + + $cache + ->expects($this->any()) + ->method('write') + ->will($this->returnCallback(function ($metadata) { serialize($metadata); })) + ; + + $cache->expects($this->any()) + ->method('read') + ->will($this->returnValue(false)); + + $metadata = $factory->getMetadataFor(self::PARENT_CLASS); + $metadata->addConstraint(new Callback(function () {})); + + $metadata = $factory->getMetadataFor(self::CLASS_NAME); + } } class TestLoader implements LoaderInterface diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php index 09e6e449e0309..c131f28aea553 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php @@ -43,6 +43,6 @@ public function getFilesLoader(LoaderInterface $loader) public function getFileLoader() { - return $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface'); + return $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); } } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php index 647a568c2c3cc..c0a46cb0fdd04 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php @@ -20,12 +20,12 @@ public function testAllLoadersAreCalled() { $metadata = new ClassMetadata('\stdClass'); - $loader1 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface'); + $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader1->expects($this->once()) ->method('loadClassMetadata') ->with($this->equalTo($metadata)); - $loader2 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface'); + $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader2->expects($this->once()) ->method('loadClassMetadata') ->with($this->equalTo($metadata)); @@ -42,12 +42,12 @@ public function testReturnsTrueIfAnyLoaderReturnedTrue() { $metadata = new ClassMetadata('\stdClass'); - $loader1 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface'); + $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader1->expects($this->any()) ->method('loadClassMetadata') ->will($this->returnValue(true)); - $loader2 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface'); + $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader2->expects($this->any()) ->method('loadClassMetadata') ->will($this->returnValue(false)); @@ -64,12 +64,12 @@ public function testReturnsFalseIfNoLoaderReturnedTrue() { $metadata = new ClassMetadata('\stdClass'); - $loader1 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface'); + $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader1->expects($this->any()) ->method('loadClassMetadata') ->will($this->returnValue(false)); - $loader2 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface'); + $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader2->expects($this->any()) ->method('loadClassMetadata') ->will($this->returnValue(false)); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php index e6326b9a3154d..2053e24856889 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php @@ -19,6 +19,7 @@ use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\Regex; use Symfony\Component\Validator\Constraints\IsTrue; +use Symfony\Component\Validator\Constraints\Traverse; use Symfony\Component\Validator\Exception\MappingException; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader; @@ -57,6 +58,7 @@ public function testLoadClassMetadata() $expected->addConstraint(new Callback('validateMe')); $expected->addConstraint(new Callback('validateMeStatic')); $expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback'))); + $expected->addConstraint(new Traverse(false)); $expected->addPropertyConstraint('firstName', new NotNull()); $expected->addPropertyConstraint('firstName', new Range(array('min' => 3))); $expected->addPropertyConstraint('firstName', new Choice(array('A', 'B'))); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml b/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml index 689184ecf2d81..b1426cf4a90cd 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml @@ -31,6 +31,11 @@ callback + + + false + + diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php index 905cf00af4ffc..77a7cc6c2bdc6 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php @@ -603,8 +603,8 @@ public function testInitializeObjectsOnFirstValidation() $entity->initialized = false; // prepare initializers that set "initialized" to true - $initializer1 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface'); - $initializer2 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface'); + $initializer1 = $this->getMockBuilder('Symfony\\Component\\Validator\\ObjectInitializerInterface')->getMock(); + $initializer2 = $this->getMockBuilder('Symfony\\Component\\Validator\\ObjectInitializerInterface')->getMock(); $initializer1->expects($this->once()) ->method('initialize') diff --git a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php index cd77e948d4b1b..9e0afe06390be 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php @@ -42,7 +42,7 @@ public function testEmptyGroupsArrayDoesNotTriggerDeprecation() $childB->name = 'fake'; $entity->childA = array($childA); $entity->childB = array($childB); - $validatorContext = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface'); + $validatorContext = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock(); $validatorContext ->expects($this->once()) ->method('validate') @@ -76,7 +76,7 @@ public function testRelationBetweenChildAAndChildB() $entity->childA = array($childA); $entity->childB = array($childB); - $validatorContext = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface'); + $validatorContext = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock(); $validatorContext ->expects($this->once()) ->method('validate') diff --git a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php index fbc863157d9af..d41a791978bc4 100644 --- a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php +++ b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -34,7 +34,7 @@ protected function tearDown() public function testAddObjectInitializer() { $this->assertSame($this->builder, $this->builder->addObjectInitializer( - $this->getMock('Symfony\Component\Validator\ObjectInitializerInterface') + $this->getMockBuilder('Symfony\Component\Validator\ObjectInitializerInterface')->getMock() )); } @@ -86,21 +86,21 @@ public function testDisableAnnotationMapping() public function testSetMetadataCache() { $this->assertSame($this->builder, $this->builder->setMetadataCache( - $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface')) + $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock()) ); } public function testSetConstraintValidatorFactory() { $this->assertSame($this->builder, $this->builder->setConstraintValidatorFactory( - $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface')) + $this->getMockBuilder('Symfony\Component\Validator\ConstraintValidatorFactoryInterface')->getMock()) ); } public function testSetTranslator() { $this->assertSame($this->builder, $this->builder->setTranslator( - $this->getMock('Symfony\Component\Translation\TranslatorInterface')) + $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()) ); } diff --git a/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php b/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php index 7d7ebe73b0814..1cc96c834e6f6 100644 --- a/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php +++ b/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php @@ -29,7 +29,7 @@ interface ContextualValidatorInterface * * @param string $path The path to append * - * @return ContextualValidatorInterface This validator + * @return $this */ public function atPath($path); @@ -46,7 +46,7 @@ public function atPath($path); * validate. If none is given, * "Default" is assumed * - * @return ContextualValidatorInterface This validator + * @return $this */ public function validate($value, $constraints = null, $groups = null); @@ -59,7 +59,7 @@ public function validate($value, $constraints = null, $groups = null); * @param array|null $groups The validation groups to validate. If * none is given, "Default" is assumed * - * @return ContextualValidatorInterface This validator + * @return $this */ public function validateProperty($object, $propertyName, $groups = null); @@ -74,7 +74,7 @@ public function validateProperty($object, $propertyName, $groups = null); * @param array|null $groups The validation groups to validate. If * none is given, "Default" is assumed * - * @return ContextualValidatorInterface This validator + * @return $this */ public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null); diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index 941557e4f9d5a..6c987d7383998 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -720,9 +720,7 @@ private function validateGenericNode($value, $object, $cacheKey, MetadataInterfa // The $cascadedGroups property is set, if the "Default" group is // overridden by a group sequence // See validateClassNode() - $cascadedGroups = count($cascadedGroups) > 0 - ? $cascadedGroups - : $groups; + $cascadedGroups = null !== $cascadedGroups && count($cascadedGroups) > 0 ? $cascadedGroups : $groups; if (is_array($value)) { // Arrays are always traversed, independent of the specified diff --git a/src/Symfony/Component/Validator/ValidatorBuilderInterface.php b/src/Symfony/Component/Validator/ValidatorBuilderInterface.php index cd2f87575a690..e4bd1040133d5 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilderInterface.php +++ b/src/Symfony/Component/Validator/ValidatorBuilderInterface.php @@ -29,7 +29,7 @@ interface ValidatorBuilderInterface * * @param ObjectInitializerInterface $initializer The initializer * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function addObjectInitializer(ObjectInitializerInterface $initializer); @@ -38,7 +38,7 @@ public function addObjectInitializer(ObjectInitializerInterface $initializer); * * @param array $initializers The initializer * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function addObjectInitializers(array $initializers); @@ -47,7 +47,7 @@ public function addObjectInitializers(array $initializers); * * @param string $path The path to the mapping file * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function addXmlMapping($path); @@ -56,7 +56,7 @@ public function addXmlMapping($path); * * @param array $paths The paths to the mapping files * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function addXmlMappings(array $paths); @@ -65,7 +65,7 @@ public function addXmlMappings(array $paths); * * @param string $path The path to the mapping file * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function addYamlMapping($path); @@ -74,7 +74,7 @@ public function addYamlMapping($path); * * @param array $paths The paths to the mapping files * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function addYamlMappings(array $paths); @@ -83,7 +83,7 @@ public function addYamlMappings(array $paths); * * @param string $methodName The name of the method * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function addMethodMapping($methodName); @@ -92,7 +92,7 @@ public function addMethodMapping($methodName); * * @param array $methodNames The names of the methods * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function addMethodMappings(array $methodNames); @@ -101,14 +101,14 @@ public function addMethodMappings(array $methodNames); * * @param Reader $annotationReader The annotation reader to be used * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function enableAnnotationMapping(Reader $annotationReader = null); /** * Disables annotation based constraint mapping. * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function disableAnnotationMapping(); @@ -117,7 +117,7 @@ public function disableAnnotationMapping(); * * @param MetadataFactoryInterface $metadataFactory The metadata factory * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function setMetadataFactory(MetadataFactoryInterface $metadataFactory); @@ -126,7 +126,7 @@ public function setMetadataFactory(MetadataFactoryInterface $metadataFactory); * * @param CacheInterface $cache The cache instance * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function setMetadataCache(CacheInterface $cache); @@ -135,7 +135,7 @@ public function setMetadataCache(CacheInterface $cache); * * @param ConstraintValidatorFactoryInterface $validatorFactory The validator factory * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory); @@ -144,7 +144,7 @@ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterfac * * @param TranslatorInterface $translator The translator instance * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function setTranslator(TranslatorInterface $translator); @@ -157,7 +157,7 @@ public function setTranslator(TranslatorInterface $translator); * * @param string $translationDomain The translation domain of the violation messages * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function setTranslationDomain($translationDomain); diff --git a/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php b/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php index 60a654f793689..811b4842e888d 100644 --- a/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php +++ b/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php @@ -31,7 +31,7 @@ interface ConstraintViolationBuilderInterface * * @param string $path The property path * - * @return ConstraintViolationBuilderInterface This builder + * @return $this */ public function atPath($path); @@ -41,7 +41,7 @@ public function atPath($path); * @param string $key The name of the parameter * @param string $value The value to be inserted in the parameter's place * - * @return ConstraintViolationBuilderInterface This builder + * @return $this */ public function setParameter($key, $value); @@ -52,7 +52,7 @@ public function setParameter($key, $value); * the values to be inserted in their place as * values * - * @return ConstraintViolationBuilderInterface This builder + * @return $this */ public function setParameters(array $parameters); @@ -62,7 +62,7 @@ public function setParameters(array $parameters); * * @param string $translationDomain The translation domain * - * @return ConstraintViolationBuilderInterface This builder + * @return $this * * @see \Symfony\Component\Translation\TranslatorInterface */ @@ -73,7 +73,7 @@ public function setTranslationDomain($translationDomain); * * @param mixed $invalidValue The invalid value * - * @return ConstraintViolationBuilderInterface This builder + * @return $this */ public function setInvalidValue($invalidValue); @@ -83,7 +83,7 @@ public function setInvalidValue($invalidValue); * * @param int $number The number for determining the plural form * - * @return ConstraintViolationBuilderInterface This builder + * @return $this * * @see \Symfony\Component\Translation\TranslatorInterface::transChoice() */ @@ -94,7 +94,7 @@ public function setPlural($number); * * @param string|null $code The violation code * - * @return ConstraintViolationBuilderInterface This builder + * @return $this */ public function setCode($code); @@ -103,7 +103,7 @@ public function setCode($code); * * @param mixed $cause The cause of the violation * - * @return ConstraintViolationBuilderInterface This builder + * @return $this */ public function setCause($cause); diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index 3724b399279ab..104a6e230ba94 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -167,12 +167,12 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra foreach ($c->getParameters() as $v) { $k = '$'.$v->name; - if ($v->isPassedByReference()) { - $k = '&'.$k; - } if (method_exists($v, 'isVariadic') && $v->isVariadic()) { $k = '...'.$k; } + if ($v->isPassedByReference()) { + $k = '&'.$k; + } $a[$prefix.'parameters'][$k] = $v; } if (isset($a[$prefix.'parameters'])) { diff --git a/src/Symfony/Component/VarDumper/LICENSE b/src/Symfony/Component/VarDumper/LICENSE index 39fa189d2b5fc..207646a052dcd 100644 --- a/src/Symfony/Component/VarDumper/LICENSE +++ b/src/Symfony/Component/VarDumper/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/Component/Yaml/LICENSE b/src/Symfony/Component/Yaml/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Yaml/LICENSE +++ b/src/Symfony/Component/Yaml/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/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index de908c8a37f93..d4cc9752e42b6 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -452,7 +452,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false) $previousLineIndentation = $indent; - if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) { + if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) { $this->moveToPreviousLine(); break; } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index aa6bf874569d2..99ecaa8423496 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -189,6 +189,22 @@ public function getBlockChompingTests() ); $tests['Literal block chomping clip with multiple trailing newlines'] = array($expected, $yaml); + $yaml = <<<'EOF' +foo: +- bar: | + one + + two +EOF; + $expected = array( + 'foo' => array( + array( + 'bar' => "one\n\ntwo", + ), + ), + ); + $tests['Literal block chomping clip with embedded blank line inside unindented collection'] = array($expected, $yaml); + $yaml = <<<'EOF' foo: | one