From a0e305baa1609dc382476662588ba8e8e998213e Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Sat, 3 Dec 2016 10:46:32 +0100 Subject: [PATCH 001/106] Update PHP CS Fixer config file --- .php_cs => .php_cs.dist | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) rename .php_cs => .php_cs.dist (84%) diff --git a/.php_cs b/.php_cs.dist similarity index 84% rename from .php_cs rename to .php_cs.dist index 5a702adb3a838..baee1a5ec0d0f 100644 --- a/.php_cs +++ b/.php_cs.dist @@ -1,15 +1,14 @@ 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'), )) - ->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 From 8306530e6078132a661498e8ccf80813f782d857 Mon Sep 17 00:00:00 2001 From: Martynas Narbutas Date: Sat, 3 Dec 2016 11:01:12 +0100 Subject: [PATCH 002/106] [Security] AbstractVoter method supportsAttribute gives false positive if attribute is zero (0) --- .../Authorization/Voter/AbstractVoter.php | 2 +- .../Authorization/Voter/AbstractVoterTest.php | 71 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/AbstractVoter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/AbstractVoter.php index efa156228e227..3d8bbc2d3f987 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/AbstractVoter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/AbstractVoter.php @@ -26,7 +26,7 @@ abstract class AbstractVoter implements VoterInterface */ public function supportsAttribute($attribute) { - return in_array($attribute, $this->getSupportedAttributes()); + return in_array($attribute, $this->getSupportedAttributes(), true); } /** diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php index 2ab943bd8cbb0..c122587158a72 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php @@ -16,6 +16,9 @@ class AbstractVoterTest extends \PHPUnit_Framework_TestCase { + /** + * @var TokenInterface + */ protected $token; protected function setUp() @@ -23,6 +26,9 @@ protected function setUp() $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); } + /** + * @return array + */ public function getTests() { return array( @@ -53,6 +59,71 @@ public function testVote(array $attributes, $expectedVote, $object, $message) $this->assertEquals($expectedVote, $voter->vote($this->token, $object, $attributes), $message); } + + /** + * @return array + */ + public function getSupportsAttributeData() + { + return array( + 'positive_string_edit' => array( + 'expected' => true, + 'attribute' => 'EDIT', + 'message' => 'expected TRUE given as attribute EDIT is supported', + ), + 'positive_string_create' => array( + 'expected' => true, + 'attribute' => 'CREATE', + 'message' => 'expected TRUE as given attribute CREATE is supported', + ), + + 'negative_string_read' => array( + 'expected' => false, + 'attribute' => 'READ', + 'message' => 'expected FALSE as given attribute READ is not supported', + ), + 'negative_string_random' => array( + 'expected' => false, + 'attribute' => 'random', + 'message' => 'expected FALSE as given attribute "random" is not supported', + ), + 'negative_string_0' => array( + 'expected' => false, + 'attribute' => '0', + 'message' => 'expected FALSE as given attribute "0" is not supported', + ), + // this set of data gives false positive if in_array is not used with strict flag set to 'true' + 'negative_int_0' => array( + 'expected' => false, + 'attribute' => 0, + 'message' => 'expected FALSE as given attribute 0 is not string', + ), + 'negative_int_1' => array( + 'expected' => false, + 'attribute' => 1, + 'message' => 'expected FALSE as given attribute 1 is not string', + ), + 'negative_int_7' => array( + 'expected' => false, + 'attribute' => 7, + 'message' => 'expected FALSE as attribute 7 is not string', + ), + ); + } + + /** + * @dataProvider getSupportsAttributeData + * + * @param bool $expected + * @param string $attribute + * @param string $message + */ + public function testSupportsAttribute($expected, $attribute, $message) + { + $voter = new AbstractVoterTest_Voter(); + + $this->assertEquals($expected, $voter->supportsAttribute($attribute), $message); + } } class AbstractVoterTest_Voter extends AbstractVoter From 94253e8a23ec6d312ea72a38e438e8e4dba0fe53 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 10 Dec 2016 19:17:41 +0100 Subject: [PATCH 003/106] Only count on arrays or countables to avoid warnings in PHP 7.2 --- src/Symfony/Component/Form/Form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index d7109bd3ac3eb..54b9b39ebd02c 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -748,7 +748,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)); } From 9cd884312fdfc976f93761c0e7cdfdd31064c752 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 13 Dec 2016 11:53:02 +0100 Subject: [PATCH 004/106] updated CHANGELOG for 2.7.22 --- CHANGELOG-2.7.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CHANGELOG-2.7.md b/CHANGELOG-2.7.md index fd12d3a03612e..ff7d6301ddcc4 100644 --- a/CHANGELOG-2.7.md +++ b/CHANGELOG-2.7.md @@ -7,6 +7,34 @@ in 2.7 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/v2.7.0...v2.7.1 +* 2.7.22 (2016-12-13) + + * bug #20714 [FrameworkBundle] Fix unresolved parameters from default configs in debug:config (chalasr) + * bug #20442 [FrameworkBundle] Bundle commands are not available via find() (julienfalque) + * bug #20840 [WebProfilerBundle] add dependency on Twig (xabbuh) + * bug #20828 [Validator] Fix init of YamlFileLoader::$classes for empty files (nicolas-grekas) + * bug #20539 Cast result to int before adding to it (alcaeus) + * bug #20831 [Twig] Fix deprecations with Twig 1.29 (nicolas-grekas) + * bug #20767 [Cache] Fix dumping SplDoublyLinkedList iter mode (nicolas-grekas) + * bug #20736 [Console] fixed PHP7 Errors when not using Dispatcher (keradus) + * bug #20755 [HttpKernel] Regression test for missing controller arguments (iltar) + * bug #20418 [Form][DX] FileType "multiple" fixes (yceruto) + * bug #19902 [DependencyInjection] PhpDumper.php: hasReference() shouldn't search references in lazy service. (antanas-arvasevicius) + * bug #20704 [Console] Fix wrong handling of multiline arg/opt descriptions (ogizanagi) + * bug #20712 [TwigBundle] Fix twig loader registered twice (ogizanagi) + * bug #20671 [Config] ConfigCache::isFresh() should return false when unserialize() fails (nicolas-grekas) + * bug #20676 [ClassLoader] Use only forward slashes in generated class map (nicolas-grekas) + * bug #20664 [Validator] ensure the proper context for nested validations (xabbuh) + * bug #20661 bug #20653 [WebProfilerBundle] Profiler includes ghost panels (jzawadzki) + * bug #20374 [FrameworkBundle] Improve performance of ControllerNameParser (enumag) + * bug #20474 [Routing] Fail properly when a route parameter name cannot be used as a PCRE subpattern name (fancyweb) + * bug #20566 [DI] Initialize properties before method calls (ro0NL) + * bug #20609 [DI] Fixed custom services definition BC break introduced in ec7e70fb… (kiler129) + * bug #20598 [DI] Aliases should preserve the aliased invalid behavior (nicolas-grekas) + * bug #20602 [HttpKernel] Revert BC breaking change of Request::isMethodSafe() (nicolas-grekas) + * bug #20499 [Doctrine][Form] support large integers (xabbuh) + * bug #20576 [Process] Do feat test before enabling TTY mode (nicolas-grekas) + * 2.7.21 (2016-11-21) * bug #20543 [DI] Fix error when trying to resolve a DefinitionDecorator (nicolas-grekas) From c5ab208642843fd6d3b43d4efad9478ebcbd69bc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 13 Dec 2016 11:53:11 +0100 Subject: [PATCH 005/106] update CONTRIBUTORS for 2.7.22 --- CONTRIBUTORS.md | 58 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 20 deletions(-) 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) From bdb6bf985f0766216ff2ab9597ad55f22811876a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 13 Dec 2016 11:53:27 +0100 Subject: [PATCH 006/106] updated VERSION for 2.7.22 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 4ed457d9931a1..8569c48863ef2 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.22-DEV'; + const VERSION = '2.7.22'; const VERSION_ID = 20722; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; const RELEASE_VERSION = 22; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From f22a50562930922d1dcf89ddfcd866a3f73f2306 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 13 Dec 2016 13:12:22 +0100 Subject: [PATCH 007/106] bumped Symfony version to 2.7.23 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 8569c48863ef2..81f7b2a6140ae 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.22'; - const VERSION_ID = 20722; + const VERSION = '2.7.23-DEV'; + const VERSION_ID = 20723; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; - const RELEASE_VERSION = 22; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 23; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 42fbabd470db3152f2ba5907ce1a0497221b7f34 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 13 Dec 2016 13:16:09 +0100 Subject: [PATCH 008/106] updated CHANGELOG for 2.8.15 --- CHANGELOG-2.8.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CHANGELOG-2.8.md b/CHANGELOG-2.8.md index e5ad3abf25202..9fd4cd6412cf3 100644 --- a/CHANGELOG-2.8.md +++ b/CHANGELOG-2.8.md @@ -7,6 +7,35 @@ in 2.8 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/v2.8.0...v2.8.1 +* 2.8.15 (2016-12-13) + + * bug #20714 [FrameworkBundle] Fix unresolved parameters from default configs in debug:config (chalasr) + * bug #20442 [FrameworkBundle] Bundle commands are not available via find() (julienfalque) + * bug #20840 [WebProfilerBundle] add dependency on Twig (xabbuh) + * bug #20828 [Validator] Fix init of YamlFileLoader::$classes for empty files (nicolas-grekas) + * bug #20539 Cast result to int before adding to it (alcaeus) + * bug #20831 [Twig] Fix deprecations with Twig 1.29 (nicolas-grekas) + * bug #20767 [Cache] Fix dumping SplDoublyLinkedList iter mode (nicolas-grekas) + * bug #20736 [Console] fixed PHP7 Errors when not using Dispatcher (keradus) + * bug #20755 [HttpKernel] Regression test for missing controller arguments (iltar) + * bug #20418 [Form][DX] FileType "multiple" fixes (yceruto) + * bug #19902 [DependencyInjection] PhpDumper.php: hasReference() shouldn't search references in lazy service. (antanas-arvasevicius) + * bug #20704 [Console] Fix wrong handling of multiline arg/opt descriptions (ogizanagi) + * bug #20712 [TwigBundle] Fix twig loader registered twice (ogizanagi) + * bug #20716 [WebProfilerBundle] Fix dump block is unfairly restrained (ogizanagi) + * bug #20671 [Config] ConfigCache::isFresh() should return false when unserialize() fails (nicolas-grekas) + * bug #20676 [ClassLoader] Use only forward slashes in generated class map (nicolas-grekas) + * bug #20664 [Validator] ensure the proper context for nested validations (xabbuh) + * bug #20661 bug #20653 [WebProfilerBundle] Profiler includes ghost panels (jzawadzki) + * bug #20374 [FrameworkBundle] Improve performance of ControllerNameParser (enumag) + * bug #20474 [Routing] Fail properly when a route parameter name cannot be used as a PCRE subpattern name (fancyweb) + * bug #20566 [DI] Initialize properties before method calls (ro0NL) + * bug #20609 [DI] Fixed custom services definition BC break introduced in ec7e70fb… (kiler129) + * bug #20598 [DI] Aliases should preserve the aliased invalid behavior (nicolas-grekas) + * bug #20602 [HttpKernel] Revert BC breaking change of Request::isMethodSafe() (nicolas-grekas) + * bug #20499 [Doctrine][Form] support large integers (xabbuh) + * bug #20576 [Process] Do feat test before enabling TTY mode (nicolas-grekas) + * 2.8.14 (2016-11-21) * bug #20543 [DI] Fix error when trying to resolve a DefinitionDecorator (nicolas-grekas) From 5b5311c13092ffc428345c31e944b5a1ba56447a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 13 Dec 2016 13:16:15 +0100 Subject: [PATCH 009/106] updated VERSION for 2.8.15 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 408ff9d874913..9e0fcf10b8fb9 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.15-DEV'; + const VERSION = '2.8.15'; const VERSION_ID = 20815; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 15; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From a163a1655489da9584f2da6508c632bdf8a87ebd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 13 Dec 2016 13:44:14 +0100 Subject: [PATCH 010/106] bumped Symfony version to 2.8.16 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 9e0fcf10b8fb9..d028126e1e852 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.15'; - const VERSION_ID = 20815; + const VERSION = '2.8.16-DEV'; + const VERSION_ID = 20816; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 15; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 16; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 8bf83cc0b0ba0900cce1c74564733cd26632ca37 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 13 Dec 2016 14:18:12 +0100 Subject: [PATCH 011/106] bumped Symfony version to 3.1.9 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index a06d4815d44ed..96bcda7212a90 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '3.1.8'; - const VERSION_ID = 30108; + const VERSION = '3.1.9-DEV'; + const VERSION_ID = 30109; const MAJOR_VERSION = 3; const MINOR_VERSION = 1; - const RELEASE_VERSION = 8; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 9; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2017'; const END_OF_LIFE = '07/2017'; From d8c18cc3cdd4d7a62869f66243f760f96f616a52 Mon Sep 17 00:00:00 2001 From: Maxime STEINHAUSSER Date: Wed, 7 Dec 2016 12:55:24 +0100 Subject: [PATCH 012/106] [Console] Review Application docblocks --- src/Symfony/Component/Console/Application.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index b11268ade33bf..a9400127e6da4 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -102,8 +102,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) { @@ -387,7 +385,7 @@ public function add(Command $command) * * @return Command A Command object * - * @throws \InvalidArgumentException When command name given does not exist + * @throws \InvalidArgumentException When given command name does not exist */ public function get($name) { @@ -831,8 +829,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) { From 3247308c5003541eaa6528112853163009cd8378 Mon Sep 17 00:00:00 2001 From: Andy Raines Date: Fri, 9 Dec 2016 12:15:36 +0000 Subject: [PATCH 013/106] [Console] fixed BC issue with static closures --- .../Component/Console/Command/Command.php | 10 +++++++- .../Console/Tests/Command/CommandTest.php | 23 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index aadc60cdffec3..bbac86a5a293e 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -283,7 +283,15 @@ public function setCode($code) if (PHP_VERSION_ID >= 50400 && $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); + } } } diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index ff0c8d4791f57..4378847369a75 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -335,6 +335,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(); From 5e899cd2a78d19b759a01e4974182a51f5fbc0ba Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Tue, 13 Dec 2016 18:58:15 +0000 Subject: [PATCH 014/106] [HttpFoundation] Fix cookie to string conversion for raw cookies --- src/Symfony/Component/HttpFoundation/Cookie.php | 12 ++++++------ .../Component/HttpFoundation/Tests/CookieTest.php | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Cookie.php b/src/Symfony/Component/HttpFoundation/Cookie.php index 67e20dd5019fb..6513421dc3332 100644 --- a/src/Symfony/Component/HttpFoundation/Cookie.php +++ b/src/Symfony/Component/HttpFoundation/Cookie.php @@ -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) { $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/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index 9134c1570c262..bcc0e014f3e2e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -154,10 +154,12 @@ public function testToString() 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); } } From b587a7294f7049ed0d77875c46ba87ece0368a06 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Fri, 27 Mar 2015 23:19:17 +0800 Subject: [PATCH 015/106] [config] Fix issue when key removed and left value only When a key attribute is mapped and the key is removed from the value array, if only 'value' element is left in the array, it should replace its wrapper array. Assume the original value array is as follows (key attribute is 'id'). ```php array( 'things' => array( array('id' => 'option1', 'value' => 'value1'), array('id' => 'option2', 'value' => 'value2') ) ) ``` After normalized, the above shall be converted to the following array. ```php array( 'things' => array( 'option1' => 'value1', 'option2' => 'value2' ) ) ``` It's also possible to mix 'value-only' and 'none-value-only' elements in the array: ```php array( 'things' => array( array('id' => 'option1', 'value' => 'value1'), array('id' => 'option2', 'value' => 'value2', 'foo' => 'foo2') ) ) ``` The above shall be converted to the following array. ```php array( 'things' => array( 'option1' => 'value1', 'option2' => array('value' => 'value2','foo' => 'foo2') ) ) ``` The 'value' element can also be array: ```php array( 'things' => array( array( 'id' => 'option1', 'value' => array('foo'=>'foo1', 'bar' => 'bar1') ) ) ) ``` The above shall be converted to the following array. ```php array( 'things' => array( 'option1' => array('foo' => 'foo1', 'bar' => 'bar1') ) ) ``` When using VariableNode for value element, it's also possible to mix different types of value elements: ```php array( 'things' => array( array('id' => 'option1', 'value' => array('foo'=>'foo1', 'bar' => 'bar1')), array('id' => 'option2', 'value' => 'value2') ) ) ``` The above shall be converted to the following array. ```php array( 'things' => array( 'option1' => array('foo'=>'foo1', 'bar' => 'bar1'), 'option2' => 'value2' ) ) ``` | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15270 | License | MIT | Doc PR | n/a --- .../Config/Definition/PrototypedArrayNode.php | 74 +++++++- .../Definition/PrototypedArrayNodeTest.php | 161 ++++++++++++++++++ 2 files changed, 227 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index ae1a76663a411..5c0fc1c6031c7 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/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', + ), + ), + ); + } } From 92423e77ac35eb9a2af1e3a3c44bca7531cba3cf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 14 Dec 2016 09:03:29 +0100 Subject: [PATCH 016/106] fixed CS --- src/Symfony/Component/Config/Definition/PrototypedArrayNode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index 5c0fc1c6031c7..1c3c2188326be 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -257,7 +257,7 @@ protected function normalizeValue($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 = current($this->valuePrototypes) ?: clone $children['value']; $valuePrototype->parent = $this; $originalClosures = $this->prototype->normalizationClosures; if (is_array($originalClosures)) { From ca4c35164fad0ae6977250adf575f494a85cf249 Mon Sep 17 00:00:00 2001 From: Indra Gunawan Date: Wed, 14 Dec 2016 14:53:51 +0700 Subject: [PATCH 017/106] [Validator] add Indonesian translation --- .../Validator/Resources/translations/validators.id.xlf | 4 ++++ 1 file changed, 4 insertions(+) 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. + From 2c9dc66665b9968952d428a9a128264461f15e2d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 16 Oct 2016 10:57:31 +0200 Subject: [PATCH 018/106] do not try to register incomplete definitions --- .../Compiler/ExceptionListenerPass.php | 10 +++++-- .../Compiler/ExtensionPass.php | 19 +++++++++++++ .../DependencyInjection/TwigExtension.php | 12 +++++++++ .../TwigBundle/Resources/config/form.xml | 20 ++++++++++++++ .../Resources/config/templating.xml | 21 +++++++++++++++ .../TwigBundle/Resources/config/twig.xml | 27 ------------------- 6 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 src/Symfony/Bundle/TwigBundle/Resources/config/form.xml create mode 100644 src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php index 9fbfd65950a53..711743a5af634 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php @@ -27,8 +27,14 @@ public function process(ContainerBuilder $container) return; } - // register the exception controller only if Twig is enabled - if ($container->hasParameter('templating.engines')) { + if (!interface_exists('Symfony\Component\Templating\TemplateReferenceInterface')) { + $container->removeDefinition('twig.controller.exception'); + } + + // 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 d09de2d615c0a..d619de0d81cec 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -23,6 +23,25 @@ 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'); diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index 7b97e120baa4b..5eb163c8869bb 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -36,6 +36,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) { 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..0703f0f57774a --- /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..5a39c95018c0b --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index f2c2a4cee007c..c08be1f0399ed 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -55,22 +55,8 @@ - - - - - - - - - - - - - - @@ -130,21 +116,8 @@ - - - - - - %twig.form.resources% - - - - - - - From 28ec36140d4cd30a3d7e1991e490d4d0b0aecfba Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 15 Dec 2016 08:56:57 +0100 Subject: [PATCH 019/106] [VarDumper] Fix dumping by-ref variadics --- src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index dd07c08a470ba..e4a7f4e148aa9 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -125,12 +125,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; } From 10806e056ee19bf80acdf7b4c196d5650608b148 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Thu, 15 Dec 2016 14:58:23 +0100 Subject: [PATCH 020/106] [FrameworkBundle] Fix PHP form templates on translatable attributes --- .../Resources/views/Form/button_attributes.html.php | 2 +- .../Resources/views/Form/widget_container_attributes.html.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 ac1077a205ae3..4ffa2e84ff24c 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($view['translator']->trans($v, array(), $translation_domain))) ?> 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 327925a537196..7aa9e9d406d02 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($view['translator']->trans($v, array(), $translation_domain))) ?> escape($k), $view->escape($k)) ?> From e66d3da91ac2890927f0aaa8bfbedfc9985599f0 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Thu, 15 Dec 2016 15:48:03 +0100 Subject: [PATCH 021/106] [DependencyInjection] Fix on-invalid attribute type in xsd --- .../Loader/schema/dic/services/services-1.0.xsd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 a7a534c9f1b64..7c28fd8de3b32 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 @@ - + From 999f769ba545e3eb9fb91df5e2fce7320834b9b2 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Thu, 15 Dec 2016 20:58:01 +0100 Subject: [PATCH 022/106] [Serializer] Fix MaxDepth annotation exceptions --- .../Serializer/Annotation/MaxDepth.php | 4 ++-- .../Tests/Annotation/MaxDepthTest.php | 20 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) 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/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() From fb9b08396b6e3e2c107556e0b3949776f5cbd8f6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 16 Dec 2016 13:58:05 +0100 Subject: [PATCH 023/106] test for the Validator component to be present --- .../DependencyInjection/FrameworkExtension.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 278b8b9b7d672..13966eb99dbd4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -751,6 +751,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'); From d65679b3021dbbc8bc5f0cab071a07147e133a55 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 16 Dec 2016 16:35:20 +0100 Subject: [PATCH 024/106] =?UTF-8?q?[Validator]=C2=A0phpize=20default=20opt?= =?UTF-8?q?ion=20values?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the behavior for default constraints inline with the behavior when the option is given explicitly. --- .../Component/Validator/Mapping/Loader/XmlFileLoader.php | 2 +- .../Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php | 2 ++ .../Validator/Tests/Mapping/Loader/constraint-mapping.xml | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) 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/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 + + From 8aeed8817983d9b73bb69f122081ce0fd29ed23f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 17 Dec 2016 11:40:05 +0100 Subject: [PATCH 025/106] [Security] Fix test --- .../Core/Tests/Authorization/Voter/AbstractVoterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php index 7c60007d98ee1..69cfba34bbb05 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php @@ -122,7 +122,7 @@ public function getSupportsAttributeData() */ public function testSupportsAttribute($expected, $attribute, $message) { - $voter = new AbstractVoterTest_Voter(); + $voter = new Fixtures\MyVoter(); $this->assertEquals($expected, $voter->supportsAttribute($attribute), $message); } From 9d467121033d4ec9fdded9b355ced5d8c229e297 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sat, 17 Dec 2016 12:19:40 +0100 Subject: [PATCH 026/106] [Console] Fix question formatting using SymfonyStyle::ask() --- .../Console/Helper/SymfonyQuestionHelper.php | 2 +- .../Tests/Helper/SymfonyQuestionHelperTest.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php b/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php index 7e4369b259899..ea994fcec70e0 100644 --- a/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php @@ -53,7 +53,7 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu */ protected function writePrompt(OutputInterface $output, Question $question) { - $text = OutputFormatter::escape($question->getQuestion()); + $text = $question->getQuestion(); $default = $question->getDefault(); switch (true) { diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index f57d65070e076..e26a254baa899 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -79,7 +79,9 @@ public function testAskReturnsNullIfValidatorAllowsIt() $questionHelper = new SymfonyQuestionHelper(); $questionHelper->setInputStream($this->getInputStream("\n")); $question = new Question('What is your favorite superhero?'); - $question->setValidator(function ($value) { return $value; }); + $question->setValidator(function ($value) { + return $value; + }); $this->assertNull($questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question)); } @@ -92,13 +94,13 @@ public function testAskEscapeDefaultValue() $this->assertOutputContains('Can I have a backslash? [\]', $output); } - public function testAskEscapeLabel() + public function testAskEscapeAndFormatLabel() { $helper = new SymfonyQuestionHelper(); - $helper->setInputStream($this->getInputStream('sure')); - $helper->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), new Question('Do you want a \?')); + $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 a \?', $output); + $this->assertOutputContains('Do you want to use Foo\\Bar or Foo\\Baz\\? [Foo\\Baz]:', $output); } /** From faf2370a3d85a25225ee60b07b5fa4b428a90942 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 17 Dec 2016 19:04:40 +0100 Subject: [PATCH 027/106] removed obsolete condition --- .../DependencyInjection/Compiler/ExceptionListenerPass.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php index 711743a5af634..be447ab33c75d 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php @@ -27,9 +27,7 @@ public function process(ContainerBuilder $container) return; } - if (!interface_exists('Symfony\Component\Templating\TemplateReferenceInterface')) { - $container->removeDefinition('twig.controller.exception'); - } + $container->removeDefinition('twig.controller.exception'); // 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')) { From c9e560f1b76603d5a72f3652d8aa6f92e4d24535 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 17 Dec 2016 22:15:07 +0100 Subject: [PATCH 028/106] do not remove the Twig ExceptionController service --- .../DependencyInjection/Compiler/ExceptionListenerPass.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php index be447ab33c75d..b7ebb2a406512 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php @@ -27,8 +27,6 @@ public function process(ContainerBuilder $container) return; } - $container->removeDefinition('twig.controller.exception'); - // 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'); From fb91f74b34f2ea8064ad790677c4cb8207848ef0 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 17 Dec 2016 23:43:59 +0100 Subject: [PATCH 029/106] [Form] fix group sequence based validation --- .../Validator/Constraints/FormValidator.php | 15 ++++-- .../Validator/Type/BaseValidatorExtension.php | 5 ++ .../Constraints/FormValidatorTest.php | 50 +++++++++++-------- .../Type/BaseValidatorExtensionTest.php | 10 ++++ 4 files changed, 56 insertions(+), 24 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index 8333e7c2166be..5b989f1a60ca8 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\ConstraintValidator; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Exception\UnexpectedTypeException; @@ -49,10 +50,12 @@ public function validate($form, Constraint $constraint) // Validate the data against its own constraints if (self::allowDataWalking($form)) { - foreach ($groups as $group) { - if ($validator) { - $validator->atPath('data')->validate($form->getData(), null, $group); - } else { + if ($validator) { + if (is_array($groups) && count($groups) > 0 || $groups instanceof GroupSequence && count($groups->groups) > 0) { + $validator->atPath('data')->validate($form->getData(), null, $groups); + } + } else { + foreach ($groups as $group) { // 2.4 API $this->context->validate($form->getData(), 'data', $group, true); } @@ -218,6 +221,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/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index 9e7bdee25ee4b..5047ecabd52e3 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\Tests\Constraints\AbstractConstraintValidatorTest; @@ -73,8 +74,7 @@ public function testValidate() ->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()); @@ -96,12 +96,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()); @@ -135,7 +134,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()); @@ -347,6 +346,21 @@ function () { throw new TransformationFailedException(); } } public function testHandleCallbackValidationGroups() + { + $object = $this->getMock('\stdClass'); + $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 testHandleGroupSequenceValidationGroups() { $object = $this->getMock('\stdClass'); $options = array('validation_groups' => array($this, 'getValidationGroups')); @@ -354,8 +368,7 @@ public function testHandleCallbackValidationGroups() ->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()); @@ -370,7 +383,7 @@ public function testDontExecuteFunctionNames() ->setData($object) ->getForm(); - $this->expectValidateAt(0, 'data', $object, 'header'); + $this->expectValidateAt(0, 'data', $object, array('header')); $this->validator->validate($form, new Form()); @@ -387,8 +400,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()); @@ -414,7 +426,7 @@ public function testUseValidationGroupOfClickedButton() $parent->submit(array('name' => $object, 'submit' => '')); - $this->expectValidateAt(0, 'data', $object, 'button_group'); + $this->expectValidateAt(0, 'data', $object, array('button_group')); $this->validator->validate($form, new Form()); @@ -440,7 +452,7 @@ public function testDontUseValidationGroupOfUnclickedButton() $form->setData($object); - $this->expectValidateAt(0, 'data', $object, 'form_group'); + $this->expectValidateAt(0, 'data', $object, array('form_group')); $this->validator->validate($form, new Form()); @@ -464,7 +476,7 @@ public function testUseInheritedValidationGroup() $form->setData($object); - $this->expectValidateAt(0, 'data', $object, 'group'); + $this->expectValidateAt(0, 'data', $object, array('group')); $this->validator->validate($form, new Form()); @@ -488,8 +500,7 @@ public function testUseInheritedCallbackValidationGroup() $form->setData($object); - $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()); @@ -515,8 +526,7 @@ public function testUseInheritedClosureValidationGroup() $form->setData($object); - $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()); @@ -530,7 +540,7 @@ public function testAppendPropertyPath() ->setData($object) ->getForm(); - $this->expectValidateAt(0, 'data', $object, 'Default'); + $this->expectValidateAt(0, 'data', $object, array('Default')); $this->validator->validate($form, new Form()); 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()); } From 257a856f9f987e88c03803c37a13ddc93f270119 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Tue, 22 Nov 2016 18:33:09 +0000 Subject: [PATCH 030/106] [WebProfilerBundle] Display multiple HTTP headers in WDT --- .../DataCollector/RequestDataCollector.php | 61 +++++-------------- .../RequestDataCollectorTest.php | 4 +- 2 files changed, 17 insertions(+), 48 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 9a499a737ad02..7929cfc614284 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\KernelEvents; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -40,12 +38,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. @@ -121,6 +115,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])) { $controller = $this->controllers[$request]; if (is_array($controller)) { @@ -183,7 +189,7 @@ public function getRequestQuery() public function getRequestHeaders() { - return new HeaderBag($this->data['request_headers']); + return new ParameterBag($this->data['request_headers']); } public function getRequestServer() @@ -203,7 +209,7 @@ public function getRequestAttributes() public function getResponseHeaders() { - return new ResponseHeaderBag($this->data['response_headers']); + return new ParameterBag($this->data['response_headers']); } public function getSessionMetadata() @@ -302,41 +308,4 @@ public function getName() { return 'request'; } - - 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/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index 2eb1c41e8dda8..3a0ab50321af9 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -31,7 +31,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); @@ -45,7 +45,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()); From 20190c3861f9c1d6aed17391b35d4e5391d2bb13 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 18 Dec 2016 21:52:30 +0100 Subject: [PATCH 031/106] [HttpKernel] Fix ClientTest cookie format assertions --- .../Component/HttpKernel/Tests/ClientTest.php | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) 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() From 313defaadf976ed2befe20d98b5a338a5cb1fc69 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Sun, 18 Dec 2016 19:50:35 +0100 Subject: [PATCH 032/106] Mention the community review guide --- CONTRIBUTING.md | 2 ++ README.md | 9 +++++++++ 2 files changed, 11 insertions(+) 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/README.md b/README.md index e1c2e3a7e666a..585350ef44a93 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,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 ---------------------- @@ -54,3 +62,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 From e18918368948492d8fc7c810f9eba064bce393c3 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Sat, 17 Dec 2016 19:49:57 +0100 Subject: [PATCH 033/106] [Console] SymfonyStyle: Escape trailing backslashes in user texts --- .../Console/Formatter/OutputFormatter.php | 14 ++++++++++++++ .../Console/Helper/SymfonyQuestionHelper.php | 2 +- .../Component/Console/Style/SymfonyStyle.php | 4 ++-- .../Style/SymfonyStyle/command/command_12.php | 13 +++++++++++++ .../Style/SymfonyStyle/output/output_12.txt | 7 +++++++ .../Tests/Helper/SymfonyQuestionHelperTest.php | 13 ++++++++++--- 6 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_12.txt diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 154a041dae013..e0bbd0670554c 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -33,6 +33,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/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index e9932d1f8797d..a1a0fb8c2ee4a 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -121,7 +121,7 @@ public function title($message) { $this->autoPrependBlock(); $this->writeln(array( - sprintf('%s', $message), + sprintf('%s', OutputFormatter::escapeTrailingBackslash($message)), sprintf('%s', str_repeat('=', strlen($message))), )); $this->newLine(); @@ -134,7 +134,7 @@ public function section($message) { $this->autoPrependBlock(); $this->writeln(array( - sprintf('%s', $message), + sprintf('%s', OutputFormatter::escapeTrailingBackslash($message)), sprintf('%s', str_repeat('-', strlen($message))), )); $this->newLine(); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php new file mode 100644 index 0000000000000..e6a13558d046c --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.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_12.txt b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_12.txt new file mode 100644 index 0000000000000..59d00e04a248d --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_12.txt @@ -0,0 +1,7 @@ + +Title ending with \ +=================== + +Section ending with \ +--------------------- + diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index e26a254baa899..ed4adef52eb16 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -79,9 +79,7 @@ public function testAskReturnsNullIfValidatorAllowsIt() $questionHelper = new SymfonyQuestionHelper(); $questionHelper->setInputStream($this->getInputStream("\n")); $question = new Question('What is your favorite superhero?'); - $question->setValidator(function ($value) { - return $value; - }); + $question->setValidator(function ($value) { return $value; }); $this->assertNull($questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question)); } @@ -103,6 +101,15 @@ public function testAskEscapeAndFormatLabel() $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('Question with a trailing \\')); + + $this->assertOutputContains('Question with a trailing \\', $output); + } + /** * @expectedException \Symfony\Component\Console\Exception\RuntimeException * @expectedExceptionMessage Aborted From 71d059cad115e4adb8e56ebad8c19f9ca0670c2f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 19 Dec 2016 10:02:29 +0100 Subject: [PATCH 034/106] fixed obsolete getMock() usage --- .../DoctrineDataCollectorTest.php | 4 +- .../DataFixtures/ContainerAwareLoaderTest.php | 2 +- .../DoctrineParserCacheTest.php | 6 +- .../ChoiceList/DoctrineChoiceLoaderTest.php | 8 +-- .../Tests/Form/DoctrineOrmTypeGuesserTest.php | 4 +- .../Form/Type/EntityTypePerformanceTest.php | 2 +- .../Tests/Form/Type/EntityTypeTest.php | 2 +- .../Doctrine/Tests/Logger/DbalLoggerTest.php | 10 +-- .../Security/User/EntityUserProviderTest.php | 2 +- .../Constraints/UniqueEntityValidatorTest.php | 4 +- .../Tests/Handler/ConsoleHandlerTest.php | 10 +-- .../Instantiator/RuntimeInstantiatorTest.php | 2 +- .../Bridge/Twig/Tests/AppVariableTest.php | 12 ++-- .../Tests/Extension/DumpExtensionTest.php | 2 +- ...xtensionBootstrap3HorizontalLayoutTest.php | 2 +- .../FormExtensionBootstrap3LayoutTest.php | 2 +- .../Extension/FormExtensionDivLayoutTest.php | 2 +- .../FormExtensionTableLayoutTest.php | 2 +- .../Extension/HttpKernelExtensionTest.php | 2 +- .../Tests/Extension/RoutingExtensionTest.php | 4 +- .../Extension/StopwatchExtensionTest.php | 2 +- .../Bridge/Twig/Tests/Node/DumpNodeTest.php | 8 +-- .../Bridge/Twig/Tests/Node/FormThemeTest.php | 2 +- .../Node/SearchAndRenderBlockNodeTest.php | 20 +++--- .../Bridge/Twig/Tests/Node/TransNodeTest.php | 2 +- ...ranslationDefaultDomainNodeVisitorTest.php | 4 +- .../TranslationNodeVisitorTest.php | 2 +- .../TokenParser/FormThemeTokenParserTest.php | 2 +- .../Tests/Translation/TwigExtractorTest.php | 10 +-- .../Bridge/Twig/Tests/TwigEngineTest.php | 2 +- .../Tests/Command/RouterDebugCommandTest.php | 4 +- .../Tests/Command/RouterMatchCommandTest.php | 4 +- .../Command/TranslationDebugCommandTest.php | 14 ++--- .../Command/TranslationUpdateCommandTest.php | 12 ++-- .../Tests/Console/ApplicationTest.php | 10 +-- .../Controller/ControllerNameParserTest.php | 4 +- .../Controller/ControllerResolverTest.php | 4 +- .../Tests/Controller/ControllerTest.php | 54 ++++++++-------- .../Controller/RedirectControllerTest.php | 8 +-- .../Compiler/AddCacheWarmerPassTest.php | 21 ++----- .../AddConstraintValidatorsPassTest.php | 18 ++---- .../LegacyFragmentRendererPassTest.php | 16 ++--- .../Compiler/LoggingTranslatorPassTest.php | 10 +-- .../Compiler/ProfilerPassTest.php | 5 +- .../Compiler/SerializerPassTest.php | 11 ++-- .../Compiler/TranslatorPassTest.php | 9 +-- ...ainerAwareHIncludeFragmentRendererTest.php | 2 +- .../Tests/Routing/RouterTest.php | 4 +- .../Tests/Templating/DelegatingEngineTest.php | 6 +- .../Tests/Templating/GlobalVariablesTest.php | 12 ++-- .../Templating/Helper/StopwatchHelperTest.php | 2 +- .../Templating/TemplateNameParserTest.php | 2 +- .../Tests/Templating/TimedPhpEngineTest.php | 8 +-- .../Tests/Translation/TranslatorTest.php | 12 ++-- .../ConstraintValidatorFactoryTest.php | 8 +-- .../SecurityDataCollectorTest.php | 2 +- .../Controller/PreviewErrorControllerTest.php | 2 +- .../Compiler/TwigLoaderPassTest.php | 5 +- .../Extension/LegacyAssetsExtensionTest.php | 2 +- .../Tests/Loader/FilesystemLoaderTest.php | 24 +++---- .../LegacyRenderTokenParserTest.php | 2 +- .../Controller/ProfilerControllerTest.php | 6 +- .../WebProfilerExtensionTest.php | 2 +- .../WebDebugToolbarListenerTest.php | 14 ++--- .../Tests/Profiler/TemplateManagerTest.php | 4 +- .../Tests/Context/RequestStackContextTest.php | 12 ++-- .../Component/Asset/Tests/PackagesTest.php | 4 +- .../Component/Asset/Tests/PathPackageTest.php | 2 +- .../Component/Asset/Tests/UrlPackageTest.php | 2 +- .../Tests/Loader/DelegatingLoaderTest.php | 8 +-- .../Config/Tests/Loader/FileLoaderTest.php | 4 +- .../Tests/Loader/LoaderResolverTest.php | 8 +-- .../Config/Tests/Loader/LoaderTest.php | 16 ++--- .../Config/Tests/Util/XmlUtilsTest.php | 2 +- .../Console/Tests/ApplicationTest.php | 16 ++--- .../Console/Tests/Command/CommandTest.php | 2 +- .../Console/Tests/Helper/HelperSetTest.php | 2 +- .../Tests/Helper/LegacyProgressHelperTest.php | 2 +- .../Console/Tests/Helper/ProgressBarTest.php | 6 +- .../Tests/Helper/QuestionHelperTest.php | 4 +- .../Helper/SymfonyQuestionHelperTest.php | 2 +- .../Debug/Tests/ErrorHandlerTest.php | 18 +++--- .../Debug/Tests/ExceptionHandlerTest.php | 4 +- .../Compiler/ExtensionCompilerPassTest.php | 6 +- .../MergeExtensionConfigurationPassTest.php | 4 +- .../Tests/ContainerBuilderTest.php | 6 +- .../RealServiceInstantiatorTest.php | 2 +- .../ContainerAwareEventDispatcherTest.php | 20 +++--- .../Debug/TraceableEventDispatcherTest.php | 4 +- .../RegisterListenersPassTest.php | 14 ++--- .../Tests/ImmutableEventDispatcherTest.php | 6 +- .../Tests/ExpressionLanguageTest.php | 4 +- .../Component/Form/Tests/AbstractFormTest.php | 12 ++-- .../Form/Tests/AbstractLayoutTest.php | 2 +- .../Form/Tests/AbstractRequestHandlerTest.php | 9 +-- .../Component/Form/Tests/ButtonTest.php | 4 +- .../Factory/CachingFactoryDecoratorTest.php | 40 ++++++------ .../Factory/DefaultChoiceListFactoryTest.php | 8 +-- .../Factory/PropertyAccessDecoratorTest.php | 32 +++++----- .../Tests/ChoiceList/LazyChoiceListTest.php | 4 +- .../LegacyChoiceListAdapterTest.php | 2 +- .../Component/Form/Tests/CompoundFormTest.php | 2 +- .../DataMapper/PropertyPathMapperTest.php | 4 +- .../BaseDateTimeTransformerTest.php | 12 +--- .../DataTransformerChainTest.php | 8 +-- .../FixRadioInputListenerTest.php | 10 +-- .../FixUrlProtocolListenerTest.php | 6 +- .../MergeCollectionListenerTest.php | 6 +- .../EventListener/ResizeFormListenerTest.php | 8 +-- .../Core/EventListener/TrimListenerTest.php | 6 +- .../LegacySessionCsrfProviderTest.php | 8 +-- .../CsrfValidationListenerTest.php | 10 +-- .../Csrf/Type/FormTypeCsrfExtensionTest.php | 4 +- .../DataCollectorExtensionTest.php | 2 +- .../DataCollector/FormDataCollectorTest.php | 8 +-- .../DataCollector/FormDataExtractorTest.php | 16 ++--- .../Type/DataCollectorTypeExtensionTest.php | 4 +- .../LegacyBindRequestListenerTest.php | 20 +++--- .../Constraints/FormValidatorTest.php | 63 +++++++++---------- .../EventListener/ValidationListenerTest.php | 14 ++--- .../Type/FormTypeValidatorExtensionTest.php | 4 +- .../Extension/Validator/Type/TypeTestCase.php | 4 +- .../Type/UploadValidatorExtensionTest.php | 2 +- .../Validator/Util/ServerParamsTest.php | 4 +- .../Validator/ValidatorExtensionTest.php | 4 +- .../Validator/ValidatorTypeGuesserTest.php | 2 +- .../ViolationMapper/ViolationMapperTest.php | 4 +- .../Component/Form/Tests/FormBuilderTest.php | 6 +- .../Component/Form/Tests/FormConfigTest.php | 4 +- .../Form/Tests/FormFactoryBuilderTest.php | 2 +- .../Component/Form/Tests/FormFactoryTest.php | 14 ++--- .../Component/Form/Tests/FormRegistryTest.php | 22 +++---- .../Form/Tests/ResolvedFormTypeTest.php | 32 +++++----- .../Component/Form/Tests/SimpleFormTest.php | 24 +++---- .../HttpFoundation/Tests/File/FileTest.php | 2 +- .../HttpFoundation/Tests/ResponseTest.php | 2 +- .../Handler/MemcacheSessionHandlerTest.php | 2 +- .../Handler/MemcachedSessionHandlerTest.php | 2 +- .../Storage/Handler/PdoSessionHandlerTest.php | 6 +- .../Handler/WriteCheckSessionHandlerTest.php | 8 +-- .../Storage/Proxy/SessionHandlerProxyTest.php | 2 +- .../HttpKernel/Tests/Bundle/BundleTest.php | 4 +- .../CacheClearer/ChainCacheClearerTest.php | 2 +- .../Tests/Config/FileLocatorTest.php | 4 +- .../Controller/ControllerResolverTest.php | 4 +- .../DataCollector/LoggerDataCollectorTest.php | 2 +- .../RequestDataCollectorTest.php | 2 +- .../DataCollector/TimeDataCollectorTest.php | 2 +- .../Debug/TraceableEventDispatcherTest.php | 2 +- .../ContainerAwareHttpKernelTest.php | 12 ++-- .../FragmentRendererPassTest.php | 25 +++----- .../LazyLoadingFragmentHandlerTest.php | 6 +- .../MergeExtensionConfigurationPassTest.php | 14 +---- .../AddRequestFormatsListenerTest.php | 2 +- .../DebugHandlersListenerTest.php | 6 +- .../EventListener/ExceptionListenerTest.php | 4 +- .../EventListener/FragmentListenerTest.php | 2 +- .../EventListener/LocaleListenerTest.php | 14 ++--- .../EventListener/ProfilerListenerTest.php | 4 +- .../EventListener/ResponseListenerTest.php | 2 +- .../EventListener/RouterListenerTest.php | 20 +++--- .../EventListener/SurrogateListenerTest.php | 6 +- .../EventListener/TestSessionListenerTest.php | 2 +- .../EventListener/TranslatorListenerTest.php | 6 +- .../ValidateRequestListenerTest.php | 2 +- .../Tests/Fragment/FragmentHandlerTest.php | 2 +- .../Fragment/HIncludeFragmentRendererTest.php | 2 +- .../Fragment/InlineFragmentRendererTest.php | 12 ++-- .../HttpKernel/Tests/HttpCache/EsiTest.php | 2 +- .../HttpKernel/Tests/HttpCache/SsiTest.php | 2 +- .../HttpKernel/Tests/HttpKernelTest.php | 4 +- .../Component/HttpKernel/Tests/KernelTest.php | 6 +- .../Bundle/Reader/BundleEntryReaderTest.php | 2 +- .../Tests/ProcessFailedExceptionTest.php | 18 +----- .../Tests/PropertyAccessorCollectionTest.php | 16 ++--- .../Tests/Generator/UrlGeneratorTest.php | 2 +- .../Tests/Loader/PhpFileLoaderTest.php | 2 +- .../Tests/Loader/XmlFileLoaderTest.php | 2 +- .../Tests/Loader/YamlFileLoaderTest.php | 2 +- .../Component/Routing/Tests/RouterTest.php | 12 ++-- .../Acl/Tests/Dbal/MutableAclProviderTest.php | 2 +- .../Security/Acl/Tests/Domain/AclTest.php | 6 +- .../Acl/Tests/Domain/AuditLoggerTest.php | 2 +- .../Security/Acl/Tests/Domain/EntryTest.php | 4 +- .../Acl/Tests/Domain/FieldEntryTest.php | 4 +- .../Domain/PermissionGrantingStrategyTest.php | 4 +- .../SecurityIdentityRetrievalStrategyTest.php | 6 +- .../Tests/Domain/UserSecurityIdentityTest.php | 2 +- .../Security/Acl/Tests/Voter/AclVoterTest.php | 20 +++--- .../AuthenticationProviderManagerTest.php | 24 +++---- .../AuthenticationTrustResolverTest.php | 6 +- .../AnonymousAuthenticationProviderTest.php | 6 +- .../DaoAuthenticationProviderTest.php | 52 +++++++-------- ...uthenticatedAuthenticationProviderTest.php | 16 ++--- .../RememberMeAuthenticationProviderTest.php | 14 ++--- .../UserAuthenticationProviderTest.php | 26 ++++---- .../Token/AbstractTokenTest.php | 12 ++-- .../Token/RememberMeTokenTest.php | 2 +- .../Token/Storage/TokenStorageTest.php | 2 +- .../AccessDecisionManagerTest.php | 12 ++-- .../AuthorizationCheckerTest.php | 10 +-- .../Authorization/Voter/AbstractVoterTest.php | 2 +- .../Voter/AuthenticatedVoterTest.php | 6 +- .../Voter/ExpressionVoterTest.php | 10 +-- .../Authorization/Voter/RoleVoterTest.php | 2 +- .../Core/Tests/Encoder/EncoderFactoryTest.php | 4 +- .../Tests/Encoder/UserPasswordEncoderTest.php | 12 ++-- .../Core/Tests/LegacySecurityContextTest.php | 20 +++--- .../Core/Tests/Role/SwitchUserRoleTest.php | 4 +- .../Core/Tests/User/ChainUserProviderTest.php | 4 +- .../Core/Tests/User/UserCheckerTest.php | 16 ++--- .../Constraints/UserPasswordValidatorTest.php | 12 ++-- .../Csrf/Tests/CsrfTokenManagerTest.php | 4 +- .../UriSafeTokenGeneratorTest.php | 2 +- .../Security/Http/Tests/AccessMapTest.php | 6 +- ...efaultAuthenticationFailureHandlerTest.php | 16 ++--- ...efaultAuthenticationSuccessHandlerTest.php | 10 +-- .../SimpleAuthenticationHandlerTest.php | 12 ++-- .../BasicAuthenticationEntryPointTest.php | 4 +- .../DigestAuthenticationEntryPointTest.php | 6 +- .../FormAuthenticationEntryPointTest.php | 14 ++--- .../AbstractPreAuthenticatedListenerTest.php | 32 +++++----- .../Tests/Firewall/AccessListenerTest.php | 54 ++++++++-------- .../AnonymousAuthenticationListenerTest.php | 22 +++---- .../BasicAuthenticationListenerTest.php | 50 +++++++-------- .../Tests/Firewall/ChannelListenerTest.php | 32 +++++----- .../Tests/Firewall/ContextListenerTest.php | 32 +++++----- .../Tests/Firewall/ExceptionListenerTest.php | 22 +++---- .../Tests/Firewall/LogoutListenerTest.php | 10 +-- .../Tests/Firewall/RememberMeListenerTest.php | 38 +++++------ .../RemoteUserAuthenticationListenerTest.php | 12 ++-- .../SimplePreAuthenticationListenerTest.php | 14 ++--- .../Tests/Firewall/SwitchUserListenerTest.php | 36 +++++------ .../X509AuthenticationListenerTest.php | 16 ++--- .../Security/Http/Tests/FirewallMapTest.php | 30 ++++----- .../Security/Http/Tests/FirewallTest.php | 42 ++++++------- .../Security/Http/Tests/HttpUtilsTest.php | 24 +++---- .../CookieClearingLogoutHandlerTest.php | 2 +- .../DefaultLogoutSuccessHandlerTest.php | 4 +- .../Tests/Logout/SessionLogoutHandlerTest.php | 6 +- .../AbstractRememberMeServicesTest.php | 26 ++++---- ...istentTokenBasedRememberMeServicesTest.php | 32 +++++----- .../Tests/RememberMe/ResponseListenerTest.php | 2 +- .../TokenBasedRememberMeServicesTest.php | 16 ++--- .../SessionAuthenticationStrategyTest.php | 10 +-- ...PasswordFormAuthenticationListenerTest.php | 14 ++--- .../Tests/Mapping/ClassMetadataTest.php | 12 ++-- .../Factory/ClassMetadataFactoryTest.php | 4 +- .../Normalizer/AbstractNormalizerTest.php | 4 +- .../Normalizer/GetSetMethodNormalizerTest.php | 4 +- .../Tests/Normalizer/ObjectNormalizerTest.php | 4 +- .../Normalizer/PropertyNormalizerTest.php | 4 +- .../Serializer/Tests/SerializerTest.php | 12 ++-- .../Templating/Tests/DelegatingEngineTest.php | 2 +- .../Helper/LegacyCoreAssetsHelperTest.php | 2 +- .../Tests/Loader/CacheLoaderTest.php | 4 +- .../Tests/Loader/FilesystemLoaderTest.php | 2 +- .../Templating/Tests/Loader/LoaderTest.php | 4 +- .../Tests/LoggingTranslatorTest.php | 4 +- .../Tests/MessageCatalogueTest.php | 14 ++--- .../Translation/Tests/TranslatorCacheTest.php | 8 +-- .../Tests/Writer/TranslationWriterTest.php | 2 +- .../AbstractConstraintValidatorTest.php | 8 +-- .../Tests/LegacyExecutionContextTest.php | 8 +-- .../LazyLoadingMetadataFactoryTest.php | 6 +- .../Tests/Mapping/Loader/FilesLoaderTest.php | 2 +- .../Tests/Mapping/Loader/LoaderChainTest.php | 12 ++-- .../Tests/Validator/Abstract2Dot5ApiTest.php | 10 +-- .../Tests/Validator/AbstractLegacyApiTest.php | 4 +- .../Tests/Validator/AbstractValidatorTest.php | 4 +- .../RecursiveValidator2Dot5ApiTest.php | 2 +- .../Validator/Tests/ValidatorBuilderTest.php | 8 +-- 272 files changed, 1192 insertions(+), 1286 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php index 45d0310e6dac8..6fa34345cd4a3 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -139,7 +139,7 @@ private function createCollector($queries) ->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 4848d88818f8a..98583b3bb13b2 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php @@ -72,14 +72,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'); 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/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 5341e81f7b602..5a93de6addd7c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -1300,7 +1300,7 @@ public function testPropertyOption() 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 37a72b07b6b02..42f56b0ca83c3 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') @@ -137,7 +137,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 3c52a7d506074..cdc553b2f05b9 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -150,7 +150,7 @@ public function testSupportProxy() 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 33e484320a56a..348b46ddaa75e 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -63,7 +63,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)) @@ -92,7 +92,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/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/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/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 c7195ab577820..2951e4471f731 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 406c1cef16bf4..d26714530c954 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -39,7 +39,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 9e39ac35dc421..7e4c55e984b4a 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -40,7 +40,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 7fa88eef00c7e..6509c405e7bc9 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -39,7 +39,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 48bebdc13f8f5..8101a7d59b0b6 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 035dc4f671431..8d3ede471c506 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' @@ -99,7 +99,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 590b9ef75c617..02732f1932e82 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 0a3d30bdd5e5e..408b7cfd145d5 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 cbd21fc46edd2..3a444e8a1f77d 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( 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/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php index 25d9a72b961a9..aac62095b1a14 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 fc7e2155537fe..cb7f698bc664e 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 24a4f625f6db5..8690263374e7b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -68,7 +68,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') @@ -78,7 +78,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') @@ -88,7 +88,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') @@ -97,7 +97,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') @@ -112,7 +112,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') @@ -129,7 +129,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 00ffa4c1fd162..36e8ed90a7117 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php @@ -175,12 +175,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 307770316c6e6..d7f40a24d8b4a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php @@ -33,12 +33,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)); @@ -84,7 +84,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') @@ -104,13 +104,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') @@ -128,10 +128,10 @@ private function getContainerWithTokenStorage($token = null) 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(); @@ -146,10 +146,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)); @@ -169,10 +169,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)); @@ -184,10 +184,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 Controller(); @@ -208,10 +208,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('get')->will($this->returnValue($templating)); $controller = new Controller(); @@ -222,10 +222,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('get')->will($this->returnValue($templating)); $controller = new Controller(); @@ -236,9 +236,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('get')->will($this->returnValue($templating)); $controller = new Controller(); @@ -256,12 +256,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 Controller(); @@ -272,12 +272,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 Controller(); @@ -288,9 +288,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/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/LegacyFragmentRendererPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php index 97c98d5d8f1ab..e5c6adba8c974 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php @@ -33,15 +33,12 @@ public function testContentRendererWithoutInterface() 'my_content_renderer' => array(), ); - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); $definition->expects($this->atLeastOnce()) ->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)); @@ -65,22 +62,19 @@ public function testValidContentRenderer() 'my_content_renderer' => array(), ); - $renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $renderer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); $renderer ->expects($this->once()) ->method('addMethodCall') ->with('addRenderer', array(new Reference('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\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\RendererService')); - $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/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php index ad0d65390d2f9..b71fe0a80766d 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/SerializerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php index a098c4fd626ac..3e592916a0a2a 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->atLeastOnce()) ->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/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php index 1757cfee9618c..cc85cdb02acb2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php @@ -22,7 +22,7 @@ class LegacyContainerAwareHIncludeFragmentRendererTest extends TestCase { public function testRender() { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->once()) ->method('get') ->will($this->returnValue($this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock())) 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 48a7737dd8080..46c9303096e62 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php @@ -31,7 +31,7 @@ protected function setUp() */ public function testLegacyGetSecurity() { - $securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); + $securityContext = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContextInterface')->getMock(); $this->assertNull($this->globals->getSecurity()); $this->container->set('security.context', $securityContext); @@ -45,7 +45,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()); } @@ -55,8 +55,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); @@ -75,9 +75,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/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php index 479475732c0aa..aba568c51fa56 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 e09b0d3f33a85..11fe9da001e66 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)); @@ -96,7 +96,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->setLocale('invalid locale'); @@ -121,7 +121,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') @@ -149,7 +149,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') @@ -207,7 +207,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') @@ -248,7 +248,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/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php index acf4788adc7ee..c7845959ac42f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php @@ -54,7 +54,7 @@ public function testCollectWhenAuthenticationTokenIsNull() */ public function testLegacyCollectWhenAuthenticationTokenIsNull() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContextInterface')->getMock(); $collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy()); $collector->collect($this->getRequest(), $this->getResponse()); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php index e4a47a07694b5..4dfb100e34e84 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php @@ -28,7 +28,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/Extension/LegacyAssetsExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php index b7b5ba4382836..66027981d42dc 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php @@ -84,7 +84,7 @@ private function createRequestContextMock($scheme, $host, $httpPort, $httpsPort) private function createContainerMock($helper) { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->any()) ->method('get') ->with('templating.helper.assets') 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/TokenParser/LegacyRenderTokenParserTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php index 6a5806cd7a965..13881c108d603 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php @@ -25,7 +25,7 @@ class LegacyRenderTokenParserTest extends 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 RenderTokenParser()); $stream = $env->tokenize(new \Twig_Source($source, '')); $parser = new \Twig_Parser($env); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index 045be103647f9..0ae9fa80fc331 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 5eaa95c0a3022..2237e18b29e54 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -46,7 +46,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->addScope(new Scope('request')); 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/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/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/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index 7ce5418994773..237c197e025ac 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/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 2612be9e9eaaa..9c9acd3ec616e 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -447,7 +447,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'))); @@ -469,7 +469,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') @@ -516,7 +516,7 @@ public function testLegacyAsXml() 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') @@ -540,7 +540,7 @@ public function testRenderException() $tester->run(array('command' => 'foo3:bar'), array('decorated' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(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') @@ -556,7 +556,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') @@ -572,7 +572,7 @@ public function testRenderExceptionWithDoubleWidthCharacters() $tester->run(array('command' => 'foo'), array('decorated' => true)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getDisplay(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') @@ -706,7 +706,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') @@ -721,7 +721,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 695759cb9d57c..e1593b0bbd6d7 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -273,7 +273,7 @@ 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')); diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php index 24deb341f681c..a31615ee80b61 100644 --- a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php @@ -109,7 +109,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/LegacyProgressHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php index 7c866e8570865..bbb9f8b076b4d 100644 --- a/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php @@ -142,7 +142,7 @@ public function testRegressProgress() public function testRedrawFrequency() { - $progress = $this->getMock('Symfony\Component\Console\Helper\ProgressHelper', array('display')); + $progress = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressHelper')->setMethods(array('display'))->getMock(); $progress->expects($this->exactly(4)) ->method('display'); diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index 2d61fd6a85f75..612d13d7dc4d7 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..ac9976ea726d6 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -132,7 +132,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/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index f3b7701c3f738..973c3d7501693 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -133,7 +133,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)); @@ -212,7 +212,7 @@ public function testHandleError() restore_error_handler(); restore_exception_handler(); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $that = $this; $warnArgCheck = function ($logLevel, $message, $context) use ($that) { @@ -237,7 +237,7 @@ public function testHandleError() restore_error_handler(); restore_exception_handler(); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $that = $this; $logArgCheck = function ($level, $message, $context) use ($that) { @@ -278,7 +278,7 @@ public function testHandleDeprecation() $that->assertArrayHasKey('stack', $context); }; - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger ->expects($this->once()) ->method('log') @@ -297,7 +297,7 @@ public function testHandleException() $exception = new \Exception('foo'); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $that = $this; $logArgCheck = function ($level, $message, $context) use ($that) { @@ -344,7 +344,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)) @@ -384,7 +384,7 @@ public function testHandleFatalError() 'line' => 123, ); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $that = $this; $logArgCheck = function ($level, $message, $context) use ($that) { @@ -436,7 +436,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') @@ -489,7 +489,7 @@ public function testLegacyInterface() restore_error_handler(); restore_exception_handler(); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $that = $this; $logArgCheck = function ($level, $message, $context) use ($that) { diff --git a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php index d4b93c0838922..fb105828d23f2 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'); @@ -119,7 +119,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/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 2332dc6ec8d86..b95574ab4645f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -249,7 +249,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); } @@ -620,7 +620,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'); @@ -632,7 +632,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/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/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php index 0f3f5ba766b4e..18aac429d4c84 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php @@ -30,7 +30,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()) @@ -51,7 +51,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()) @@ -86,7 +86,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()) @@ -109,7 +109,7 @@ public function testPreventDuplicateListenerService() */ public function testTriggerAListenerServiceOutOfScope() { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $scope = new Scope('scope'); $container = new Container(); @@ -129,7 +129,7 @@ public function testReEnteringAScope() { $event = new Event(); - $service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service1 = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $service1 ->expects($this->exactly(2)) @@ -148,7 +148,7 @@ public function testReEnteringAScope() $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); $dispatcher->dispatch('onEvent', $event); - $service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); + $service2 = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); $service2 ->expects($this->once()) @@ -170,7 +170,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); @@ -196,7 +196,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); @@ -213,7 +213,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); @@ -228,7 +228,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 25a9533da4ece..1b424e93fcaa3 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php @@ -103,7 +103,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); @@ -118,7 +118,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/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/Form/Tests/AbstractFormTest.php b/src/Symfony/Component/Form/Tests/AbstractFormTest.php index dc590c918cec4..ba8b574751c7d 100644 --- a/src/Symfony/Component/Form/Tests/AbstractFormTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractFormTest.php @@ -37,7 +37,7 @@ protected function setUp() // We need an actual dispatcher to use the deprecated // bindRequest() method $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(); } @@ -73,8 +73,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') @@ -91,7 +91,7 @@ protected function getMockForm($name = 'name') */ protected function getDataMapper() { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); + return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); } /** @@ -99,7 +99,7 @@ protected function getDataMapper() */ protected function getDataTransformer() { - return $this->getMock('Symfony\Component\Form\DataTransformerInterface'); + return $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); } /** @@ -107,6 +107,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 6441c07f6bf39..05f52249a98f9 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(); } diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php index d6e0b4f67194b..93f6d7fb22599 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 d3d530afb58f8..251a1dfb5844a 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); } @@ -295,7 +295,7 @@ public function testCreateFromFlippedChoicesDifferentValueClosure() 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()) @@ -309,8 +309,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(); @@ -329,7 +329,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 () {}; @@ -344,7 +344,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 () {}; @@ -366,7 +366,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()) @@ -382,7 +382,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(); @@ -402,7 +402,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()) @@ -418,7 +418,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(); @@ -438,7 +438,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()) @@ -454,7 +454,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(); @@ -474,7 +474,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()) @@ -490,7 +490,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(); @@ -510,7 +510,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()) @@ -526,7 +526,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(); @@ -546,7 +546,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()) @@ -562,7 +562,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(); @@ -582,7 +582,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()) @@ -598,7 +598,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 741cde5b43921..ac6f5d5c719b9 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -332,7 +332,7 @@ function ($choice) { 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); @@ -341,7 +341,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); @@ -771,7 +771,7 @@ public function testCreateViewForFlatLegacyChoiceList() $preferred = array(new LegacyChoiceView('x', 'x', 'Preferred')); $other = array(new LegacyChoiceView('y', 'y', 'Other')); - $list = $this->getMock('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface')->getMock(); $list->expects($this->once()) ->method('getPreferredViews') @@ -798,7 +798,7 @@ public function testCreateViewForNestedLegacyChoiceList() new LegacyChoiceView('z', 'z', 'Other one'), ); - $list = $this->getMock('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'); + $list = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface')->getMock(); $list->expects($this->once()) ->method('getPreferredViews') diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index 44490a686a83d..5dc192c3f24bb 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); } @@ -84,7 +84,7 @@ public function testCreateFromFlippedChoices() 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') @@ -114,7 +114,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') @@ -128,7 +128,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') @@ -142,7 +142,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') @@ -159,7 +159,7 @@ public function testCreateViewPreferredChoicesAsPropertyPath() 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') @@ -177,7 +177,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') @@ -194,7 +194,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') @@ -212,7 +212,7 @@ public function testCreateViewLabelsAsPropertyPath() 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') @@ -230,7 +230,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') @@ -249,7 +249,7 @@ public function testCreateViewIndicesAsPropertyPath() 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') @@ -268,7 +268,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') @@ -288,7 +288,7 @@ public function testCreateViewGroupsAsPropertyPath() 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') @@ -309,7 +309,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') @@ -329,7 +329,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') @@ -350,7 +350,7 @@ public function testCreateViewAttrAsPropertyPath() 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 5db96e6a7dee1..3aae8e683d774 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php @@ -37,8 +37,8 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->innerList = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); - $this->loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); + $this->innerList = $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/ChoiceList/LegacyChoiceListAdapterTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LegacyChoiceListAdapterTest.php index 911d8c001e054..32f07294243c7 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/LegacyChoiceListAdapterTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/LegacyChoiceListAdapterTest.php @@ -32,7 +32,7 @@ class LegacyChoiceListAdapterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->adaptedList = $this->getMock('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'); + $this->adaptedList = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface')->getMock(); $this->list = new LegacyChoiceListAdapter($this->adaptedList); } diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index fdf83896d55a6..de6db05ab15c4 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -925,7 +925,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/EventListener/FixRadioInputListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php index b936ea35ccf36..65cc25539483c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php @@ -39,7 +39,7 @@ protected function tearDown() public function testFixRadio() { $data = '1'; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $listener = new FixRadioInputListener($this->choiceList, true); @@ -51,7 +51,7 @@ public function testFixRadio() public function testFixZero() { $data = '0'; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $listener = new FixRadioInputListener($this->choiceList, true); @@ -63,7 +63,7 @@ public function testFixZero() public function testFixEmptyString() { $data = ''; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $listener = new FixRadioInputListener($this->choiceList, true); @@ -77,7 +77,7 @@ public function testConvertEmptyStringToPlaceholderIfNotFound() $list = new ArrayKeyChoiceList(array(0 => 'A', 1 => 'B')); $data = ''; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $listener = new FixRadioInputListener($list, true); @@ -91,7 +91,7 @@ public function testDontConvertEmptyStringToPlaceholderIfNoPlaceholderUsed() $list = new ArrayKeyChoiceList(array(0 => 'A', 1 => 'B')); $data = ''; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $listener = new FixRadioInputListener($list, false); 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 e87f2dcd510e5..a6b111e78e63a 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(); @@ -55,7 +55,7 @@ public function testTrimUtf8Separators($hex) $symbol = mb_convert_encoding($binary, 'UTF-8', 'UCS-2BE'); $symbol = $symbol."ab\ncd".$symbol; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $symbol); $filter = new TrimListener(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php index 8618de18047c1..43918643b617e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php @@ -23,13 +23,7 @@ class LegacySessionCsrfProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->session = $this->getMock( - 'Symfony\Component\HttpFoundation\Session\Session', - array(), - array(), - '', - false // don't call constructor - ); + $this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); $this->provider = new SessionCsrfProvider($this->session, 'SECRET'); } 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 bc78a4a442b91..4a88d18d71abd 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -47,8 +47,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 abef0b335896d..993d818d5b62a 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 fc0b76fdf0557..ac74746cd83e2 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('getName') ->will($this->returnValue('type_name')); @@ -91,7 +91,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('getName') ->will($this->returnValue('type_name')); @@ -129,7 +129,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('getName') ->will($this->returnValue('type_name')); @@ -164,7 +164,7 @@ 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('getName') ->will($this->returnValue('type_name')); @@ -174,11 +174,11 @@ public function testExtractConfigurationBuildsIdRecursively() $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 03e0146a2b4ad..4131a46cee05a 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/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php index 37765991ccf59..f84220c78c9de 100644 --- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php @@ -92,7 +92,7 @@ public function testSubmitRequest($method) 'REQUEST_METHOD' => $method, )); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $config = new FormConfigBuilder('author', null, $dispatcher); $form = new Form($config); $event = new FormEvent($form, $request); @@ -115,7 +115,7 @@ public function testSubmitRequestWithEmptyName($method) 'REQUEST_METHOD' => $method, )); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $config = new FormConfigBuilder('', null, $dispatcher); $form = new Form($config); $event = new FormEvent($form, $request); @@ -138,10 +138,10 @@ public function testSubmitEmptyRequestToCompoundForm($method) 'REQUEST_METHOD' => $method, )); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $config = new FormConfigBuilder('author', null, $dispatcher); $config->setCompound(true); - $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')); + $config->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock()); $form = new Form($config); $event = new FormEvent($form, $request); @@ -161,7 +161,7 @@ public function testSubmitEmptyRequestToSimpleForm($method) 'REQUEST_METHOD' => $method, )); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $config = new FormConfigBuilder('author', null, $dispatcher); $config->setCompound(false); $form = new Form($config); @@ -181,7 +181,7 @@ public function testSubmitGetRequest() 'REQUEST_METHOD' => 'GET', )); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $config = new FormConfigBuilder('author', null, $dispatcher); $form = new Form($config); $event = new FormEvent($form, $request); @@ -201,7 +201,7 @@ public function testSubmitGetRequestWithEmptyName() 'REQUEST_METHOD' => 'GET', )); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $config = new FormConfigBuilder('', null, $dispatcher); $form = new Form($config); $event = new FormEvent($form, $request); @@ -221,10 +221,10 @@ public function testSubmitEmptyGetRequestToCompoundForm() 'REQUEST_METHOD' => 'GET', )); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $config = new FormConfigBuilder('author', null, $dispatcher); $config->setCompound(true); - $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')); + $config->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock()); $form = new Form($config); $event = new FormEvent($form, $request); @@ -240,7 +240,7 @@ public function testSubmitEmptyGetRequestToSimpleForm() 'REQUEST_METHOD' => 'GET', )); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $config = new FormConfigBuilder('author', null, $dispatcher); $config->setCompound(false); $form = new Form($config); 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 9e7bdee25ee4b..55e09b3496697 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -45,12 +45,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(); } @@ -67,7 +64,7 @@ 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) @@ -83,7 +80,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')); @@ -110,7 +107,7 @@ public function testValidateConstraints() public function testDontValidateIfParentWithoutCascadeValidation() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent', null, array('cascade_validation' => false)) ->setCompound(true) @@ -144,7 +141,7 @@ public function testMissingConstraintIndex() public function testValidateConstraintsEvenIfNoCascadeValidation() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $constraint1 = new NotNull(array('groups' => array('group1', 'group2'))); $constraint2 = new NotBlank(array('groups' => 'group2')); @@ -171,7 +168,7 @@ public function testValidateConstraintsEvenIfNoCascadeValidation() public function testDontValidateIfNoValidationGroups() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $form = $this->getBuilder('name', '\stdClass', array( 'validation_groups' => array(), @@ -190,9 +187,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(), @@ -214,7 +211,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', @@ -248,7 +245,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', @@ -283,9 +280,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', @@ -318,7 +315,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; }, @@ -348,7 +345,7 @@ function () { throw new TransformationFailedException(); } 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) @@ -364,7 +361,7 @@ 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) @@ -379,7 +376,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'); }); @@ -397,7 +394,7 @@ public function testHandleClosureValidationGroups() public function testUseValidationGroupOfClickedButton() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent', null, array('cascade_validation' => true)) ->setCompound(true) @@ -423,7 +420,7 @@ public function testUseValidationGroupOfClickedButton() public function testDontUseValidationGroupOfUnclickedButton() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent', null, array('cascade_validation' => true)) ->setCompound(true) @@ -449,7 +446,7 @@ public function testDontUseValidationGroupOfUnclickedButton() public function testUseInheritedValidationGroup() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parentOptions = array( 'validation_groups' => 'group', @@ -473,7 +470,7 @@ public function testUseInheritedValidationGroup() public function testUseInheritedCallbackValidationGroup() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parentOptions = array( 'validation_groups' => array($this, 'getValidationGroups'), @@ -498,7 +495,7 @@ public function testUseInheritedCallbackValidationGroup() public function testUseInheritedClosureValidationGroup() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parentOptions = array( 'validation_groups' => function (FormInterface $form) { @@ -525,7 +522,7 @@ public function testUseInheritedClosureValidationGroup() public function testAppendPropertyPath() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $form = $this->getBuilder('name', '\stdClass') ->setData($object) ->getForm(); @@ -605,9 +602,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') @@ -655,6 +652,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 91608aebe8e06..72a9bdfffc719 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\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\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 @@ -183,7 +183,7 @@ public function testValidateWithEmptyViolationList() public function testValidatorInterfaceSinceSymfony25() { // Mock of ValidatorInterface since apiVersion 2.5 - $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); @@ -192,7 +192,7 @@ public function testValidatorInterfaceSinceSymfony25() public function testValidatorInterfaceUntilSymfony24() { // Mock of ValidatorInterface until apiVersion 2.4 - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); + $validator = $this->getMockBuilder('Symfony\Component\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/FormTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php index 4ca10da50e88d..79e4dc78f7ac6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php @@ -40,7 +40,7 @@ public function testSubmitValidatesData() public function testValidatorInterfaceSinceSymfony25() { // Mock of ValidatorInterface since apiVersion 2.5 - $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); @@ -49,7 +49,7 @@ public function testValidatorInterfaceSinceSymfony25() public function testValidatorInterfaceUntilSymfony24() { // Mock of ValidatorInterface until apiVersion 2.4 - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); + $validator = $this->getMockBuilder('Symfony\Component\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 8ace4d3c3b9e8..8c558dd3d7568 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php @@ -20,8 +20,8 @@ abstract class TypeTestCase extends BaseTypeTestCase protected function setUp() { - $this->validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); - $metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); + $this->validator = $this->getMockBuilder('Symfony\Component\Validator\ValidatorInterface')->getMock(); + $metadataFactory = $this->getMockBuilder('Symfony\Component\Validator\MetadataFactoryInterface')->getMock(); $this->validator->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory)); $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $metadataFactory->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/ValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php index 74a170562207b..5a41f928ca52a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php @@ -56,8 +56,8 @@ public function test2Dot5ValidationApi() */ public function test2Dot4ValidationApi() { - $factory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); + $factory = $this->getMockBuilder('Symfony\Component\Validator\MetadataFactoryInterface')->getMock(); + $validator = $this->getMockBuilder('Symfony\Component\Validator\ValidatorInterface')->getMock(); $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata') ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php index bd065eeb4508c..a5e49d5e63769 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\MetadataFactoryInterface'); + $this->metadataFactory = $this->getMockBuilder('Symfony\Component\Validator\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 8c7b96587dc0b..e0edf5d89f7b9 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 2c3ab000ffe30..e41a8085b520d 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 86f2fbd72dcca..41de2d95a6a87 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -57,11 +57,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()) @@ -375,7 +375,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)) @@ -614,6 +614,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 c99e45edf081a..3d6864b09e884 100644 --- a/src/Symfony/Component/Form/Tests/FormRegistryTest.php +++ b/src/Symfony/Component/Form/Tests/FormRegistryTest.php @@ -57,9 +57,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( @@ -71,7 +71,7 @@ protected function setUp() public function testGetTypeFromExtension() { $type = new FooType(); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $this->extension2->addType($type); @@ -94,7 +94,7 @@ public function testGetTypeWithTypeExtensions() $type = new FooType(); $ext1 = new FooTypeBarExtension(); $ext2 = new FooTypeBazExtension(); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $this->extension2->addType($type); $this->extension1->addTypeExtension($ext1); @@ -116,8 +116,8 @@ public function testGetTypeConnectsParent() { $parentType = new FooType(); $type = new FooSubType(); - $parentResolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $parentResolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $this->extension1->addType($parentType); $this->extension2->addType($type); @@ -146,8 +146,8 @@ public function testGetTypeConnectsParent() public function testGetTypeConnectsParentIfGetParentReturnsInstance() { $type = new FooSubTypeWithParentInstance(); - $parentResolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $parentResolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $this->extension1->addType($type); @@ -183,7 +183,7 @@ public function testGetTypeThrowsExceptionIfTypeNotFound() public function testHasTypeAfterLoadingFromExtension() { $type = new FooType(); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $this->resolvedTypeFactory->expects($this->once()) ->method('createResolvedType') @@ -208,7 +208,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); $this->assertNull($registry->getTypeGuesser()); diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 234d52cf3903e..942c06e43e4f2 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -43,9 +43,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(); @@ -101,7 +101,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\OptionsResolverInterface'); + $optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolverInterface')->getMock(); $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) @@ -129,7 +129,7 @@ public function testCreateBuilderWithDataClassOption() { $givenOptions = array('data_class' => 'Foo'); $resolvedOptions = array('data_class' => '\stdClass'); - $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface'); + $optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolverInterface')->getMock(); $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) @@ -168,7 +168,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()) @@ -198,7 +198,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); @@ -208,8 +208,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); @@ -220,8 +220,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(); $test = $this; $i = 0; @@ -264,8 +264,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(); $test = $this; $i = 0; @@ -310,7 +310,7 @@ public function testFinishView() */ private function getMockFormType() { - return $this->getMock('Symfony\Component\Form\AbstractType', array('getName', 'configureOptions', 'finishView', 'buildView', 'buildForm')); + return $this->getMockBuilder('Symfony\Component\Form\AbstractType')->setMethods(array('getName', 'configureOptions', 'finishView', 'buildView', 'buildForm'))->getMock(); } /** @@ -318,7 +318,7 @@ private function getMockFormType() */ 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(); } /** @@ -326,7 +326,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 8774ad0468e4d..725aff7296632 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -685,8 +685,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()) @@ -699,10 +699,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); @@ -720,9 +720,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()) @@ -857,7 +857,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( '' => '', @@ -921,7 +921,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) @@ -1034,7 +1034,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/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/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 d2775a80a20f1..052296a4c5fbb 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/Tests/Bundle/BundleTest.php b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php index 6320c0e8b22a3..5faf795f87815 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php @@ -22,7 +22,7 @@ class BundleTest extends \PHPUnit_Framework_TestCase 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(); @@ -48,7 +48,7 @@ public function testHttpKernelRegisterCommandsIgnoresCommandsThatAreRegisteredAs $container = new ContainerBuilder(); $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/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/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index f3b0ac025d6bf..53aa6ca3c64b0 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); @@ -215,7 +215,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 dd1608ce7f3a2..01b72fd7d80ed 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 3a0ab50321af9..ba70bfa92abd6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -185,7 +185,7 @@ protected function createResponse() */ protected function injectController($collector, $controller, $request) { - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); $httpKernel = new HttpKernel(new EventDispatcher(), $resolver); $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 f64d7247c0b48..32b286999f9d8 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -108,7 +108,7 @@ public function testListenerCanRemoveItselfWhenExecuted() protected function getHttpKernel($dispatcher, $controller) { - $resolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock(); $resolver->expects($this->once())->method('getController')->will($this->returnValue($controller)); $resolver->expects($this->once())->method('getArguments')->will($this->returnValue(array())); diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php index c32f5bb01a4f1..c6ce79783bde2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php @@ -34,7 +34,7 @@ public function testHandle($type) return $expected; }; - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $this ->expectsEnterScopeOnce($container) ->expectsLeaveScopeOnce($container) @@ -63,11 +63,11 @@ public function testVerifyRequestStackPushPopDuringHandle($type) return $expected; }; - $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'); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $dispatcher = new EventDispatcher(); $resolver = $this->getResolverMockFor($controller, $request); $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack); @@ -86,7 +86,7 @@ public function testHandleRestoresThePreviousRequestOnException($type) throw $expected; }; - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $this ->expectsEnterScopeOnce($container) ->expectsLeaveScopeOnce($container) @@ -95,7 +95,7 @@ public function testHandleRestoresThePreviousRequestOnException($type) ; $dispatcher = new EventDispatcher(); - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); $resolver = $this->getResolverMockFor($controller, $request); $stack = new RequestStack(); $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack); @@ -120,7 +120,7 @@ public function getProviderTypes() private function getResolverMockFor($controller, $request) { - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('getController') ->with($request) diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php index 3e2bfd072aaa8..c4652cd88a668 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php @@ -28,14 +28,14 @@ public function testLegacyFragmentRedererWithoutAlias() 'my_content_renderer' => array(array()), ); - $renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $renderer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); $renderer ->expects($this->once()) ->method('addMethodCall') ->with('addRenderer', array(new Reference('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')); @@ -45,10 +45,7 @@ public function testLegacyFragmentRedererWithoutAlias() ->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)); @@ -79,12 +76,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)); @@ -108,14 +102,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')); @@ -125,10 +119,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 581db45658902..a6170dfd4f542 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, false, $requestStack); 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 30c823c83cd1e..9b42f2775781d 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('fr', $router, $this->requestStack); $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 261b7fa393e20..479287ceacacd 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php @@ -40,7 +40,7 @@ public function testLegacyEventsWithoutRequestStack() ->method('collect') ->will($this->returnValue($profile)); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') ->disableOriginalConstructor() @@ -73,7 +73,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 122fe2f76a054..fd1543b6bc613 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) { - $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)); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = Request::create('http://localhost/'); $listener = new RouterListener($requestMatcher, new RequestContext(), $logger, $this->requestStack); 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/Fragment/FragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php index f8955f1248e53..4f87037c20473 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 d14ebb0d12c33..49e94a0bb09b9 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php @@ -51,7 +51,7 @@ public function testRenderWithObjectsAsAttributes() public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController() { - $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') @@ -84,7 +84,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); @@ -94,7 +94,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); @@ -114,7 +114,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') @@ -130,7 +130,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') @@ -142,7 +142,7 @@ private function getKernelExpectingRequest(Request $request) public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() { - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); $resolver ->expects($this->once()) ->method('getController') 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 0fd0fdec7b98f..270926f79c596 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -261,7 +261,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'); @@ -298,7 +298,7 @@ protected function getResolver($controller = null) $controller = function () { return new Response('Hello'); }; } - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); + $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); $resolver->expects($this->any()) ->method('getController') ->will($this->returnValue($controller)); diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 1fbc272beb8d1..8639818397e67 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -65,7 +65,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'); @@ -162,7 +162,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'); @@ -174,7 +174,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/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/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index de37353f91752..c1feaa6ba9ae7 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)); @@ -52,11 +48,7 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( $output = 'Command output'; $errorOutput = 'FATAL: Unexpected error'; - $process = $this->getMock( - 'Symfony\Component\Process\Process', - array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled'), - array($cmd) - ); + $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled'))->setConstructorArgs(array($cmd))->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->will($this->returnValue(false)); @@ -99,11 +91,7 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() $exitCode = 1; $exitText = 'General error'; - $process = $this->getMock( - 'Symfony\Component\Process\Process', - array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput'), - array($cmd) - ); + $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput'))->setConstructorArgs(array($cmd))->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->will($this->returnValue(false)); diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php index ad87687bc0561..9b53998cadb9d 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/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index b2a4ecd72db73..9f4090ff8609e 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 78065070a0a7c..f2edebd584bf4 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 de1542040b143..d3edc0849484b 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/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/Acl/Tests/Dbal/MutableAclProviderTest.php b/src/Symfony/Component/Security/Acl/Tests/Dbal/MutableAclProviderTest.php index c2169e43e39a3..6df2d79ccc29e 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Dbal/MutableAclProviderTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Dbal/MutableAclProviderTest.php @@ -255,7 +255,7 @@ public function testUpdateAclDoesNotAcceptUntrackedAcls() public function testUpdateDoesNothingWhenThereAreNoChanges() { - $con = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false); + $con = $this->getMockBuilder('Doctrine\DBAL\Connection')->disableOriginalConstructor()->getMock(); $con ->expects($this->never()) ->method('beginTransaction') diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/AclTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/AclTest.php index 84b9ba9005995..bfe85e2e0b86c 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/AclTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Domain/AclTest.php @@ -208,7 +208,7 @@ public function testIsFieldGranted() { $sids = array(new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity('ROLE_IDDQD')); $masks = array(1, 2, 4); - $strategy = $this->getMock('Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface'); + $strategy = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface')->getMock(); $acl = new Acl(1, new ObjectIdentity(1, 'foo'), $strategy, array(), true); $strategy @@ -225,7 +225,7 @@ public function testIsGranted() { $sids = array(new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity('ROLE_IDDQD')); $masks = array(1, 2, 4); - $strategy = $this->getMock('Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface'); + $strategy = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface')->getMock(); $acl = new Acl(1, new ObjectIdentity(1, 'foo'), $strategy, array(), true); $strategy @@ -488,7 +488,7 @@ protected function getListener($expectedChanges) { $aceProperties = array('aceOrder', 'mask', 'strategy', 'auditSuccess', 'auditFailure'); - $listener = $this->getMock('Doctrine\Common\PropertyChangedListener'); + $listener = $this->getMockBuilder('Doctrine\Common\PropertyChangedListener')->getMock(); foreach ($expectedChanges as $index => $property) { if (in_array($property, $aceProperties)) { $class = 'Symfony\Component\Security\Acl\Domain\Entry'; diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/AuditLoggerTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/AuditLoggerTest.php index 15538d346245a..ae11474a35c29 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/AuditLoggerTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Domain/AuditLoggerTest.php @@ -73,7 +73,7 @@ public function getTestLogData() protected function getEntry() { - return $this->getMock('Symfony\Component\Security\Acl\Model\AuditableEntryInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AuditableEntryInterface')->getMock(); } protected function getLogger() diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/EntryTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/EntryTest.php index ab8e481daf5fa..58f2786344c77 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/EntryTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Domain/EntryTest.php @@ -109,11 +109,11 @@ protected function getAce($acl = null, $sid = null) protected function getAcl() { - return $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock(); } protected function getSid() { - return $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface')->getMock(); } } diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/FieldEntryTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/FieldEntryTest.php index 735e2e86da75d..55b083ca4c32f 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/FieldEntryTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Domain/FieldEntryTest.php @@ -64,11 +64,11 @@ protected function getAce($acl = null, $sid = null) protected function getAcl() { - return $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock(); } protected function getSid() { - return $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface')->getMock(); } } diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/PermissionGrantingStrategyTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/PermissionGrantingStrategyTest.php index 34ef69081971a..463f2c126c98f 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/PermissionGrantingStrategyTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Domain/PermissionGrantingStrategyTest.php @@ -107,7 +107,7 @@ public function testIsGrantedCallsAuditLoggerOnGrant() $acl = $this->getAcl($strategy); $sid = new UserSecurityIdentity('johannes', 'Foo'); - $logger = $this->getMock('Symfony\Component\Security\Acl\Model\AuditLoggerInterface'); + $logger = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AuditLoggerInterface')->getMock(); $logger ->expects($this->once()) ->method('logIfNeeded') @@ -126,7 +126,7 @@ public function testIsGrantedCallsAuditLoggerOnDeny() $acl = $this->getAcl($strategy); $sid = new UserSecurityIdentity('johannes', 'Foo'); - $logger = $this->getMock('Symfony\Component\Security\Acl\Model\AuditLoggerInterface'); + $logger = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AuditLoggerInterface')->getMock(); $logger ->expects($this->once()) ->method('logIfNeeded') diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php index 160c27cfdde32..579a52e66ec86 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php @@ -109,7 +109,7 @@ public function getSecurityIdentityRetrievalTests() protected function getAccount($username, $class) { - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface', array(), array(), $class); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->setMockClassName($class)->getMock(); $account ->expects($this->any()) ->method('getUsername') @@ -121,7 +121,7 @@ protected function getAccount($username, $class) protected function getStrategy(array $roles = array(), $authenticationStatus = 'fullFledged') { - $roleHierarchy = $this->getMock('Symfony\Component\Security\Core\Role\RoleHierarchyInterface'); + $roleHierarchy = $this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleHierarchyInterface')->getMock(); $roleHierarchy ->expects($this->once()) ->method('getReachableRoles') @@ -129,7 +129,7 @@ protected function getStrategy(array $roles = array(), $authenticationStatus = ' ->will($this->returnValue($roles)) ; - $trustResolver = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver', array(), array('', '')); + $trustResolver = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver')->setConstructorArgs(array('', ''))->getMock(); $trustResolver ->expects($this->at(0)) diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/UserSecurityIdentityTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/UserSecurityIdentityTest.php index 09d3f0d560ffe..1eb52836bc84f 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/UserSecurityIdentityTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Domain/UserSecurityIdentityTest.php @@ -52,7 +52,7 @@ public function getCompareData() ->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') diff --git a/src/Symfony/Component/Security/Acl/Tests/Voter/AclVoterTest.php b/src/Symfony/Component/Security/Acl/Tests/Voter/AclVoterTest.php index 2148135f4bce6..bf8d6744acaa4 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Voter/AclVoterTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Voter/AclVoterTest.php @@ -213,7 +213,7 @@ public function testVoteGrantsAccess($grant) ->expects($this->once()) ->method('findAcl') ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) + ->will($this->returnValue($acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock())) ; $acl @@ -259,7 +259,7 @@ public function testVoteNoAceFound() ->expects($this->once()) ->method('findAcl') ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) + ->will($this->returnValue($acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock())) ; $acl @@ -302,7 +302,7 @@ public function testVoteGrantsFieldAccess($grant) ->expects($this->once()) ->method('findAcl') ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) + ->will($this->returnValue($acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock())) ; $acl @@ -348,7 +348,7 @@ public function testVoteNoFieldAceFound() ->expects($this->once()) ->method('findAcl') ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) + ->will($this->returnValue($acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock())) ; $acl @@ -389,7 +389,7 @@ public function testWhenReceivingAnObjectIdentityInterfaceWeDontRetrieveANewObje ->expects($this->once()) ->method('findAcl') ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) + ->will($this->returnValue($acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock())) ; $acl @@ -404,15 +404,15 @@ public function testWhenReceivingAnObjectIdentityInterfaceWeDontRetrieveANewObje 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 getVoter($allowIfObjectIdentityUnavailable = true, $alwaysContains = true) { - $provider = $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface'); - $permissionMap = $this->getMock('Symfony\Component\Security\Acl\Permission\PermissionMapInterface'); - $oidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface'); - $sidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface'); + $provider = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclProviderInterface')->getMock(); + $permissionMap = $this->getMockBuilder('Symfony\Component\Security\Acl\Permission\PermissionMapInterface')->getMock(); + $oidStrategy = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface')->getMock(); + $sidStrategy = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface')->getMock(); if ($alwaysContains) { $permissionMap 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 5a189b0ec6450..43eb62f3252a9 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($key) { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', array('getKey'), array(), '', false); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(array('getKey'))->disableOriginalConstructor()->getMock(); $token->expects($this->any()) ->method('getKey') ->will($this->returnValue($key)) 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/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 a6fff4bfa9ba1..ea30d5e3c71ec 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 testAuthenticateWhenKeysDoNotMatch() */ 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, $key = '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', $key)); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('getProviderKey'))->setConstructorArgs(array($user, 'foo', $key))->getMock(); $token ->expects($this->once()) ->method('getProviderKey') @@ -99,7 +99,7 @@ protected function getSupportedToken($user = null, $key = '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 7449204533dbf..23b1a080f9608 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 testConstructorKeyCannotBeEmptyString() 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 7a9ab08123156..e1fe0e2d7d430 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php @@ -67,7 +67,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'))); @@ -85,7 +85,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), @@ -103,7 +103,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( @@ -168,7 +168,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)); @@ -178,7 +178,7 @@ protected function getVoter($vote) protected function getVoterSupportsClass($ret) { - $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('supportsClass') ->will($this->returnValue($ret)); @@ -188,7 +188,7 @@ protected function getVoterSupportsClass($ret) protected function getVoterSupportsAttribute($ret) { - $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('supportsAttribute') ->will($this->returnValue($ret)); 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/Voter/AbstractVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php index c122587158a72..8d673bc0b293a 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php @@ -23,7 +23,7 @@ class AbstractVoterTest 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(); } /** 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 4679c0ff0e5ea..a59848c79bb20 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php @@ -68,11 +68,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 dc8ea7960e960..07700396bf358 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php @@ -20,7 +20,7 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase public function testSupportsAttribute() { $expression = $this->createExpression(); - $expressionLanguage = $this->getMock('Symfony\Component\Security\Core\Authorization\ExpressionLanguage'); + $expressionLanguage = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\ExpressionLanguage')->getMock(); $voter = new ExpressionVoter($expressionLanguage, $this->createTrustResolver(), $this->createRoleHierarchy()); $this->assertTrue($voter->supportsAttribute($expression)); @@ -54,7 +54,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()) @@ -67,7 +67,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()) @@ -80,12 +80,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 c15e936f6e58c..ce4f4cf4fbcd3 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php @@ -57,7 +57,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/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/LegacySecurityContextTest.php b/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php index fbb847eed596f..f86fcad1c4508 100644 --- a/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php +++ b/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php @@ -24,14 +24,14 @@ class LegacySecurityContextTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $this->authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); + $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $this->authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); $this->securityContext = new SecurityContext($this->tokenStorage, $this->authorizationChecker); } public function testGetTokenDelegation() { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $this->tokenStorage ->expects($this->once()) @@ -43,7 +43,7 @@ public function testGetTokenDelegation() public function testSetTokenDelegation() { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $this->tokenStorage ->expects($this->once()) @@ -83,8 +83,8 @@ public function isGrantedDelegationProvider() */ public function testOldConstructorSignature() { - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); - $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); new SecurityContext($authenticationManager, $accessDecisionManager); } @@ -99,10 +99,10 @@ public function testOldConstructorSignatureFailures($first, $second) public function oldConstructorSignatureFailuresProvider() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); - $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); return array( array(new \stdClass(), new \stdClass()), 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/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/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/Csrf/Tests/TokenGenerator/UriSafeTokenGeneratorTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenGenerator/UriSafeTokenGeneratorTest.php index 1b325e5d1e8c0..afbaa7c9f864f 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/TokenGenerator/UriSafeTokenGeneratorTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/TokenGenerator/UriSafeTokenGeneratorTest.php @@ -44,7 +44,7 @@ public static function setUpBeforeClass() protected function setUp() { - $this->random = $this->getMock('Symfony\Component\Security\Core\Util\SecureRandomInterface'); + $this->random = $this->getMockBuilder('Symfony\Component\Security\Core\Util\SecureRandomInterface')->getMock(); $this->generator = new UriSafeTokenGenerator($this->random, self::ENTROPY); } 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 252b1240316af..da30aa9a683c4 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php @@ -32,14 +32,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() @@ -173,8 +173,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 ae9f02bad8c22..7166c53ffd63c 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() @@ -87,7 +87,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 181e340e60a31..a3e035268a9d8 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', 'TheKey'); $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 3450c1ea439b9..c5761ac1e66c3 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, 'TheKey', 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('TheKey', '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, 'TheKey', 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, 'TheKey', $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 ae1199ac3cbc6..5453b317de436 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -32,7 +32,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(), '' ); @@ -45,7 +45,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' ); @@ -94,7 +94,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() @@ -113,7 +113,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() @@ -130,12 +130,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') @@ -169,8 +169,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(); @@ -182,7 +182,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') @@ -193,15 +193,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)); @@ -222,7 +222,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') @@ -230,7 +230,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'); @@ -253,7 +253,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/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index 3d409e54579f3..b372447d8b9bb 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -84,12 +84,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'); @@ -106,7 +106,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); @@ -123,8 +123,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); @@ -146,7 +146,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; @@ -154,7 +154,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; @@ -163,7 +163,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); @@ -172,9 +172,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 15c996e6261a5..0cc470606b8ab 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 0a1286cd172ae..6061b12a8cffd 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\Core\Authentication\SimplePreAuthenticatorInterface'); + $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Core\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\Core\Authentication\SimplePreAuthenticatorInterface'); + $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Core\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 ddfaaebe38df6..259214c6df75e 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 f43963e7e77cc..d7b55da8b23a8 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -61,7 +61,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') @@ -80,7 +80,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') @@ -105,7 +105,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 @@ -136,7 +136,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') @@ -151,7 +151,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') @@ -170,7 +170,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') @@ -193,9 +193,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') @@ -219,9 +219,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') @@ -242,9 +242,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') @@ -272,20 +272,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') @@ -327,7 +327,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 e3b58e97a1fad..558825797dacb 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 4aef4b203b6a8..c23821a4ce5f0 100644 --- a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php @@ -43,7 +43,7 @@ public function testSessionIsMigrated() $this->markTestSkipped('We cannot destroy the old session on PHP 5.4.0 - 5.4.10.'); } - $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); @@ -56,7 +56,7 @@ public function testSessionIsMigratedWithPhp54Workaround() $this->markTestSkipped('This PHP version is not affected.'); } - $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(false)); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE); @@ -65,7 +65,7 @@ public function testSessionIsMigratedWithPhp54Workaround() 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); @@ -74,7 +74,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)); @@ -85,6 +85,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/Tests/Http/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index b7c6ab9db5752..3e65b09b7db49 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\SecurityContextInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContextInterface')->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/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/ClassMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php index 2e2ba22dcee0b..331aa3a25e1f4 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php @@ -47,7 +47,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') @@ -60,7 +60,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)) 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/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 9b0f0df1bdaf2..f449bf430ee9e 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -36,7 +36,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); } @@ -470,7 +470,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/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index e3780e55c0bf4..99141b52cdd4c 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -39,7 +39,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); } @@ -404,7 +404,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(); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php index a2d1a063d31b2..a0402c5a348ee 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php @@ -35,7 +35,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); } @@ -423,7 +423,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 4b82ad9143511..05df5bc322f47 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -38,7 +38,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'); } @@ -70,7 +70,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'); } @@ -95,14 +95,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'); @@ -118,14 +118,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'); 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/Helper/LegacyCoreAssetsHelperTest.php b/src/Symfony/Component/Templating/Tests/Helper/LegacyCoreAssetsHelperTest.php index 890a94220860c..b6d7ce99289e5 100644 --- a/src/Symfony/Component/Templating/Tests/Helper/LegacyCoreAssetsHelperTest.php +++ b/src/Symfony/Component/Templating/Tests/Helper/LegacyCoreAssetsHelperTest.php @@ -22,7 +22,7 @@ class LegacyCoreAssetsHelperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->package = $this->getMock('Symfony\Component\Templating\Asset\PackageInterface'); + $this->package = $this->getMockBuilder('Symfony\Component\Templating\Asset\PackageInterface')->getMock(); } protected function tearDown() 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 87e78508e5706..b79dd618f929c 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'); } @@ -30,7 +30,7 @@ public function testGetSetLogger() public function testLegacyGetSetDebugger() { $loader = new ProjectTemplateLoader4(); - $debugger = $this->getMock('Symfony\Component\Templating\DebuggerInterface'); + $debugger = $this->getMockBuilder('Symfony\Component\Templating\DebuggerInterface')->getMock(); $loader->setDebugger($debugger); $this->assertSame($debugger, $loader->getDebugger(), '->setDebugger() sets the debugger instance'); } 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 abe364c7368c7..fa3451b2cac19 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\ResourceInterface'); - $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); + $resource = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->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/Tests/Constraints/AbstractConstraintValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php index 230d90bd578c1..3a6fa5f6786ba 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php @@ -94,9 +94,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(); switch ($this->getApiVersion()) { case Validation::API_VERSION_2_5: @@ -111,7 +111,7 @@ protected function createContext() $context = new LegacyExecutionContext( $validator, $this->root, - $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'), + $this->getMockBuilder('Symfony\Component\Validator\MetadataFactoryInterface')->getMock(), $translator ); break; diff --git a/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php b/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php index f0139c0da5ffc..ebf9696a3588c 100644 --- a/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php +++ b/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php @@ -45,9 +45,9 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); $this->violations = new ConstraintViolationList(); - $this->metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface'); - $this->metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); - $this->globalContext = $this->getMock('Symfony\Component\Validator\GlobalExecutionContextInterface'); + $this->metadata = $this->getMockBuilder('Symfony\Component\Validator\MetadataInterface')->getMock(); + $this->metadataFactory = $this->getMockBuilder('Symfony\Component\Validator\MetadataFactoryInterface')->getMock(); + $this->globalContext = $this->getMockBuilder('Symfony\Component\Validator\GlobalExecutionContextInterface')->getMock(); $this->globalContext->expects($this->any()) ->method('getRoot') ->will($this->returnValue('Root')); @@ -60,7 +60,7 @@ protected function setUp() $this->globalContext->expects($this->any()) ->method('getMetadataFactory') ->will($this->returnValue($this->metadataFactory)); - $this->translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); + $this->translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); $this->context = new ExecutionContext($this->globalContext, $this->translator, self::TRANS_DOMAIN, $this->metadata, 'currentValue', 'Group', 'foo.bar'); } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php index c1aaa9f8c7bf2..1de7455186239 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php @@ -76,7 +76,7 @@ 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( @@ -115,8 +115,8 @@ 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); 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/Validator/Abstract2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php index 1e6f3403e7284..5e97d523bf759 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php @@ -550,7 +550,7 @@ public function testMetadataMustImplementClassMetadataInterface() { $entity = new Entity(); - $metadata = $this->getMock('Symfony\Component\Validator\Tests\Fixtures\LegacyClassMetadata'); + $metadata = $this->getMockBuilder('Symfony\Component\Validator\Tests\Fixtures\LegacyClassMetadata')->getMock(); $metadata->expects($this->any()) ->method('getClassName') ->will($this->returnValue(get_class($entity))); @@ -569,7 +569,7 @@ public function testReferenceMetadataMustImplementClassMetadataInterface() $entity = new Entity(); $entity->reference = new Reference(); - $metadata = $this->getMock('Symfony\Component\Validator\Tests\Fixtures\LegacyClassMetadata'); + $metadata = $this->getMockBuilder('Symfony\Component\Validator\Tests\Fixtures\LegacyClassMetadata')->getMock(); $metadata->expects($this->any()) ->method('getClassName') ->will($this->returnValue(get_class($entity->reference))); @@ -590,7 +590,7 @@ public function testLegacyPropertyMetadataMustImplementPropertyMetadataInterface $entity = new Entity(); // Legacy interface - $propertyMetadata = $this->getMock('Symfony\Component\Validator\MetadataInterface'); + $propertyMetadata = $this->getMockBuilder('Symfony\Component\Validator\MetadataInterface')->getMock(); $metadata = new FakeClassMetadata(get_class($entity)); $metadata->addCustomPropertyMetadata('firstName', $propertyMetadata); @@ -672,8 +672,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/AbstractLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php index cbbaecfcddcad..47346324b88a3 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php @@ -267,8 +267,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/AbstractValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php index 7359348432b59..d5ff2954f818c 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php @@ -844,7 +844,7 @@ public function testValidateProperty() public function testLegacyValidatePropertyFailsIfPropertiesNotSupported() { // $metadata does not implement PropertyMetadataContainerInterface - $metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface'); + $metadata = $this->getMockBuilder('Symfony\Component\Validator\MetadataInterface')->getMock(); $this->metadataFactory->addMetadataForValue('VALUE', $metadata); @@ -975,7 +975,7 @@ public function testValidatePropertyValueWithClassName() public function testLegacyValidatePropertyValueFailsIfPropertiesNotSupported() { // $metadata does not implement PropertyMetadataContainerInterface - $metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface'); + $metadata = $this->getMockBuilder('Symfony\Component\Validator\MetadataInterface')->getMock(); $this->metadataFactory->addMetadataForValue('VALUE', $metadata); diff --git a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php index b27e6454bea7a..1313fb9e31a7b 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php @@ -35,7 +35,7 @@ public function testEmptyGroupsArrayDoesNotTriggerDeprecation() { $entity = new Entity(); - $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()) ); } From 0f9a7287c3d3f56bc23b1eb93b110ab9adedf39e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 19 Dec 2016 16:48:05 +0100 Subject: [PATCH 035/106] fixed obsolete getMock() usage --- .../Security/User/EntityUserProviderTest.php | 6 +- .../Tests/Controller/ControllerTest.php | 68 +++++++++---------- .../Compiler/ConfigCachePassTest.php | 14 ++-- .../Compiler/PropertyInfoPassTest.php | 4 +- .../Compiler/UnusedTagsPassTest.php | 8 +-- .../TwigBundle/Tests/TemplateIteratorTest.php | 2 +- .../Tests/Command/ExportCommandTest.php | 4 +- .../Tests/Command/ImportCommandTest.php | 2 +- .../Tests/ResourceCheckerConfigCacheTest.php | 8 +-- .../Debug/Tests/ErrorHandlerTest.php | 2 +- .../Debug/TraceableEventDispatcherTest.php | 2 +- .../Core/EventListener/TrimListenerTest.php | 4 +- .../DependencyInjectionExtensionTest.php | 12 ++-- .../Constraints/FormValidatorTest.php | 4 +- .../EventListener/ValidationListenerTest.php | 14 ++-- .../Extension/Validator/Type/TypeTestCase.php | 2 +- .../Validator/ValidatorExtensionTest.php | 4 +- .../Validator/ValidatorTypeGuesserTest.php | 2 +- .../Form/Tests/FormFactoryBuilderTest.php | 2 +- .../Component/Form/Tests/FormRegistryTest.php | 8 +-- .../Form/Tests/ResolvedFormTypeTest.php | 34 +++++----- .../Tests/ProcessFailedExceptionTest.php | 18 +---- .../Tests/RouteCollectionBuilderTest.php | 10 +-- .../AnonymousAuthenticationProviderTest.php | 6 +- .../LdapBindAuthenticationProviderTest.php | 18 ++--- .../RememberMeAuthenticationProviderTest.php | 14 ++-- .../Tests/Authorization/Voter/VoterTest.php | 2 +- .../Core/Tests/User/LdapUserProviderTest.php | 8 +-- .../GuardAuthenticationListenerTest.php | 22 +++--- .../Tests/GuardAuthenticatorHandlerTest.php | 8 +-- .../GuardAuthenticationProviderTest.php | 20 +++--- .../AnonymousAuthenticationListenerTest.php | 22 +++--- .../DigestAuthenticationListenerTest.php | 8 +-- .../SimplePreAuthenticationListenerTest.php | 14 ++-- .../Normalizer/ArrayDenormalizerTest.php | 2 +- .../Translation/Tests/TranslatorCacheTest.php | 8 +-- .../Constraints/ExpressionValidatorTest.php | 2 +- 37 files changed, 184 insertions(+), 204 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 959992f5a0caf..038185b536cd2 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -180,12 +180,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( @@ -201,7 +201,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)), diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php index e3f81fe8ea511..8c9fcd507eb30 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php @@ -33,12 +33,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)); @@ -84,7 +84,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') @@ -104,13 +104,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') @@ -128,10 +128,10 @@ private function getContainerWithTokenStorage($token = null) 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)); @@ -146,10 +146,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)); @@ -164,7 +164,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)); @@ -180,7 +180,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)); @@ -195,7 +195,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)); @@ -208,10 +208,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(); @@ -226,10 +226,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)); @@ -249,10 +249,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)); @@ -264,10 +264,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 Controller(); @@ -288,10 +288,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)); @@ -303,10 +303,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)); @@ -318,9 +318,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)); @@ -339,12 +339,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 Controller(); @@ -355,12 +355,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 Controller(); @@ -371,9 +371,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/DependencyInjection/Compiler/ConfigCachePassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php index c0eef3d627ce7..cf13e7e56a5c2 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->getMock('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->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock(); $container->expects($this->atLeastOnce()) ->method('findTaggedServiceIds') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php index 74f0b607bda3e..c8e252c8fb609 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()) ->method('findTaggedServiceIds') @@ -51,7 +51,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()) ->method('findTaggedServiceIds') 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/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/WebProfilerBundle/Tests/Command/ExportCommandTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php index 17817ae7c2865..ab36cf75d19a8 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php @@ -33,7 +33,7 @@ public function testExecuteWithUnknownToken() ; $helperSet = new HelperSet(); - $helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper'); + $helper = $this->getMockBuilder('Symfony\Component\Console\Helper\FormatterHelper')->getMock(); $helper->expects($this->any())->method('formatSection'); $helperSet->set($helper, 'formatter'); @@ -56,7 +56,7 @@ public function testExecuteWithToken() $profiler->expects($this->once())->method('loadProfile')->with('TOKEN')->will($this->returnValue($profile)); $helperSet = new HelperSet(); - $helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper'); + $helper = $this->getMockBuilder('Symfony\Component\Console\Helper\FormatterHelper')->getMock(); $helper->expects($this->any())->method('formatSection'); $helperSet->set($helper, 'formatter'); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php index 2c440ecc75a0d..0b3fd0b546057 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php @@ -32,7 +32,7 @@ public function testExecute() $profiler->expects($this->once())->method('import')->will($this->returnValue(new Profile('TOKEN'))); $helperSet = new HelperSet(); - $helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper'); + $helper = $this->getMockBuilder('Symfony\Component\Console\Helper\FormatterHelper')->getMock(); $helper->expects($this->any())->method('formatSection'); $helperSet->set($helper, 'formatter'); 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/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 18ac7ad9e74e5..61f1206b9fabe 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -435,7 +435,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]); diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php index 5c458766621b0..46eece72fffb0 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php @@ -75,7 +75,7 @@ public function testGetListenerPriority() public function testGetListenerPriorityReturnsZeroWhenWrappedMethodDoesNotExist() { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $traceableEventDispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); $traceableEventDispatcher->addListener('foo', function () {}, 123); $listeners = $traceableEventDispatcher->getListeners('foo'); 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/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 dc5ff0511e781..59231e9fbc0fb 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -109,7 +109,7 @@ public function testValidateConstraints() public function testValidateIfParentWithCascadeValidation() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent', null, array('cascade_validation' => true)) ->setCompound(true) @@ -131,7 +131,7 @@ public function testValidateIfParentWithCascadeValidation() public function testValidateIfChildWithValidConstraint() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent') ->setCompound(true) 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 788b8a082b50e..a851cd82ff692 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 @@ -183,7 +183,7 @@ public function testValidateWithEmptyViolationList() public function testValidatorInterfaceSinceSymfony25() { // Mock of ValidatorInterface since apiVersion 2.5 - $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); @@ -195,7 +195,7 @@ public function testValidatorInterfaceSinceSymfony25() public function testValidatorInterfaceUntilSymfony24() { // Mock of ValidatorInterface until apiVersion 2.4 - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); + $validator = $this->getMockBuilder('Symfony\Component\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/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/ValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php index 9aa60533760d4..4ad0189f61dd6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php @@ -56,8 +56,8 @@ public function test2Dot5ValidationApi() */ public function test2Dot4ValidationApi() { - $factory = $this->getMock('Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface'); - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); + $factory = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface')->getMock(); + $validator = $this->getMockBuilder('Symfony\Component\Validator\ValidatorInterface')->getMock(); $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata') ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php index 220e6898bde09..a98b066934f1e 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/FormFactoryBuilderTest.php b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php index 20a1c0052c0ee..af4220d824781 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 LegacyFooType(); } diff --git a/src/Symfony/Component/Form/Tests/FormRegistryTest.php b/src/Symfony/Component/Form/Tests/FormRegistryTest.php index 3649bc4fb90a6..952cd046ff167 100644 --- a/src/Symfony/Component/Form/Tests/FormRegistryTest.php +++ b/src/Symfony/Component/Form/Tests/FormRegistryTest.php @@ -63,9 +63,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( @@ -305,7 +305,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 36804ebebe8bc..a6ca4e3536e5d 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(); @@ -127,7 +127,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\OptionsResolverInterface'); + $optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolverInterface')->getMock(); $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) @@ -155,7 +155,7 @@ public function testCreateBuilderWithDataClassOption() { $givenOptions = array('data_class' => 'Foo'); $resolvedOptions = array('data_class' => '\stdClass'); - $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface'); + $optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolverInterface')->getMock(); $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) @@ -194,7 +194,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()) @@ -224,7 +224,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); @@ -234,8 +234,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); @@ -246,8 +246,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(); $test = $this; $i = 0; @@ -290,8 +290,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(); $test = $this; $i = 0; @@ -393,7 +393,7 @@ public function testGetBlockPrefix() public function testBlockPrefixDefaultsToNameIfSet() { // Type without getBlockPrefix() method - $type = $this->getMock('Symfony\Component\Form\FormTypeInterface'); + $type = $this->getMockBuilder('Symfony\Component\Form\FormTypeInterface')->getMock(); $type->expects($this->once()) ->method('getName') @@ -431,7 +431,7 @@ public function provideTypeClassBlockPrefixTuples() */ private function getMockFormType($typeClass = 'Symfony\Component\Form\AbstractType') { - return $this->getMock($typeClass, array('getName', 'getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm')); + return $this->getMockBuilder($typeClass)->setMethods(array('getName', 'getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm'))->getMock(); } /** @@ -439,7 +439,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(); } /** @@ -447,7 +447,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/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index 963bbb30105d6..b5c9a6d48e6d3 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)); $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/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/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/LdapBindAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php index fbb4d733a93c4..aae3c764af103 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php @@ -27,9 +27,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'); @@ -44,14 +44,14 @@ public function testEmptyPasswordShouldThrowAnException() */ public function testBindFailureShouldThrowAnException() { - $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); $ldap ->expects($this->once()) ->method('bind') ->will($this->throwException(new ConnectionException())) ; - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); $reflection = new \ReflectionMethod($provider, 'checkAuthentication'); @@ -62,15 +62,15 @@ public function testBindFailureShouldThrowAnException() public function testRetrieveUser() { - $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') ->with('foo') ; - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); $reflection = new \ReflectionMethod($provider, 'retrieveUser'); 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/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/User/LdapUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php index 9b126e95180f3..a8fc2618eab7d 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php @@ -24,7 +24,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase */ public function testLoadUserByUsernameFailsIfCantConnectToLdap() { - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); $ldap ->expects($this->once()) ->method('bind') @@ -40,7 +40,7 @@ public function testLoadUserByUsernameFailsIfCantConnectToLdap() */ public function testLoadUserByUsernameFailsIfNoLdapEntries() { - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); $ldap ->expects($this->once()) ->method('escape') @@ -56,7 +56,7 @@ public function testLoadUserByUsernameFailsIfNoLdapEntries() */ public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry() { - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); $ldap ->expects($this->once()) ->method('escape') @@ -78,7 +78,7 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry() public function testSuccessfulLoadUserByUsername() { - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); $ldap ->expects($this->once()) ->method('escape') 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/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/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/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/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/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/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index 61510abc37e56..420fb705762f0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -224,7 +224,7 @@ public function testExpressionLanguageUsage() 'expression' => 'false', )); - $expressionLanguage = $this->getMock('Symfony\Component\ExpressionLanguage\ExpressionLanguage'); + $expressionLanguage = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ExpressionLanguage')->getMock(); $used = false; From a3058245db65f750d311229a2de6e1530dcdb105 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 19 Dec 2016 17:00:11 +0100 Subject: [PATCH 036/106] fixed obsolete getMock() usage --- .../ChoiceList/DoctrineChoiceLoaderTest.php | 2 +- .../MergeDoctrineCollectionListenerTest.php | 2 +- .../Tests/Controller/ControllerTest.php | 10 +-- .../Compiler/ConfigCachePassTest.php | 4 +- .../Tests/Templating/GlobalVariablesTest.php | 10 +-- .../Console/Tests/ApplicationTest.php | 16 ++--- .../Debug/Tests/ErrorHandlerTest.php | 18 ++--- .../ContainerAwareEventDispatcherTest.php | 14 ++-- .../Debug/TraceableEventDispatcherTest.php | 4 +- .../Factory/DefaultChoiceListFactoryTest.php | 4 +- .../Factory/PropertyAccessDecoratorTest.php | 12 ++-- .../Tests/ChoiceList/LazyChoiceListTest.php | 4 +- .../Constraints/FormValidatorTest.php | 65 +++++++++---------- .../EventListener/ValidationListenerTest.php | 12 ++-- .../Type/FormTypeValidatorExtensionTest.php | 2 +- .../Form/Tests/FormFactoryBuilderTest.php | 2 +- .../Form/Tests/ResolvedFormTypeTest.php | 32 ++++----- .../Tests/Controller/ArgumentResolverTest.php | 2 +- .../RequestDataCollectorTest.php | 6 +- .../Debug/TraceableEventDispatcherTest.php | 4 +- .../FragmentRendererPassTest.php | 16 ++--- .../EventListener/ProfilerListenerTest.php | 2 +- .../Fragment/InlineFragmentRendererTest.php | 16 ++--- .../HttpKernel/Tests/HttpKernelTest.php | 6 +- .../Component/Ldap/Tests/LdapClientTest.php | 6 +- src/Symfony/Component/Ldap/Tests/LdapTest.php | 4 +- .../LdapBindAuthenticationProviderTest.php | 18 ++--- .../AccessDecisionManagerTest.php | 8 +-- .../DebugAccessDecisionManagerTest.php | 2 +- .../Voter/ExpressionVoterTest.php | 8 +-- .../Core/Tests/User/LdapUserProviderTest.php | 38 +++++------ .../Tests/Firewall/ExceptionListenerTest.php | 2 +- .../SessionAuthenticationStrategyTest.php | 8 +-- ...PasswordFormAuthenticationListenerTest.php | 14 ++-- .../Factory/CacheMetadataFactoryTest.php | 6 +- .../Factory/ClassMetadataFactoryTest.php | 4 +- .../JsonSerializableNormalizerTest.php | 2 +- .../Serializer/Tests/SerializerTest.php | 4 +- .../Templating/Tests/Loader/LoaderTest.php | 2 +- .../AbstractConstraintValidatorTest.php | 6 +- .../Tests/Validator/AbstractTest.php | 4 +- .../Validator/RecursiveValidatorTest.php | 2 +- 42 files changed, 197 insertions(+), 206 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php index daea5a0b63e52..f20340b04e883 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php @@ -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/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/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php index 09e7e19aa9f9e..f74117951b024 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php @@ -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') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php index cf13e7e56a5c2..4ca86c33761a3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php @@ -25,7 +25,7 @@ public function testThatCheckersAreProcessedInPriorityOrder() ); $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock(); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock()->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock(); $container->expects($this->atLeastOnce()) ->method('findTaggedServiceIds') @@ -50,7 +50,7 @@ public function testThatCheckersAreProcessedInPriorityOrder() public function testThatCheckersCanBeMissing() { $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock(); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock()->setMethods(array('findTaggedServiceIds'))->getMock(); $container->expects($this->atLeastOnce()) ->method('findTaggedServiceIds') 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/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/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/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/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 86c256bd10ebe..30111a24082da 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') 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/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index abc6597bc1d82..0ab38fd317381 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -45,12 +45,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,7 +59,7 @@ 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) @@ -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')); @@ -105,7 +102,7 @@ public function testValidateConstraints() public function testValidateChildIfValidConstraint() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent') ->setCompound(true) @@ -129,7 +126,7 @@ public function testValidateChildIfValidConstraint() public function testDontValidateIfParentWithoutValidConstraint() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent', null) ->setCompound(true) @@ -163,7 +160,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 +187,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 +206,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 +230,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 +264,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 +299,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 +334,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; }, @@ -367,7 +364,7 @@ function () { throw new TransformationFailedException(); } 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) @@ -383,7 +380,7 @@ 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) @@ -398,7 +395,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'); }); @@ -416,7 +413,7 @@ public function testHandleClosureValidationGroups() public function testUseValidationGroupOfClickedButton() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent') ->setCompound(true) @@ -443,7 +440,7 @@ public function testUseValidationGroupOfClickedButton() public function testDontUseValidationGroupOfUnclickedButton() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent') ->setCompound(true) @@ -470,7 +467,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 +489,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 +511,7 @@ public function testUseInheritedCallbackValidationGroup() public function testUseInheritedClosureValidationGroup() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parentOptions = array( 'validation_groups' => function (FormInterface $form) { @@ -540,7 +537,7 @@ public function testUseInheritedClosureValidationGroup() public function testAppendPropertyPath() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $form = $this->getBuilder('name', '\stdClass') ->setData($object) ->getForm(); @@ -618,9 +615,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 +665,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/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/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/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/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/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index df5d974fd8c30..26350620ba7f6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -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/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/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/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/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/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/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/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/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/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/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/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index ffa7cd8ff3098..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); 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/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/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/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/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index 48d356f7cef69..1a9a6b4b5496c 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -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/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/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/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 0d3778e71a340..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') From ab520a13c61e64880dd9e1e8405a57fa2a3b6ed1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 19 Dec 2016 17:17:38 +0100 Subject: [PATCH 037/106] fixed tests --- .../DependencyInjection/Compiler/ConfigCachePassTest.php | 4 ++-- .../Component/Process/Tests/ProcessFailedExceptionTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php index cf13e7e56a5c2..7f465b253401a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php @@ -25,7 +25,7 @@ public function testThatCheckersAreProcessedInPriorityOrder() ); $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock(); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock(); $container->expects($this->atLeastOnce()) ->method('findTaggedServiceIds') @@ -50,7 +50,7 @@ public function testThatCheckersAreProcessedInPriorityOrder() public function testThatCheckersCanBeMissing() { $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock(); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock(); $container->expects($this->atLeastOnce()) ->method('findTaggedServiceIds') diff --git a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index b5c9a6d48e6d3..e9720c7572404 100644 --- a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -49,7 +49,7 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( $errorOutput = 'FATAL: Unexpected error'; $workingDirectory = getcwd(); - $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'))->setConstructorArgs(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)); From 98c835d9be88e810b74cdae17b83a126798023a1 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 19 Dec 2016 19:45:07 +0100 Subject: [PATCH 038/106] [TwigBundle][#20799] fix merge --- .../TwigBundle/Resources/config/form.xml | 6 ++--- .../Resources/config/templating.xml | 4 +-- .../TwigBundle/Resources/config/twig.xml | 25 ------------------- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml index 0703f0f57774a..864e6b8b5810f 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/form.xml @@ -4,15 +4,15 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - + - + %twig.form.resources% - + diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml index 5a39c95018c0b..89c1048eb2bfd 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - + @@ -12,7 +12,7 @@ - + diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index 55182c083abd5..1f244f9f44f53 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -45,22 +45,10 @@ - - - - - - - - - - - - @@ -115,21 +103,8 @@ - - - - - - %twig.form.resources% - - - - - - - From 6fddb75ef54bb218119f03121b217a721cdddf89 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 19 Dec 2016 21:36:15 +0100 Subject: [PATCH 039/106] Fix merge --- src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index 1f244f9f44f53..2143747ad9456 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -47,8 +47,6 @@ - - From c245f87a47353fcfe63dabd5639f275d4adb3278 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Tue, 20 Dec 2016 17:35:30 +0000 Subject: [PATCH 040/106] [HttpKernel] Continuation of #20599 for 3.1 --- .../DataCollector/RequestDataCollector.php | 61 +++++-------------- .../RequestDataCollectorTest.php | 4 +- 2 files changed, 17 insertions(+), 48 deletions(-) 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/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index 26350620ba7f6..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()); From 1255786811bac557713e0504b60eac3fe68c7b94 Mon Sep 17 00:00:00 2001 From: Tarjei Huse Date: Thu, 22 Dec 2016 10:25:47 +0100 Subject: [PATCH 041/106] Improve language I suspect the file has been updated from the Danish translation and thus some of the sentences sound weird in Norwegian. Here's a suggested update. --- .../Resources/translations/validators.no.xlf | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) 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. From d559e26e0b54fbbb82ff4c213a5272d66df4a81c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 23 Dec 2016 08:00:05 +0100 Subject: [PATCH 042/106] removed some PHP CS Fixer rules --- .php_cs.dist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.php_cs.dist b/.php_cs.dist index baee1a5ec0d0f..86ff5eab4d2e2 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -5,6 +5,8 @@ return PhpCsFixer\Config::create() '@Symfony' => true, '@Symfony:risky' => true, 'array_syntax' => array('syntax' => 'long'), + 'no_unreachable_default_argument_value' => false, + 'heredoc_to_nowdoc' => false, )) ->setRiskyAllowed(true) ->setFinder( From 08e5747ce1882685a08a118132f5edf699d75454 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 23 Dec 2016 12:20:51 +0100 Subject: [PATCH 043/106] [TwigBridge] fix Twig 2.x compatibility --- src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index 3a444e8a1f77d..b1980b8a37722 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -53,7 +53,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) { From 4dc4f694ca7baa2448de7ab68b9ecfb8edca53b5 Mon Sep 17 00:00:00 2001 From: Arthur de Moulins Date: Thu, 22 Dec 2016 14:40:27 +0100 Subject: [PATCH 044/106] remove is_writable check on filesystem cache --- src/Symfony/Component/Cache/Adapter/AbstractAdapter.php | 3 +++ .../Component/Cache/Adapter/FilesystemAdapter.php | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 1b53e3390cb29..a8a2d00f6f36c 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -16,6 +16,7 @@ use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerInterface; use Symfony\Component\Cache\CacheItem; +use Symfony\Component\Cache\Exception\CacheException; /** * @author Nicolas Grekas @@ -129,6 +130,8 @@ abstract protected function doDelete(array $ids); * @param int $lifetime The lifetime of the cached values, 0 for persisting until manual cleaning * * @return array|bool The identifiers that failed to be cached or a boolean stating if caching succeeded or not + * + * @throws CacheException If write can not be performed */ abstract protected function doSave(array $values, $lifetime); 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; } From a70b389c3838999be13b14baf55039acf79ecf2c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 23 Dec 2016 15:24:19 +0100 Subject: [PATCH 045/106] use HHVM 3.15 to run tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 70e364f8f960d..3e48a5600600a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,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 From 89ccbc450ce577a138520f73acfd2e2b6bd4aa23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 23 Dec 2016 16:05:48 +0100 Subject: [PATCH 046/106] [FrameworkBundle] Make TemplateController working without the Templating component --- .../Controller/TemplateController.php | 10 ++- .../Controller/TemplateControllerTest.php | 69 +++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php index 16d15f902340c..346b82b0ae14c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -33,8 +33,14 @@ class TemplateController extends ContainerAware */ public function templateAction($template, $maxAge = null, $sharedAge = null, $private = null) { - /** @var $response \Symfony\Component\HttpFoundation\Response */ - $response = $this->container->get('templating')->renderResponse($template); + /* @var $response \Symfony\Component\HttpFoundation\Response */ + 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/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(); + } +} From d39311385f821659e9e7592598237a5f8835a0f0 Mon Sep 17 00:00:00 2001 From: ShinDarth Date: Wed, 7 Dec 2016 15:51:03 +0100 Subject: [PATCH 047/106] [Console] improved code coverage of Command class --- .../Console/Tests/Command/CommandTest.php | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 695759cb9d57c..2558f01cb9683 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(); @@ -275,8 +299,8 @@ public function testRunReturnsIntegerExitCode() $command = $this->getMock('TestCommand', array('execute')); $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,17 @@ 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')) { + $this->assertEquals('foo', cli_get_process_title()); + } + } + public function testSetCode() { $command = new \TestCommand(); From e5ce4c9383b9ef15cd75ef05e40afdda5c684b83 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 23 Dec 2016 22:13:36 +0100 Subject: [PATCH 048/106] removed unneeded comment --- .../Bundle/FrameworkBundle/Controller/TemplateController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php index 346b82b0ae14c..76167c245ea9f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -33,7 +33,6 @@ class TemplateController extends ContainerAware */ public function templateAction($template, $maxAge = null, $sharedAge = null, $private = null) { - /* @var $response \Symfony\Component\HttpFoundation\Response */ if ($this->container->has('templating')) { $response = $this->container->get('templating')->renderResponse($template); } elseif ($this->container->has('twig')) { From 8b281fe40120d9467bb1040909221daafa1a97f9 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 25 Dec 2016 18:58:48 +0100 Subject: [PATCH 049/106] override property constraints in child class --- .../Validator/Mapping/ClassMetadata.php | 4 +++ .../Tests/Mapping/ClassMetadataTest.php | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 5df8517a479ad..b18b788678e50 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -346,6 +346,10 @@ public function mergeConstraints(ClassMetadata $source) } foreach ($source->getConstrainedProperties() as $property) { + if ($this->hasPropertyMetadata($property)) { + continue; + } + foreach ($source->getPropertyMetadata($property) as $member) { $member = clone $member; diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php index 34c62445a428b..9538977167546 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; @@ -295,4 +296,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 } From 3c0693de23ea30c1a54ff7179ebf3168e1328793 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 26 Dec 2016 08:50:27 +0100 Subject: [PATCH 050/106] fixed @return when returning this or static --- src/Symfony/Bridge/Twig/NodeVisitor/Scope.php | 6 +- src/Symfony/Component/BrowserKit/Cookie.php | 2 +- .../Builder/ArrayNodeDefinition.php | 26 ++++---- .../Definition/Builder/EnumNodeDefinition.php | 2 +- .../Config/Definition/Builder/ExprBuilder.php | 22 +++---- .../Definition/Builder/MergeBuilder.php | 4 +- .../Config/Definition/Builder/NodeBuilder.php | 6 +- .../Definition/Builder/NodeDefinition.php | 28 ++++----- .../Builder/NormalizationBuilder.php | 4 +- .../Builder/NumericNodeDefinition.php | 4 +- .../Component/Config/Loader/Loader.php | 2 +- src/Symfony/Component/Console/Application.php | 2 +- .../Component/Console/Command/Command.php | 20 +++--- .../Console/Formatter/OutputFormatter.php | 2 +- .../Formatter/OutputFormatterStyleStack.php | 2 +- .../Console/Helper/DescriptorHelper.php | 2 +- .../Component/Console/Helper/Helper.php | 2 +- .../Component/Console/Helper/Table.php | 4 +- .../Component/Console/Helper/TableHelper.php | 20 +++--- .../Component/Console/Helper/TableStyle.php | 18 +++--- .../Console/Question/ChoiceQuestion.php | 6 +- .../Component/Console/Question/Question.php | 12 ++-- .../Exception/SyntaxErrorException.php | 10 +-- .../CssSelector/Node/Specificity.php | 2 +- .../CssSelector/Parser/TokenStream.php | 4 +- .../XPath/Extension/NodeExtension.php | 2 +- .../CssSelector/XPath/Translator.php | 4 +- .../Component/CssSelector/XPath/XPathExpr.php | 8 +-- .../Component/Debug/ExceptionHandler.php | 2 +- .../Compiler/ServiceReferenceGraph.php | 4 +- .../DependencyInjection/ContainerBuilder.php | 12 ++-- .../DependencyInjection/Definition.php | 48 +++++++------- .../DefinitionDecorator.php | 2 +- src/Symfony/Component/DomCrawler/Crawler.php | 30 ++++----- src/Symfony/Component/DomCrawler/Form.php | 4 +- .../DomCrawler/FormFieldRegistry.php | 2 +- .../Component/EventDispatcher/Event.php | 2 +- .../EventDispatcher/GenericEvent.php | 4 +- .../Component/ExpressionLanguage/Compiler.php | 8 +-- .../Finder/Adapter/AdapterInterface.php | 30 ++++----- .../Finder/Expression/Expression.php | 2 +- .../Component/Finder/Expression/Regex.php | 16 ++--- .../Finder/Expression/ValueInterface.php | 4 +- src/Symfony/Component/Finder/Finder.php | 62 +++++++++---------- .../Component/Finder/Shell/Command.php | 20 +++--- src/Symfony/Component/Form/Button.php | 2 +- src/Symfony/Component/Form/ButtonBuilder.php | 6 +- src/Symfony/Component/Form/FormBuilder.php | 2 +- .../Component/Form/FormBuilderInterface.php | 8 +-- .../Component/Form/FormConfigBuilder.php | 4 +- .../Form/FormFactoryBuilderInterface.php | 18 +++--- src/Symfony/Component/Form/FormInterface.php | 24 +++---- src/Symfony/Component/Form/FormView.php | 4 +- src/Symfony/Component/Form/Guess/Guess.php | 2 +- src/Symfony/Component/Form/SubmitButton.php | 2 +- .../Component/HttpFoundation/AcceptHeader.php | 6 +- .../HttpFoundation/AcceptHeaderItem.php | 10 +-- .../HttpFoundation/BinaryFileResponse.php | 8 +-- .../Component/HttpFoundation/File/File.php | 2 +- .../File/MimeType/ExtensionGuesser.php | 2 +- .../File/MimeType/MimeTypeGuesser.php | 2 +- .../Component/HttpFoundation/JsonResponse.php | 10 +-- .../HttpFoundation/RedirectResponse.php | 2 +- .../Component/HttpFoundation/Request.php | 6 +- .../Component/HttpFoundation/Response.php | 46 +++++++------- .../HttpFoundation/StreamedResponse.php | 2 +- .../Component/HttpKernel/Profiler/Profile.php | 10 +-- .../Component/Intl/Collator/Collator.php | 2 +- .../Intl/DateFormatter/IntlDateFormatter.php | 2 +- .../Intl/NumberFormatter/NumberFormatter.php | 2 +- .../Component/Intl/Util/SvnRepository.php | 2 +- .../OptionsResolver/OptionsResolver.php | 24 +++---- .../OptionsResolverInterface.php | 18 +++--- .../Component/Process/Pipes/UnixPipes.php | 2 +- .../Component/Process/Pipes/WindowsPipes.php | 2 +- src/Symfony/Component/Process/Process.php | 12 ++-- .../Component/Process/ProcessBuilder.php | 26 ++++---- .../PropertyAccess/PropertyAccess.php | 6 +- .../PropertyAccessorBuilder.php | 8 +-- .../Matcher/Dumper/DumperCollection.php | 2 +- .../Matcher/Dumper/DumperPrefixCollection.php | 2 +- .../Component/Routing/RequestContext.php | 22 +++---- src/Symfony/Component/Routing/Route.php | 30 ++++----- .../Security/Acl/Domain/ObjectIdentity.php | 2 +- .../Acl/Domain/UserSecurityIdentity.php | 4 +- .../Acl/Permission/MaskBuilderInterface.php | 8 +-- src/Symfony/Component/Stopwatch/Section.php | 4 +- src/Symfony/Component/Stopwatch/Stopwatch.php | 10 +-- .../Component/Stopwatch/StopwatchEvent.php | 6 +- .../Templating/TemplateReferenceInterface.php | 2 +- .../Translation/MessageCatalogueInterface.php | 6 +- .../Validator/Mapping/ClassMetadata.php | 10 +-- .../Validator/Mapping/GenericMetadata.php | 4 +- .../ContextualValidatorInterface.php | 8 +-- .../Validator/ValidatorBuilderInterface.php | 34 +++++----- .../ConstraintViolationBuilderInterface.php | 16 ++--- 96 files changed, 465 insertions(+), 467 deletions(-) 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/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/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index c78e492400183..03bb0cfdeeb3c 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -85,7 +85,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() { @@ -101,7 +101,7 @@ public function addDefaultsIfNotSet() * * This method is applicable to prototype nodes only. * - * @return ArrayNodeDefinition + * @return $this */ public function addDefaultChildrenIfNoneSet($children = null) { @@ -115,7 +115,7 @@ public function addDefaultChildrenIfNoneSet($children = null) * * This method is applicable to prototype nodes only. * - * @return ArrayNodeDefinition + * @return $this */ public function requiresAtLeastOneElement() { @@ -129,7 +129,7 @@ public function requiresAtLeastOneElement() * * If used all keys have to be defined in the same configuration file. * - * @return ArrayNodeDefinition + * @return $this */ public function disallowNewKeysInSubsequentConfigs() { @@ -144,7 +144,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) { @@ -179,7 +179,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) { @@ -194,7 +194,7 @@ public function useAttributeAsKey($name, $removeKeyItem = true) * * @param bool $allow * - * @return ArrayNodeDefinition + * @return $this */ public function canBeUnset($allow = true) { @@ -216,7 +216,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() { @@ -246,7 +246,7 @@ public function canBeEnabled() * * By default, the section is enabled. * - * @return ArrayNodeDefinition + * @return $this */ public function canBeDisabled() { @@ -266,7 +266,7 @@ public function canBeDisabled() /** * Disables the deep merging of the node. * - * @return ArrayNodeDefinition + * @return $this */ public function performNoDeepMerging() { @@ -284,7 +284,7 @@ public function performNoDeepMerging() * you want to send an entire configuration array through a special * tree that processes only part of the array. * - * @return ArrayNodeDefinition + * @return $this */ public function ignoreExtraKeys() { @@ -298,7 +298,7 @@ public function ignoreExtraKeys() * * @param bool $bool Whether to enable key normalization * - * @return ArrayNodeDefinition + * @return $this */ public function normalizeKeys($bool) { @@ -320,7 +320,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 dc25fcbd26f26..97f67094625c2 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..45878c02fb709 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 */ diff --git a/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php index f908a499cab20..14240f525124c 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) { 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..c8a3a248b4ef8 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) { @@ -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 ddd716d06a7b5..1dd0ce7d2eec1 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php @@ -26,7 +26,7 @@ abstract class NumericNodeDefinition extends ScalarNodeDefinition * * @param mixed $max * - * @return NumericNodeDefinition + * @return $this * * @throws \InvalidArgumentException when the constraint is inconsistent */ @@ -45,7 +45,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/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/Console/Application.php b/src/Symfony/Component/Console/Application.php index 74de1048bb172..a9351a589720c 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -772,7 +772,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) { diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 0948d42b5755d..9bcfdf79cacec 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -265,7 +265,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 * @@ -314,7 +314,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) { @@ -362,7 +362,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) { @@ -380,7 +380,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) { @@ -399,7 +399,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 */ @@ -422,7 +422,7 @@ public function setName($name) * * @param string $title The process title * - * @return Command The current instance + * @return $this */ public function setProcessTitle($title) { @@ -446,7 +446,7 @@ public function getName() * * @param string $description The description for the command * - * @return Command The current instance + * @return $this */ public function setDescription($description) { @@ -470,7 +470,7 @@ public function getDescription() * * @param string $help The help for the command * - * @return Command The current instance + * @return $this */ public function setHelp($help) { @@ -516,7 +516,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 */ @@ -568,7 +568,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/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index e0bbd0670554c..22c13d551e5a7 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -206,7 +206,7 @@ public function getStyleStack() * * @param string $string * - * @return OutputFormatterStyle|bool false if string is not format string + * @return OutputFormatterStyle|false false if string is not format string */ private function createStyleFromString($string) { diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php b/src/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php index b64c87fa59d81..e335b0ab64bc0 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php @@ -102,7 +102,7 @@ public function getCurrent() /** * @param OutputFormatterStyleInterface $emptyStyle * - * @return OutputFormatterStyleStack + * @return $this */ public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle) { diff --git a/src/Symfony/Component/Console/Helper/DescriptorHelper.php b/src/Symfony/Component/Console/Helper/DescriptorHelper.php index c324c99454389..6090bbfd006b5 100644 --- a/src/Symfony/Component/Console/Helper/DescriptorHelper.php +++ b/src/Symfony/Component/Console/Helper/DescriptorHelper.php @@ -77,7 +77,7 @@ public function describe(OutputInterface $output, $object, array $options = arra * @param string $format * @param DescriptorInterface $descriptor * - * @return DescriptorHelper + * @return $this */ public function register($format, DescriptorInterface $descriptor) { diff --git a/src/Symfony/Component/Console/Helper/Helper.php b/src/Symfony/Component/Console/Helper/Helper.php index 444bbffc768e3..90979d5b9d5e3 100644 --- a/src/Symfony/Component/Console/Helper/Helper.php +++ b/src/Symfony/Component/Console/Helper/Helper.php @@ -35,7 +35,7 @@ public function setHelperSet(HelperSet $helperSet = null) /** * Gets the helper set associated with this helper. * - * @return HelperSet A HelperSet instance + * @return HelperSet|null */ public function getHelperSet() { diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 0d947843a996c..904c04b6822a7 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -93,7 +93,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) { @@ -113,7 +113,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) { diff --git a/src/Symfony/Component/Console/Helper/TableHelper.php b/src/Symfony/Component/Console/Helper/TableHelper.php index d76288455a9ab..52989c5cfc7f5 100644 --- a/src/Symfony/Component/Console/Helper/TableHelper.php +++ b/src/Symfony/Component/Console/Helper/TableHelper.php @@ -48,7 +48,7 @@ public function __construct($triggerDeprecationError = true) * * @param int $layout self::LAYOUT_* * - * @return TableHelper + * @return $this * * @throws \InvalidArgumentException when the table layout is not known */ @@ -114,7 +114,7 @@ public function setRow($column, array $row) * * @param string $paddingChar * - * @return TableHelper + * @return $this */ public function setPaddingChar($paddingChar) { @@ -128,7 +128,7 @@ public function setPaddingChar($paddingChar) * * @param string $horizontalBorderChar * - * @return TableHelper + * @return $this */ public function setHorizontalBorderChar($horizontalBorderChar) { @@ -142,7 +142,7 @@ public function setHorizontalBorderChar($horizontalBorderChar) * * @param string $verticalBorderChar * - * @return TableHelper + * @return $this */ public function setVerticalBorderChar($verticalBorderChar) { @@ -156,7 +156,7 @@ public function setVerticalBorderChar($verticalBorderChar) * * @param string $crossingChar * - * @return TableHelper + * @return $this */ public function setCrossingChar($crossingChar) { @@ -170,7 +170,7 @@ public function setCrossingChar($crossingChar) * * @param string $cellHeaderFormat * - * @return TableHelper + * @return $this */ public function setCellHeaderFormat($cellHeaderFormat) { @@ -184,7 +184,7 @@ public function setCellHeaderFormat($cellHeaderFormat) * * @param string $cellRowFormat * - * @return TableHelper + * @return $this */ public function setCellRowFormat($cellRowFormat) { @@ -198,7 +198,7 @@ public function setCellRowFormat($cellRowFormat) * * @param string $cellRowContentFormat * - * @return TableHelper + * @return $this */ public function setCellRowContentFormat($cellRowContentFormat) { @@ -212,7 +212,7 @@ public function setCellRowContentFormat($cellRowContentFormat) * * @param string $borderFormat * - * @return TableHelper + * @return $this */ public function setBorderFormat($borderFormat) { @@ -226,7 +226,7 @@ public function setBorderFormat($borderFormat) * * @param int $padType STR_PAD_* * - * @return TableHelper + * @return $this */ public function setPadType($padType) { diff --git a/src/Symfony/Component/Console/Helper/TableStyle.php b/src/Symfony/Component/Console/Helper/TableStyle.php index f0f46c71e313b..b00f12ea314f5 100644 --- a/src/Symfony/Component/Console/Helper/TableStyle.php +++ b/src/Symfony/Component/Console/Helper/TableStyle.php @@ -34,7 +34,7 @@ class TableStyle * * @param string $paddingChar * - * @return TableStyle + * @return $this */ public function setPaddingChar($paddingChar) { @@ -62,7 +62,7 @@ public function getPaddingChar() * * @param string $horizontalBorderChar * - * @return TableStyle + * @return $this */ public function setHorizontalBorderChar($horizontalBorderChar) { @@ -86,7 +86,7 @@ public function getHorizontalBorderChar() * * @param string $verticalBorderChar * - * @return TableStyle + * @return $this */ public function setVerticalBorderChar($verticalBorderChar) { @@ -110,7 +110,7 @@ public function getVerticalBorderChar() * * @param string $crossingChar * - * @return TableStyle + * @return $this */ public function setCrossingChar($crossingChar) { @@ -134,7 +134,7 @@ public function getCrossingChar() * * @param string $cellHeaderFormat * - * @return TableStyle + * @return $this */ public function setCellHeaderFormat($cellHeaderFormat) { @@ -158,7 +158,7 @@ public function getCellHeaderFormat() * * @param string $cellRowFormat * - * @return TableStyle + * @return $this */ public function setCellRowFormat($cellRowFormat) { @@ -182,7 +182,7 @@ public function getCellRowFormat() * * @param string $cellRowContentFormat * - * @return TableStyle + * @return $this */ public function setCellRowContentFormat($cellRowContentFormat) { @@ -206,7 +206,7 @@ public function getCellRowContentFormat() * * @param string $borderFormat * - * @return TableStyle + * @return $this */ public function setBorderFormat($borderFormat) { @@ -230,7 +230,7 @@ public function getBorderFormat() * * @param int $padType STR_PAD_* * - * @return TableStyle + * @return $this */ public function setPadType($padType) { diff --git a/src/Symfony/Component/Console/Question/ChoiceQuestion.php b/src/Symfony/Component/Console/Question/ChoiceQuestion.php index 53712ca70af0d..e5b6ff4ad7217 100644 --- a/src/Symfony/Component/Console/Question/ChoiceQuestion.php +++ b/src/Symfony/Component/Console/Question/ChoiceQuestion.php @@ -56,7 +56,7 @@ public function getChoices() * * @param bool $multiselect * - * @return ChoiceQuestion The current instance + * @return $this */ public function setMultiselect($multiselect) { @@ -91,7 +91,7 @@ public function getPrompt() * * @param string $prompt * - * @return ChoiceQuestion The current instance + * @return $this */ public function setPrompt($prompt) { @@ -107,7 +107,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 1eb3af663dc8f..373501d691f8c 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -74,7 +74,7 @@ public function isHidden() * * @param bool $hidden * - * @return Question The current instance + * @return $this * * @throws \LogicException In case the autocompleter is also used */ @@ -104,7 +104,7 @@ public function isHiddenFallback() * * @param bool $fallback * - * @return Question The current instance + * @return $this */ public function setHiddenFallback($fallback) { @@ -128,7 +128,7 @@ public function getAutocompleterValues() * * @param null|array|\Traversable $values * - * @return Question The current instance + * @return $this * * @throws \InvalidArgumentException * @throws \LogicException @@ -159,7 +159,7 @@ public function setAutocompleterValues($values) * * @param null|callable $validator * - * @return Question The current instance + * @return $this */ public function setValidator($validator) { @@ -185,7 +185,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. */ @@ -219,7 +219,7 @@ public function getMaxAttempts() * * @param callable $normalizer * - * @return Question The current instance + * @return $this */ public function setNormalizer($normalizer) { 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/Node/Specificity.php b/src/Symfony/Component/CssSelector/Node/Specificity.php index 0ce0c3f3049dd..6ee406d1328d1 100644 --- a/src/Symfony/Component/CssSelector/Node/Specificity.php +++ b/src/Symfony/Component/CssSelector/Node/Specificity.php @@ -59,7 +59,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 0c166eff229fb..c4dd3375e10cf 100644 --- a/src/Symfony/Component/CssSelector/Parser/TokenStream.php +++ b/src/Symfony/Component/CssSelector/Parser/TokenStream.php @@ -59,7 +59,7 @@ class TokenStream * * @param Token $token * - * @return TokenStream + * @return $this */ public function push(Token $token) { @@ -71,7 +71,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 2b8920f1ab502..2c43116fb82fe 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php @@ -48,7 +48,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 3582048260496..4158e2e14f0da 100644 --- a/src/Symfony/Component/CssSelector/XPath/Translator.php +++ b/src/Symfony/Component/CssSelector/XPath/Translator.php @@ -144,7 +144,7 @@ public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or * * @param Extension\ExtensionInterface $extension * - * @return Translator + * @return $this */ public function registerExtension(Extension\ExtensionInterface $extension) { @@ -180,7 +180,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 c7ef97cb9a12e..f75214b6f77f8 100644 --- a/src/Symfony/Component/CssSelector/XPath/XPathExpr.php +++ b/src/Symfony/Component/CssSelector/XPath/XPathExpr.php @@ -64,7 +64,7 @@ public function getElement() /** * @param $condition * - * @return XPathExpr + * @return $this */ public function addCondition($condition) { @@ -82,7 +82,7 @@ public function getCondition() } /** - * @return XPathExpr + * @return $this */ public function addNameTest() { @@ -95,7 +95,7 @@ public function addNameTest() } /** - * @return XPathExpr + * @return $this */ public function addStarPrefix() { @@ -110,7 +110,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/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 44f8f2567821b..23929b3946c0f 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -56,7 +56,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/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 bb0546d0a5919..012a8e946e3bd 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -196,7 +196,7 @@ public function getResources() * * @param ResourceInterface $resource A resource instance * - * @return ContainerBuilder The current instance + * @return $this */ public function addResource(ResourceInterface $resource) { @@ -214,7 +214,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) { @@ -232,7 +232,7 @@ public function setResources(array $resources) * * @param object $object An object instance * - * @return ContainerBuilder The current instance + * @return $this */ public function addObjectResource($object) { @@ -248,7 +248,7 @@ public function addObjectResource($object) * * @param \ReflectionClass $class * - * @return ContainerBuilder The current instance + * @return $this */ public function addClassResource(\ReflectionClass $class) { @@ -271,7 +271,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 @@ -295,7 +295,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) { diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index d5238f34400ab..72fba5acc7ce6 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) { @@ -85,7 +85,7 @@ public function getFactory() * * @param string $factoryClass The factory class name * - * @return Definition The current instance + * @return $this * * @deprecated since version 2.6, to be removed in 3.0. */ @@ -119,7 +119,7 @@ public function getFactoryClass($triggerDeprecationError = true) * * @param string $factoryMethod The factory method name * - * @return Definition The current instance + * @return $this * * @deprecated since version 2.6, to be removed in 3.0. */ @@ -138,7 +138,7 @@ public function setFactoryMethod($factoryMethod) * @param null|string $id The decorated service id, use null to remove decoration * @param null|string $renamedId The new decorated service id * - * @return Definition The current instance + * @return $this * * @throws InvalidArgumentException In case the decorated service id and the new decorated service id are equals. */ @@ -188,7 +188,7 @@ public function getFactoryMethod($triggerDeprecationError = true) * * @param string $factoryService The factory service id * - * @return Definition The current instance + * @return $this * * @deprecated since version 2.6, to be removed in 3.0. */ @@ -224,7 +224,7 @@ public function getFactoryService($triggerDeprecationError = true) * * @param string $class The service class * - * @return Definition The current instance + * @return $this */ public function setClass($class) { @@ -248,7 +248,7 @@ public function getClass() * * @param array $arguments An array of arguments * - * @return Definition The current instance + * @return $this */ public function setArguments(array $arguments) { @@ -281,7 +281,7 @@ public function setProperty($name, $value) * * @param mixed $argument An argument * - * @return Definition The current instance + * @return $this */ public function addArgument($argument) { @@ -296,7 +296,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 */ @@ -344,7 +344,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()) { @@ -362,7 +362,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 */ @@ -381,7 +381,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) { @@ -428,7 +428,7 @@ public function getMethodCalls() * * @param array $tags * - * @return Definition the current instance + * @return $this */ public function setTags(array $tags) { @@ -465,7 +465,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()) { @@ -491,7 +491,7 @@ public function hasTag($name) * * @param string $name The tag name * - * @return Definition + * @return $this */ public function clearTag($name) { @@ -503,7 +503,7 @@ public function clearTag($name) /** * Clears the tags for this definition. * - * @return Definition The current instance + * @return $this */ public function clearTags() { @@ -517,7 +517,7 @@ public function clearTags() * * @param string $file A full pathname to include * - * @return Definition The current instance + * @return $this */ public function setFile($file) { @@ -541,7 +541,7 @@ public function getFile() * * @param string $scope Whether the service must be shared or not * - * @return Definition The current instance + * @return $this */ public function setScope($scope) { @@ -565,7 +565,7 @@ public function getScope() * * @param bool $boolean * - * @return Definition The current instance + * @return $this */ public function setPublic($boolean) { @@ -589,7 +589,7 @@ public function isPublic() * * @param bool $boolean * - * @return Definition The current instance + * @return $this * * @deprecated since version 2.7, will be removed in 3.0. */ @@ -625,7 +625,7 @@ public function isSynchronized($triggerDeprecationError = true) * * @param bool $lazy * - * @return Definition The current instance + * @return $this */ public function setLazy($lazy) { @@ -650,7 +650,7 @@ public function isLazy() * * @param bool $boolean * - * @return Definition the current instance + * @return $this */ public function setSynthetic($boolean) { @@ -676,7 +676,7 @@ public function isSynthetic() * * @param bool $boolean * - * @return Definition the current instance + * @return $this */ public function setAbstract($boolean) { @@ -701,7 +701,7 @@ public function isAbstract() * * @param callable $callable A PHP callable * - * @return Definition The current instance + * @return $this */ public function setConfigurator($callable) { diff --git a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php index f462003fd1e88..17033345fe0e6 100644 --- a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php @@ -192,7 +192,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/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index d4b7d45009a40..ea2051614f192 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -324,7 +324,7 @@ public function serialize() * * @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) { @@ -369,7 +369,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 = -1) { @@ -383,7 +383,7 @@ public function slice($offset = 0, $length = -1) * * @param \Closure $closure An anonymous function * - * @return Crawler A Crawler instance with the selected nodes + * @return self */ public function reduce(\Closure $closure) { @@ -400,7 +400,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() { @@ -410,7 +410,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() { @@ -420,7 +420,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 */ @@ -436,7 +436,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 */ @@ -452,7 +452,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 */ @@ -468,7 +468,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 */ @@ -493,7 +493,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 */ @@ -626,7 +626,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) { @@ -647,7 +647,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 */ @@ -666,7 +666,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) { @@ -681,7 +681,7 @@ public function selectLink($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) { @@ -826,7 +826,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/EventDispatcher/Event.php b/src/Symfony/Component/EventDispatcher/Event.php index 956f7264528c5..3ce854969d223 100644 --- a/src/Symfony/Component/EventDispatcher/Event.php +++ b/src/Symfony/Component/EventDispatcher/Event.php @@ -33,7 +33,7 @@ class Event private $propagationStopped = false; /** - * @var EventDispatcher Dispatcher that dispatched this event + * @var EventDispatcherInterface Dispatcher that dispatched this event */ private $dispatcher; 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/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/Finder/Adapter/AdapterInterface.php b/src/Symfony/Component/Finder/Adapter/AdapterInterface.php index bdc3a938701c9..2f22a81ccbc08 100644 --- a/src/Symfony/Component/Finder/Adapter/AdapterInterface.php +++ b/src/Symfony/Component/Finder/Adapter/AdapterInterface.php @@ -19,105 +19,105 @@ interface AdapterInterface /** * @param bool $followLinks * - * @return AdapterInterface Current instance + * @return $this */ public function setFollowLinks($followLinks); /** * @param int $mode * - * @return AdapterInterface Current instance + * @return $this */ public function setMode($mode); /** * @param array $exclude * - * @return AdapterInterface Current instance + * @return $this */ public function setExclude(array $exclude); /** * @param array $depths * - * @return AdapterInterface Current instance + * @return $this */ public function setDepths(array $depths); /** * @param array $names * - * @return AdapterInterface Current instance + * @return $this */ public function setNames(array $names); /** * @param array $notNames * - * @return AdapterInterface Current instance + * @return $this */ public function setNotNames(array $notNames); /** * @param array $contains * - * @return AdapterInterface Current instance + * @return $this */ public function setContains(array $contains); /** * @param array $notContains * - * @return AdapterInterface Current instance + * @return $this */ public function setNotContains(array $notContains); /** * @param array $sizes * - * @return AdapterInterface Current instance + * @return $this */ public function setSizes(array $sizes); /** * @param array $dates * - * @return AdapterInterface Current instance + * @return $this */ public function setDates(array $dates); /** * @param array $filters * - * @return AdapterInterface Current instance + * @return $this */ public function setFilters(array $filters); /** * @param \Closure|int $sort * - * @return AdapterInterface Current instance + * @return $this */ public function setSort($sort); /** * @param array $paths * - * @return AdapterInterface Current instance + * @return $this */ public function setPath(array $paths); /** * @param array $notPaths * - * @return AdapterInterface Current instance + * @return $this */ public function setNotPath(array $notPaths); /** * @param bool $ignore * - * @return AdapterInterface Current instance + * @return $this */ public function ignoreUnreadableDirs($ignore = true); diff --git a/src/Symfony/Component/Finder/Expression/Expression.php b/src/Symfony/Component/Finder/Expression/Expression.php index a4f1f219a8ec2..f674292326785 100644 --- a/src/Symfony/Component/Finder/Expression/Expression.php +++ b/src/Symfony/Component/Finder/Expression/Expression.php @@ -27,7 +27,7 @@ class Expression implements ValueInterface /** * @param string $expr * - * @return Expression + * @return self */ public static function create($expr) { diff --git a/src/Symfony/Component/Finder/Expression/Regex.php b/src/Symfony/Component/Finder/Expression/Regex.php index a249fc2546dac..e3c404b6d73f5 100644 --- a/src/Symfony/Component/Finder/Expression/Regex.php +++ b/src/Symfony/Component/Finder/Expression/Regex.php @@ -55,7 +55,7 @@ class Regex implements ValueInterface /** * @param string $expr * - * @return Regex + * @return self * * @throws \InvalidArgumentException */ @@ -173,7 +173,7 @@ public function hasOption($option) /** * @param string $option * - * @return Regex + * @return $this */ public function addOption($option) { @@ -187,7 +187,7 @@ public function addOption($option) /** * @param string $option * - * @return Regex + * @return $this */ public function removeOption($option) { @@ -199,7 +199,7 @@ public function removeOption($option) /** * @param bool $startFlag * - * @return Regex + * @return $this */ public function setStartFlag($startFlag) { @@ -219,7 +219,7 @@ public function hasStartFlag() /** * @param bool $endFlag * - * @return Regex + * @return $this */ public function setEndFlag($endFlag) { @@ -239,7 +239,7 @@ public function hasEndFlag() /** * @param bool $startJoker * - * @return Regex + * @return $this */ public function setStartJoker($startJoker) { @@ -259,7 +259,7 @@ public function hasStartJoker() /** * @param bool $endJoker * - * @return Regex + * @return $this */ public function setEndJoker($endJoker) { @@ -279,7 +279,7 @@ public function hasEndJoker() /** * @param array $replacement * - * @return Regex + * @return $this */ public function replaceJokers($replacement) { diff --git a/src/Symfony/Component/Finder/Expression/ValueInterface.php b/src/Symfony/Component/Finder/Expression/ValueInterface.php index 34ce0e7ce4992..3d9b369df1162 100644 --- a/src/Symfony/Component/Finder/Expression/ValueInterface.php +++ b/src/Symfony/Component/Finder/Expression/ValueInterface.php @@ -47,14 +47,14 @@ public function getType(); /** * @param string $expr * - * @return ValueInterface + * @return $this */ public function prepend($expr); /** * @param string $expr * - * @return ValueInterface + * @return $this */ public function append($expr); } diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index c9d14809dc28a..edbdcd6402074 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -85,7 +85,7 @@ public function __construct() /** * Creates a new Finder. * - * @return Finder A new Finder instance + * @return static */ public static function create() { @@ -98,7 +98,7 @@ public static function create() * @param AdapterInterface $adapter An adapter instance * @param int $priority Highest is selected first * - * @return Finder The current Finder instance + * @return $this */ public function addAdapter(AdapterInterface $adapter, $priority = 0) { @@ -114,7 +114,7 @@ public function addAdapter(AdapterInterface $adapter, $priority = 0) /** * Sets the selected adapter to the best one according to the current platform the code is run on. * - * @return Finder The current Finder instance + * @return $this */ public function useBestAdapter() { @@ -128,7 +128,7 @@ public function useBestAdapter() * * @param string $name * - * @return Finder The current Finder instance + * @return $this * * @throws \InvalidArgumentException */ @@ -147,7 +147,7 @@ public function setAdapter($name) /** * Removes all adapters registered in the finder. * - * @return Finder The current Finder instance + * @return $this */ public function removeAdapters() { @@ -171,7 +171,7 @@ public function getAdapters() /** * Restricts the matching to directories only. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this */ public function directories() { @@ -183,7 +183,7 @@ public function directories() /** * Restricts the matching to files only. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this */ public function files() { @@ -202,7 +202,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 @@ -226,7 +226,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 @@ -250,7 +250,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 */ @@ -266,7 +266,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 */ @@ -287,7 +287,7 @@ public function notName($pattern) * * @param string $pattern A pattern (string or regexp) * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see FilecontentFilterIterator */ @@ -308,7 +308,7 @@ public function contains($pattern) * * @param string $pattern A pattern (string or regexp) * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see FilecontentFilterIterator */ @@ -331,7 +331,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 */ @@ -354,7 +354,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 */ @@ -374,7 +374,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 @@ -391,7 +391,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 */ @@ -407,7 +407,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 */ @@ -427,7 +427,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 */ @@ -467,7 +467,7 @@ public static function addVCSPattern($pattern) * * @param \Closure $closure An anonymous function * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see SortableIterator */ @@ -483,7 +483,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 */ @@ -499,7 +499,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 */ @@ -517,7 +517,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 */ @@ -537,7 +537,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 */ @@ -555,7 +555,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 */ @@ -574,7 +574,7 @@ public function sortByModifiedTime() * * @param \Closure $closure An anonymous function * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this * * @see CustomFilterIterator */ @@ -588,7 +588,7 @@ public function filter(\Closure $closure) /** * Forces the following of symlinks. * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this */ public function followLinks() { @@ -604,7 +604,7 @@ public function followLinks() * * @param bool $ignore * - * @return Finder|SplFileInfo[] The current Finder instance + * @return $this */ public function ignoreUnreadableDirs($ignore = true) { @@ -618,7 +618,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 */ @@ -679,7 +679,7 @@ public function getIterator() * * @param mixed $iterator * - * @return Finder|SplFileInfo[] The finder + * @return $this * * @throws \InvalidArgumentException When the given argument is not iterable. */ @@ -713,7 +713,7 @@ public function count() } /** - * @return Finder The current Finder instance + * @return $this */ private function sortAdapters() { diff --git a/src/Symfony/Component/Finder/Shell/Command.php b/src/Symfony/Component/Finder/Shell/Command.php index f8bd6a08514e9..1e0747210c7a1 100644 --- a/src/Symfony/Component/Finder/Shell/Command.php +++ b/src/Symfony/Component/Finder/Shell/Command.php @@ -61,7 +61,7 @@ public function __toString() * * @param Command|null $parent Parent command * - * @return Command New Command instance + * @return self */ public static function create(Command $parent = null) { @@ -97,7 +97,7 @@ public static function quote($input) * * @param string|Command $bit * - * @return Command The current Command instance + * @return $this */ public function add($bit) { @@ -111,7 +111,7 @@ public function add($bit) * * @param string|Command $bit * - * @return Command The current Command instance + * @return $this */ public function top($bit) { @@ -129,7 +129,7 @@ public function top($bit) * * @param string $arg * - * @return Command The current Command instance + * @return $this */ public function arg($arg) { @@ -143,7 +143,7 @@ public function arg($arg) * * @param string $esc * - * @return Command The current Command instance + * @return $this */ public function cmd($esc) { @@ -157,7 +157,7 @@ public function cmd($esc) * * @param string $label The unique label * - * @return Command The current Command instance + * @return self|string * * @throws \RuntimeException If label already exists */ @@ -178,7 +178,7 @@ public function ins($label) * * @param string $label * - * @return Command The labeled command + * @return self|string * * @throws \RuntimeException */ @@ -194,7 +194,7 @@ public function get($label) /** * Returns parent command (if any). * - * @return Command Parent command + * @return self * * @throws \RuntimeException If command has no parent */ @@ -220,7 +220,7 @@ public function length() /** * @param \Closure $errorHandler * - * @return Command + * @return $this */ public function setErrorHandler(\Closure $errorHandler) { @@ -283,7 +283,7 @@ function ($bit) { return null !== $bit; } * @param string|Command $bit * @param int $index * - * @return Command The current Command instance + * @return $this */ public function addAtIndex($bit, $index) { 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 89cad51530224..eaecb382fd327 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) { @@ -415,7 +415,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) { @@ -507,7 +507,7 @@ public function setRequestHandler(RequestHandlerInterface $requestHandler) * * @param bool $initialize * - * @return ButtonBuilder + * @return $this * * @throws BadMethodCallException */ diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 62fd18eae4ea2..d64e2f26c6820 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 b72059242ea95..1145ab26420c0 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|FormTypeInterface $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|FormTypeInterface $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/FormConfigBuilder.php b/src/Symfony/Component/Form/FormConfigBuilder.php index 2076f016ac2d6..61c0da55c0bef 100644 --- a/src/Symfony/Component/Form/FormConfigBuilder.php +++ b/src/Symfony/Component/Form/FormConfigBuilder.php @@ -349,7 +349,7 @@ public function getInheritData() /** * Alias of {@link getInheritData()}. * - * @return FormConfigBuilder The configuration object + * @return bool * * @deprecated since version 2.3, to be removed in 3.0. * Use {@link getInheritData()} instead. @@ -715,8 +715,6 @@ public function setInheritData($inheritData) * * @param bool $inheritData Whether the form should inherit its parent's data * - * @return FormConfigBuilder The configuration object - * * @deprecated since version 2.3, to be removed in 3.0. * Use {@link setInheritData()} instead. */ 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/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/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/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 f370867aedc92..b20e2e28ba3c1 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -61,7 +61,7 @@ public function __construct($data = null, $status = 200, $headers = array()) * @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()) { @@ -73,7 +73,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 */ @@ -108,7 +108,7 @@ public function setCallback($callback = null) * * @param mixed $data * - * @return JsonResponse + * @return $this * * @throws \InvalidArgumentException */ @@ -184,7 +184,7 @@ public function getEncodingOptions() * * @param int $encodingOptions * - * @return JsonResponse + * @return $this */ public function setEncodingOptions($encodingOptions) { @@ -196,7 +196,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/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 888e5fdc010d3..e63ee755bb87f 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 952fbc48a6bb3..b19d2122ff6f1 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -219,7 +219,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()) { @@ -262,7 +262,7 @@ public function __clone() * * @param Request $request A Request instance * - * @return Response The current response + * @return $this */ public function prepare(Request $request) { @@ -324,7 +324,7 @@ public function prepare(Request $request) /** * Sends HTTP headers. * - * @return Response + * @return $this */ public function sendHeaders() { @@ -354,7 +354,7 @@ public function sendHeaders() /** * Sends content for the current web response. * - * @return Response + * @return $this */ public function sendContent() { @@ -366,7 +366,7 @@ public function sendContent() /** * Sends HTTP headers and content. * - * @return Response + * @return $this */ public function send() { @@ -389,7 +389,7 @@ public function send() * * @param mixed $content Content that can be cast to string * - * @return Response + * @return $this * * @throws \UnexpectedValueException */ @@ -419,7 +419,7 @@ public function getContent() * * @param string $version The HTTP protocol version * - * @return Response + * @return $this */ public function setProtocolVersion($version) { @@ -447,7 +447,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 */ @@ -490,7 +490,7 @@ public function getStatusCode() * * @param string $charset Character set * - * @return Response + * @return $this */ public function setCharset($charset) { @@ -563,7 +563,7 @@ public function isValidateable() * * It makes the response ineligible for serving other clients. * - * @return Response + * @return $this */ public function setPrivate() { @@ -578,7 +578,7 @@ public function setPrivate() * * It makes the response eligible for serving other clients. * - * @return Response + * @return $this */ public function setPublic() { @@ -620,7 +620,7 @@ public function getDate() * * @param \DateTime $date A \DateTime instance * - * @return Response + * @return $this */ public function setDate(\DateTime $date) { @@ -647,7 +647,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() { @@ -680,7 +680,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) { @@ -726,7 +726,7 @@ public function getMaxAge() * * @param int $value Number of seconds * - * @return Response + * @return $this */ public function setMaxAge($value) { @@ -742,7 +742,7 @@ public function setMaxAge($value) * * @param int $value Number of seconds * - * @return Response + * @return $this */ public function setSharedMaxAge($value) { @@ -776,7 +776,7 @@ public function getTtl() * * @param int $seconds Number of seconds * - * @return Response + * @return $this */ public function setTtl($seconds) { @@ -792,7 +792,7 @@ public function setTtl($seconds) * * @param int $seconds Number of seconds * - * @return Response + * @return $this */ public function setClientTtl($seconds) { @@ -820,7 +820,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) { @@ -851,7 +851,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) { @@ -875,7 +875,7 @@ public function setEtag($etag = null, $weak = false) * * @param array $options An array of cache options * - * @return Response + * @return $this * * @throws \InvalidArgumentException */ @@ -926,7 +926,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 */ @@ -978,7 +978,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 8274dc43a0aeb..8be624436c1ba 100644 --- a/src/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/src/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -55,7 +55,7 @@ public function __construct($callback = null, $status = 200, $headers = array()) * @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/HttpKernel/Profiler/Profile.php b/src/Symfony/Component/HttpKernel/Profiler/Profile.php index a4e4ba6ad66b8..d6be0c7db277c 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/Intl/Collator/Collator.php b/src/Symfony/Component/Intl/Collator/Collator.php index e3dca20c8d1a4..6d79bf30ecc31 100644 --- a/src/Symfony/Component/Intl/Collator/Collator.php +++ b/src/Symfony/Component/Intl/Collator/Collator.php @@ -86,7 +86,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 e6b01d3290e28..3efd5e7bebff3 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -171,7 +171,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/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index d3cd29dd85de3..47e7c60f22c1a 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -302,7 +302,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/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/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index bc763202f228a..cba98630533e0 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -152,7 +152,7 @@ class OptionsResolver implements Options, OptionsResolverInterface * @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 */ @@ -215,7 +215,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 */ @@ -248,7 +248,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 */ @@ -329,7 +329,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 */ @@ -396,7 +396,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 @@ -428,7 +428,7 @@ public function setNormalizer($option, \Closure $normalizer) * * @param array $normalizers An array of closures * - * @return OptionsResolver This instance + * @return $this * * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer @@ -463,7 +463,7 @@ public function setNormalizers(array $normalizers) * @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 @@ -519,7 +519,7 @@ public function setAllowedValues($option, $allowedValues = null) * @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 @@ -575,7 +575,7 @@ public function addAllowedValues($option, $allowedValues = null) * @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 @@ -625,7 +625,7 @@ public function setAllowedTypes($option, $allowedTypes = null) * @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 @@ -674,7 +674,7 @@ public function addAllowedTypes($option, $allowedTypes = null) * * @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 */ @@ -695,7 +695,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/OptionsResolver/OptionsResolverInterface.php b/src/Symfony/Component/OptionsResolver/OptionsResolverInterface.php index cefba9cabeb39..f8b6885742d8a 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolverInterface.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolverInterface.php @@ -43,7 +43,7 @@ interface OptionsResolverInterface * @param array $defaultValues A list of option names as keys and default * values or closures as values. * - * @return OptionsResolverInterface The resolver instance + * @return $this */ public function setDefaults(array $defaultValues); @@ -58,7 +58,7 @@ public function setDefaults(array $defaultValues); * @param array $defaultValues A list of option names as keys and default * values or closures as values. * - * @return OptionsResolverInterface The resolver instance + * @return $this */ public function replaceDefaults(array $defaultValues); @@ -73,7 +73,7 @@ public function replaceDefaults(array $defaultValues); * * @param array $optionNames A list of option names * - * @return OptionsResolverInterface The resolver instance + * @return $this */ public function setOptional(array $optionNames); @@ -85,7 +85,7 @@ public function setOptional(array $optionNames); * * @param array $optionNames A list of option names * - * @return OptionsResolverInterface The resolver instance + * @return $this */ public function setRequired($optionNames); @@ -96,7 +96,7 @@ public function setRequired($optionNames); * with values acceptable for that option as * values. * - * @return OptionsResolverInterface The resolver instance + * @return $this * * @throws InvalidOptionsException If an option has not been defined * (see {@link isKnown()}) for which @@ -113,7 +113,7 @@ public function setAllowedValues($allowedValues); * with values acceptable for that option as * values. * - * @return OptionsResolverInterface The resolver instance + * @return $this * * @throws InvalidOptionsException If an option has not been defined * (see {@link isKnown()}) for which @@ -127,7 +127,7 @@ public function addAllowedValues($allowedValues); * @param array $allowedTypes A list of option names as keys and type * names passed as string or array as values. * - * @return OptionsResolverInterface The resolver instance + * @return $this * * @throws InvalidOptionsException If an option has not been defined for * which an allowed type is set. @@ -142,7 +142,7 @@ public function setAllowedTypes($allowedTypes); * @param array $allowedTypes A list of option names as keys and type * names passed as string or array as values. * - * @return OptionsResolverInterface The resolver instance + * @return $this * * @throws InvalidOptionsException If an option has not been defined for * which an allowed type is set. @@ -165,7 +165,7 @@ public function addAllowedTypes($allowedTypes); * * @param array $normalizers An array of closures * - * @return OptionsResolverInterface The resolver instance + * @return $this */ public function setNormalizers(array $normalizers); diff --git a/src/Symfony/Component/Process/Pipes/UnixPipes.php b/src/Symfony/Component/Process/Pipes/UnixPipes.php index 46130302dabf0..c4babcdf5c92c 100644 --- a/src/Symfony/Component/Process/Pipes/UnixPipes.php +++ b/src/Symfony/Component/Process/Pipes/UnixPipes.php @@ -149,7 +149,7 @@ public function areOpen() * @param Process $process * @param string|resource $input * - * @return UnixPipes + * @return static */ public static function create(Process $process, $input) { diff --git a/src/Symfony/Component/Process/Pipes/WindowsPipes.php b/src/Symfony/Component/Process/Pipes/WindowsPipes.php index 7b2e5b4b23c3d..87a781ea9204a 100644 --- a/src/Symfony/Component/Process/Pipes/WindowsPipes.php +++ b/src/Symfony/Component/Process/Pipes/WindowsPipes.php @@ -183,7 +183,7 @@ public function close() * @param Process $process The process * @param $input * - * @return WindowsPipes + * @return static */ public static function create(Process $process, $input) { diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 5b23192eb9734..23d561662ebae 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -314,7 +314,7 @@ public function start($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 @@ -389,7 +389,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 @@ -405,7 +405,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 @@ -427,7 +427,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 */ @@ -499,7 +499,7 @@ public function getIncrementalOutput() /** * Clears the process output. * - * @return Process + * @return $this */ public function clearOutput() { @@ -558,7 +558,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 0f4764638a3e9..54877a8282813 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 mixed $input The input as a string * - * @return ProcessBuilder + * @return $this * * @throws InvalidArgumentException In case the argument is invalid * @@ -189,7 +189,7 @@ public function setInput($input) * * @param float|null $timeout * - * @return ProcessBuilder + * @return $this * * @throws InvalidArgumentException */ @@ -218,7 +218,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) { @@ -230,7 +230,7 @@ public function setOption($name, $value) /** * Disables fetching output and error output from the underlying process. * - * @return ProcessBuilder + * @return $this */ public function disableOutput() { @@ -242,7 +242,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/PropertyAccess/PropertyAccess.php b/src/Symfony/Component/PropertyAccess/PropertyAccess.php index bd432a3a50bf2..21b926e8282d4 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() { @@ -41,7 +41,7 @@ public static function createPropertyAccessorBuilder() /** * Alias of {@link createPropertyAccessor}. * - * @return PropertyAccessor The new property accessor + * @return PropertyAccessor * * @deprecated since version 2.3, to be removed in 3.0. * Use {@link createPropertyAccessor()} instead. 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/Routing/Matcher/Dumper/DumperCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php index 0f2815b73e46b..2bfdb2e8829bd 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php @@ -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() { 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 b485bded517ea..fee2002c9d9bb 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -159,7 +159,7 @@ public function getPattern() * * @param string $pattern The path pattern * - * @return Route The current Route instance + * @return $this * * @deprecated since version 2.2, to be removed in 3.0. Use setPath instead. */ @@ -187,7 +187,7 @@ public function getPath() * * @param string $pattern The path pattern * - * @return Route The current Route instance + * @return $this */ public function setPath($pattern) { @@ -216,7 +216,7 @@ public function getHost() * * @param string $pattern The host pattern * - * @return Route The current Route instance + * @return $this */ public function setHost($pattern) { @@ -245,7 +245,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) { @@ -294,7 +294,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) { @@ -329,7 +329,7 @@ public function getOptions() * * @param array $options The options * - * @return Route The current Route instance + * @return $this */ public function setOptions(array $options) { @@ -347,7 +347,7 @@ public function setOptions(array $options) * * @param array $options The options * - * @return Route The current Route instance + * @return $this */ public function addOptions(array $options) { @@ -367,7 +367,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) { @@ -418,7 +418,7 @@ public function getDefaults() * * @param array $defaults The defaults * - * @return Route The current Route instance + * @return $this */ public function setDefaults(array $defaults) { @@ -434,7 +434,7 @@ public function setDefaults(array $defaults) * * @param array $defaults The defaults * - * @return Route The current Route instance + * @return $this */ public function addDefaults(array $defaults) { @@ -476,7 +476,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) { @@ -503,7 +503,7 @@ public function getRequirements() * * @param array $requirements The requirements * - * @return Route The current Route instance + * @return $this */ public function setRequirements(array $requirements) { @@ -519,7 +519,7 @@ public function setRequirements(array $requirements) * * @param array $requirements The requirements * - * @return Route The current Route instance + * @return $this */ public function addRequirements(array $requirements) { @@ -567,7 +567,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) { @@ -594,7 +594,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/Security/Acl/Domain/ObjectIdentity.php b/src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php index ec817e2e87b74..d2f353e653ff9 100644 --- a/src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php +++ b/src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php @@ -52,7 +52,7 @@ public function __construct($identifier, $type) * * @param object $domainObject * - * @return ObjectIdentity + * @return self * * @throws InvalidDomainObjectException */ diff --git a/src/Symfony/Component/Security/Acl/Domain/UserSecurityIdentity.php b/src/Symfony/Component/Security/Acl/Domain/UserSecurityIdentity.php index ea17c635d512c..5766148df0ed6 100644 --- a/src/Symfony/Component/Security/Acl/Domain/UserSecurityIdentity.php +++ b/src/Symfony/Component/Security/Acl/Domain/UserSecurityIdentity.php @@ -52,7 +52,7 @@ public function __construct($username, $class) * * @param UserInterface $user * - * @return UserSecurityIdentity + * @return self */ public static function fromAccount(UserInterface $user) { @@ -64,7 +64,7 @@ public static function fromAccount(UserInterface $user) * * @param TokenInterface $token * - * @return UserSecurityIdentity + * @return self */ public static function fromToken(TokenInterface $token) { diff --git a/src/Symfony/Component/Security/Acl/Permission/MaskBuilderInterface.php b/src/Symfony/Component/Security/Acl/Permission/MaskBuilderInterface.php index ef183debdf9c8..98184c560eba1 100644 --- a/src/Symfony/Component/Security/Acl/Permission/MaskBuilderInterface.php +++ b/src/Symfony/Component/Security/Acl/Permission/MaskBuilderInterface.php @@ -21,7 +21,7 @@ interface MaskBuilderInterface * * @param int $mask * - * @return MaskBuilderInterface + * @return $this * * @throws \InvalidArgumentException if $mask is not an integer */ @@ -39,7 +39,7 @@ public function get(); * * @param mixed $mask * - * @return MaskBuilderInterface + * @return $this * * @throws \InvalidArgumentException */ @@ -50,7 +50,7 @@ public function add($mask); * * @param mixed $mask * - * @return MaskBuilderInterface + * @return $this * * @throws \InvalidArgumentException */ @@ -59,7 +59,7 @@ public function remove($mask); /** * Resets the PermissionBuilder. * - * @return MaskBuilderInterface + * @return $this */ public function reset(); diff --git a/src/Symfony/Component/Stopwatch/Section.php b/src/Symfony/Component/Stopwatch/Section.php index fb416efedce23..e2d4dec5cb713 100644 --- a/src/Symfony/Component/Stopwatch/Section.php +++ b/src/Symfony/Component/Stopwatch/Section.php @@ -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/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/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/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 5df8517a479ad..b6c799e192a9a 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -261,7 +261,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) { @@ -282,7 +282,7 @@ public function addPropertyConstraint($property, Constraint $constraint) * @param string $property * @param Constraint[] $constraints * - * @return ClassMetadata + * @return $this */ public function addPropertyConstraints($property, array $constraints) { @@ -302,7 +302,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) { @@ -323,7 +323,7 @@ public function addGetterConstraint($property, Constraint $constraint) * @param string $property * @param Constraint[] $constraints * - * @return ClassMetadata + * @return $this */ public function addGetterConstraints($property, array $constraints) { @@ -448,7 +448,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/GenericMetadata.php b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php index 458ad34fca6cd..97915ac71307f 100644 --- a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php @@ -121,7 +121,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 @@ -167,7 +167,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/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/ValidatorBuilderInterface.php b/src/Symfony/Component/Validator/ValidatorBuilderInterface.php index 690d286789955..b9b33e4fbcad1 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilderInterface.php +++ b/src/Symfony/Component/Validator/ValidatorBuilderInterface.php @@ -28,7 +28,7 @@ interface ValidatorBuilderInterface * * @param ObjectInitializerInterface $initializer The initializer * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function addObjectInitializer(ObjectInitializerInterface $initializer); @@ -37,7 +37,7 @@ public function addObjectInitializer(ObjectInitializerInterface $initializer); * * @param array $initializers The initializer * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function addObjectInitializers(array $initializers); @@ -46,7 +46,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); @@ -55,7 +55,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); @@ -64,7 +64,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); @@ -73,7 +73,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); @@ -82,7 +82,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); @@ -91,7 +91,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); @@ -100,14 +100,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(); @@ -116,7 +116,7 @@ public function disableAnnotationMapping(); * * @param MetadataFactoryInterface $metadataFactory The metadata factory * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function setMetadataFactory(MetadataFactoryInterface $metadataFactory); @@ -125,7 +125,7 @@ public function setMetadataFactory(MetadataFactoryInterface $metadataFactory); * * @param CacheInterface $cache The cache instance * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function setMetadataCache(CacheInterface $cache); @@ -134,7 +134,7 @@ public function setMetadataCache(CacheInterface $cache); * * @param ConstraintValidatorFactoryInterface $validatorFactory The validator factory * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory); @@ -143,7 +143,7 @@ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterfac * * @param TranslatorInterface $translator The translator instance * - * @return ValidatorBuilderInterface The builder object + * @return $this */ public function setTranslator(TranslatorInterface $translator); @@ -156,7 +156,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); @@ -165,7 +165,7 @@ public function setTranslationDomain($translationDomain); * * @param PropertyAccessorInterface $propertyAccessor The property accessor * - * @return ValidatorBuilderInterface The builder object + * @return $this * * @deprecated since version 2.5, to be removed in 3.0. */ @@ -176,7 +176,7 @@ public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor) * * @param int $apiVersion The required API version * - * @return ValidatorBuilderInterface The builder object + * @return $this * * @see Validation::API_VERSION_2_5 * @see Validation::API_VERSION_2_5_BC diff --git a/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php b/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php index fe5eaa3321d1b..981c7f97fa96a 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 int $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); From 82275936045d9854a3721b299e8fce54690d444f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Fri, 23 Dec 2016 15:07:27 +0100 Subject: [PATCH 051/106] [SecurityBundle] Made collection of user provider unique when injecting them to the RemberMeService --- .../DependencyInjection/Security/Factory/RememberMeFactory.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php index 7aa4f5baa03eb..c6688affb40ae 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php @@ -96,7 +96,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; From 7808b675fcfccb1cfb926c35ad340e1af9c4c3c8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 27 Dec 2016 11:48:22 +0100 Subject: [PATCH 052/106] fixed @return when returning this or static --- src/Symfony/Component/Console/Helper/Table.php | 2 +- .../Component/DependencyInjection/Definition.php | 12 ++++++------ .../Form/ChoiceList/View/ChoiceGroupView.php | 2 +- .../Component/Form/ResolvedFormTypeInterface.php | 2 +- src/Symfony/Component/PropertyInfo/Type.php | 4 ++-- .../Routing/Matcher/Dumper/DumperCollection.php | 4 ++-- .../Component/Routing/RouteCollectionBuilder.php | 4 ++-- src/Symfony/Component/Stopwatch/Section.php | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 260eafe503f77..77d21ca83b02e 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -145,7 +145,7 @@ public function getStyle() * @param int $columnIndex Column index * @param TableStyle|string $name The style name or a TableStyle instance * - * @return Table + * @return self */ public function setColumnStyle($columnIndex, $name) { diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 8eb548f5a71b2..3441ebe6c9891 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -547,7 +547,7 @@ public function getFile() * * @param bool $shared Whether the service must be shared or not * - * @return Definition The current instance + * @return self */ public function setShared($shared) { @@ -749,7 +749,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 self * * @throws InvalidArgumentException When the message template is invalid. */ @@ -824,7 +824,7 @@ public function getConfigurator() * * @param string[] $types * - * @return Definition The current instance + * @return self */ public function setAutowiringTypes(array $types) { @@ -852,7 +852,7 @@ public function isAutowired() * * @param bool $autowired * - * @return Definition The current instance + * @return self */ public function setAutowired($autowired) { @@ -876,7 +876,7 @@ public function getAutowiringTypes() * * @param string $type * - * @return Definition The current instance + * @return self */ public function addAutowiringType($type) { @@ -890,7 +890,7 @@ public function addAutowiringType($type) * * @param string $type * - * @return Definition The current instance + * @return self */ public function removeAutowiringType($type) { 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/ResolvedFormTypeInterface.php b/src/Symfony/Component/Form/ResolvedFormTypeInterface.php index 1601ef62c2ce6..a59052eac5c4f 100644 --- a/src/Symfony/Component/Form/ResolvedFormTypeInterface.php +++ b/src/Symfony/Component/Form/ResolvedFormTypeInterface.php @@ -30,7 +30,7 @@ public function getName(); /** * 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/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/Matcher/Dumper/DumperCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php index 2bfdb2e8829bd..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() { @@ -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/RouteCollectionBuilder.php b/src/Symfony/Component/Routing/RouteCollectionBuilder.php index 114c1d60f7c7b..2c9e031723871 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/Stopwatch/Section.php b/src/Symfony/Component/Stopwatch/Section.php index e2d4dec5cb713..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) { From eaca2a4509b4cc58b94595e50d9a9a391ff476b2 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 19 Dec 2016 16:58:51 +0100 Subject: [PATCH 053/106] [cache] Bump RedisAdapter timeout to 5s Bump RedisAdapter timeout to 5s because (at least with Predis) 0 means 0s --- src/Symfony/Component/Cache/Adapter/RedisAdapter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php index a636124acba9f..d0d3b72e50cf8 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php @@ -25,8 +25,8 @@ class RedisAdapter extends AbstractAdapter private static $defaultConnectionOptions = array( 'class' => null, 'persistent' => 0, - 'timeout' => 0, - 'read_timeout' => 0, + 'timeout' => 30, + 'read_timeout' => 30, 'retry_interval' => 0, ); private $redis; From aed6f867820014332e733765003391beb958c589 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 27 Dec 2016 14:36:53 +0100 Subject: [PATCH 054/106] fix merge --- src/Symfony/Component/Cache/Adapter/RedisAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php index d0d3b72e50cf8..3a59e837ee134 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php @@ -26,7 +26,7 @@ class RedisAdapter extends AbstractAdapter 'class' => null, 'persistent' => 0, 'timeout' => 30, - 'read_timeout' => 30, + 'read_timeout' => 0, 'retry_interval' => 0, ); private $redis; From ed713aef2bb436b47af4dda7eb35fae2c72ff0be Mon Sep 17 00:00:00 2001 From: SpacePossum Date: Wed, 21 Dec 2016 12:36:34 +0100 Subject: [PATCH 055/106] [Debug] UndefinedMethodFatalErrorHandler - Handle anonymous classes --- .../UndefinedMethodFatalErrorHandler.php | 8 +++++++- .../UndefinedMethodFatalErrorHandlerTest.php | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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/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".', + ), ); } } From 18dfef1e2b5cd84035532de94823ed5a9a2bbc46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 27 Dec 2016 15:47:08 +0100 Subject: [PATCH 056/106] [Debug] Wrap call to ->log in a try catch block If something goes wrong in the logger, the application ends up with a blank page. Let's display the original exception. --- src/Symfony/Component/Debug/ErrorHandler.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 9d8ab8060f105..8c664c54f9104 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -504,7 +504,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) { From 3f3c6e0e5318533a1c84f02f77bc3472f0d9faa3 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Sun, 25 Dec 2016 09:24:14 +0000 Subject: [PATCH 057/106] [Config] Improve PHPdoc / IDE autocomplete --- src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php | 2 +- .../Component/Config/Definition/Builder/MergeBuilder.php | 2 +- .../Component/Config/Definition/Builder/NodeDefinition.php | 2 +- .../Component/Config/Definition/Builder/ValidationBuilder.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php index 45878c02fb709..10112a813df7a 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php @@ -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 14240f525124c..1d24953df5742 100644 --- a/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php @@ -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/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index c8a3a248b4ef8..1b712a3150bc3 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -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() { 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) { From 8215dbdb314224e04bf1823a301cc12d1fdb2096 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Wed, 14 Dec 2016 18:35:20 +0000 Subject: [PATCH 058/106] [HttpFoundation] Validate/cast cookie expire time --- .../Component/HttpFoundation/Cookie.php | 6 ++--- .../HttpFoundation/Tests/CookieTest.php | 22 +++++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Cookie.php b/src/Symfony/Component/HttpFoundation/Cookie.php index 13d69f3bd2edd..91783a6ad2b50 100644 --- a/src/Symfony/Component/HttpFoundation/Cookie.php +++ b/src/Symfony/Component/HttpFoundation/Cookie.php @@ -56,7 +56,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.'); } } @@ -64,7 +64,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; @@ -84,7 +84,7 @@ public function __toString() } else { $str .= urlencode($this->getValue()); - if ($this->getExpiresTime() !== 0) { + if (0 !== $this->getExpiresTime()) { $str .= '; expires='.gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime()); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index 222786533ecca..d9f2e2114d414 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,12 +157,12 @@ 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); } } From 8e9a5f8009dc22eefbe0bdac62bd2947cc5fbbcc Mon Sep 17 00:00:00 2001 From: Maxime STEINHAUSSER Date: Tue, 13 Dec 2016 15:25:44 +0100 Subject: [PATCH 059/106] [Console] Descriptors should use Helper::strlen --- .../Console/Descriptor/MarkdownDescriptor.php | 5 +- .../Console/Descriptor/TextDescriptor.php | 17 +- .../Descriptor/AbstractDescriptorTest.php | 2 +- .../Descriptor/MarkdownDescriptorTest.php | 18 + .../Tests/Descriptor/TextDescriptorTest.php | 18 + .../DescriptorApplicationMbString.php | 24 ++ .../Fixtures/DescriptorCommandMbString.php | 32 ++ .../Tests/Fixtures/application_mbstring.md | 309 ++++++++++++++++++ .../Tests/Fixtures/application_mbstring.txt | 19 ++ .../Tests/Fixtures/command_mbstring.md | 33 ++ .../Tests/Fixtures/command_mbstring.txt | 13 + 11 files changed, 479 insertions(+), 11 deletions(-) create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplicationMbString.php create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommandMbString.php create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.txt create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.md create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.txt 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 eb02c89dfa372..c18ed6f22490b 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.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; @@ -37,7 +38,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 +76,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 +95,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 +207,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); } } @@ -252,9 +253,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); } } @@ -271,10 +272,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/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/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/application_mbstring.md b/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md new file mode 100644 index 0000000000000..ef81f8697268b --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md @@ -0,0 +1,309 @@ +MbString åpplicätion +==================== + +* help +* list + +**descriptor:** + +* descriptor:åèä + +help +---- + +* Description: Displays help for a command +* Usage: + + * `help [--xml] [--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: + +**xml:** + +* Name: `--xml` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output help as XML +* 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'` + +**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 [--xml] [--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: + +**xml:** + +* Name: `--xml` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output list as XML +* Default: `false` + +**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 From bbfe6f73b527a55b748913d2801eeb50baa90c51 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 28 Dec 2016 19:13:31 +0100 Subject: [PATCH 060/106] handle empty lines inside unindented collection --- src/Symfony/Component/Yaml/Parser.php | 2 +- src/Symfony/Component/Yaml/Tests/ParserTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 24f666e40e055..f3528ba24fae6 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -423,7 +423,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 42b764e03e7f5..e1e0d5a614195 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 From 7a603df71ded072c0f6a0e66524acb1b588a6a73 Mon Sep 17 00:00:00 2001 From: Marcin Szepczynski Date: Thu, 29 Dec 2016 12:15:44 +0100 Subject: [PATCH 061/106] Polish translation improvement in Validator component --- .../Validator/Resources/translations/validators.pl.xlf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf index 1d6875fb78f48..87bb76b8b00d4 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. From 2a778c2d16b91c4519ba6b135fc152ffb4a0c9cc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 29 Dec 2016 22:43:11 +0100 Subject: [PATCH 062/106] fixed @return when returning this or static --- src/Symfony/Component/Console/Helper/Table.php | 4 ++-- src/Symfony/Component/DomCrawler/Crawler.php | 2 +- src/Symfony/Component/HttpFoundation/JsonResponse.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 0e833bf3b8714..38729250ee135 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -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/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 7512da95e195d..71b05d983eda4 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -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) { diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index 8a70b130cee0d..533775e85b4f2 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -109,7 +109,7 @@ public function setCallback($callback = null) * * @param string $json * - * @return JsonResponse + * @return $this * * @throws \InvalidArgumentException */ From 20d8c74bfed449bd3869dba064b442cc9f214060 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Thu, 29 Dec 2016 22:47:05 +0100 Subject: [PATCH 063/106] Fixed @return when returning this or static #bis --- src/Symfony/Component/Console/Helper/Table.php | 2 +- .../Component/DependencyInjection/Definition.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 77d21ca83b02e..d622294ed4cb1 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -145,7 +145,7 @@ public function getStyle() * @param int $columnIndex Column index * @param TableStyle|string $name The style name or a TableStyle instance * - * @return self + * @return $this */ public function setColumnStyle($columnIndex, $name) { diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 3441ebe6c9891..a002df28753b1 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -547,7 +547,7 @@ public function getFile() * * @param bool $shared Whether the service must be shared or not * - * @return self + * @return $this */ public function setShared($shared) { @@ -749,7 +749,7 @@ public function isAbstract() * @param bool $status * @param string $template Template message to use if the definition is deprecated * - * @return self + * @return $this * * @throws InvalidArgumentException When the message template is invalid. */ @@ -824,7 +824,7 @@ public function getConfigurator() * * @param string[] $types * - * @return self + * @return $this */ public function setAutowiringTypes(array $types) { @@ -852,7 +852,7 @@ public function isAutowired() * * @param bool $autowired * - * @return self + * @return $this */ public function setAutowired($autowired) { @@ -876,7 +876,7 @@ public function getAutowiringTypes() * * @param string $type * - * @return self + * @return $this */ public function addAutowiringType($type) { @@ -890,7 +890,7 @@ public function addAutowiringType($type) * * @param string $type * - * @return self + * @return $this */ public function removeAutowiringType($type) { From 9928c0d44e21201ec86f23b1316e797f1d303f90 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 28 Dec 2016 14:01:35 +0100 Subject: [PATCH 064/106] [Console] OS X Can't call cli_set_process_title php without superuser --- src/Symfony/Component/Console/Command/Command.php | 9 ++++++++- .../Component/Console/Tests/Command/CommandTest.php | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 9bcfdf79cacec..ff4075962e45a 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()) { diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 2c63387116849..1468cbe2ea58a 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -328,6 +328,9 @@ public function testRunWithProcessTitle() $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()); } } From c24269005bbbca3d62399d4d9fe949d28f8055c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 28 Dec 2016 15:28:00 +0100 Subject: [PATCH 065/106] [Console] Escape default value when dumping help --- .../Component/Console/Descriptor/TextDescriptor.php | 11 +++++++++++ .../Console/Tests/Descriptor/ObjectsProvider.php | 3 +++ .../Tests/Fixtures/input_argument_with_style.json | 7 +++++++ .../Tests/Fixtures/input_argument_with_style.md | 7 +++++++ .../Tests/Fixtures/input_argument_with_style.txt | 1 + .../Tests/Fixtures/input_argument_with_style.xml | 7 +++++++ .../Tests/Fixtures/input_option_with_style.json | 9 +++++++++ .../Tests/Fixtures/input_option_with_style.md | 9 +++++++++ .../Tests/Fixtures/input_option_with_style.txt | 1 + .../Tests/Fixtures/input_option_with_style.xml | 7 +++++++ .../Fixtures/input_option_with_style_array.json | 12 ++++++++++++ .../Tests/Fixtures/input_option_with_style_array.md | 9 +++++++++ .../Tests/Fixtures/input_option_with_style_array.txt | 1 + .../Tests/Fixtures/input_option_with_style_array.xml | 8 ++++++++ 14 files changed, 92 insertions(+) create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.json create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.md create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.txt create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_argument_with_style.xml create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.json create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.md create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.txt create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style.xml create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.json create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.md create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.txt create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_with_style_array.xml diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index c18ed6f22490b..b49b64d5acfa8 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -13,6 +13,7 @@ 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; @@ -236,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); + } + } + } + if (PHP_VERSION_ID < 50400) { return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default)); } 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/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 @@ + + From 2bb47136df50b8f36310b9dc936d9d247200e3c6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 30 Dec 2016 11:19:53 +0100 Subject: [PATCH 066/106] fix IPv6 address handling in server commands --- src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php index acf71c666605a..3e1c324f00203 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); From 97b7fabf519b48333b772924b141f84efdb44c1e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 1 Jan 2017 13:18:05 +0100 Subject: [PATCH 067/106] do not depend on a fixed date in layout tests By default, the `DateType` as well as the `DateTimeType` set the choices being available for the year to a range starting five years in the past. After some time, this will make tests fail when the year of the fixed date being used as the initial data is before the first year being part of the choices. --- src/Symfony/Bridge/Twig/composer.json | 2 +- src/Symfony/Bundle/FrameworkBundle/composer.json | 2 +- .../Form/Tests/AbstractBootstrap3LayoutTest.php | 16 ++++++++-------- .../Component/Form/Tests/AbstractLayoutTest.php | 16 ++++++++-------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 74c98e93a50e8..426bf9a64caea 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -22,7 +22,7 @@ "require-dev": { "symfony/asset": "~2.7", "symfony/finder": "~2.3", - "symfony/form": "~2.7.11|~2.8.4", + "symfony/form": "~2.7.23|~2.8.16", "symfony/http-kernel": "~2.3", "symfony/intl": "~2.3", "symfony/routing": "~2.2", diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 9f62cb42e7de7..ead3235670602 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -40,7 +40,7 @@ "symfony/dom-crawler": "~2.0,>=2.0.5", "symfony/intl": "~2.3", "symfony/security": "~2.6", - "symfony/form": "~2.7,>=2.7.2", + "symfony/form": "~2.7.23|~2.8.16", "symfony/class-loader": "~2.1", "symfony/expression-language": "~2.6", "symfony/process": "~2.0,>=2.0.5", diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php index c3e1b3bd8afe0..5e5c8be680e7e 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php @@ -1333,7 +1333,7 @@ public function testCountryWithPlaceholder() public function testDateTime() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'datetime', date('Y').'-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => false, )); @@ -1352,7 +1352,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"] @@ -1407,7 +1407,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', 'datetime', $data, array( 'input' => 'array', @@ -1429,7 +1429,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"] @@ -1446,7 +1446,7 @@ public function testDateTimeWithHourAndMinute() public function testDateTimeWithSeconds() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'datetime', date('Y').'-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => true, )); @@ -1466,7 +1466,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"] @@ -1556,7 +1556,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() public function testDateChoice() { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'date', date('Y').'-02-03', array( 'input' => 'string', 'widget' => 'choice', )); @@ -1576,7 +1576,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/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 05f52249a98f9..1678a4bb2b6cd 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -1226,7 +1226,7 @@ public function testCountryWithPlaceholder() public function testDateTime() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'datetime', date('Y').'-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => false, )); @@ -1245,7 +1245,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"] @@ -1305,7 +1305,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', 'datetime', $data, array( 'input' => 'array', @@ -1326,7 +1326,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"] @@ -1346,7 +1346,7 @@ public function testDateTimeWithHourAndMinute() public function testDateTimeWithSeconds() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'datetime', date('Y').'-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => true, )); @@ -1365,7 +1365,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"] @@ -1452,7 +1452,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() public function testDateChoice() { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'date', date('Y').'-02-03', array( 'input' => 'string', 'widget' => 'choice', )); @@ -1468,7 +1468,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] ' From 4c623514f669ed5496bb8adbe422f56dc2402359 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 2 Jan 2017 16:09:29 +0100 Subject: [PATCH 068/106] Fix merge --- .../Tests/Fixtures/application_mbstring.md | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md b/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md index ef81f8697268b..22a256fae6834 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md @@ -14,7 +14,7 @@ help * Description: Displays help for a command * Usage: - * `help [--xml] [--format FORMAT] [--raw] [--] []` + * `help [--format FORMAT] [--raw] [--] []` The help command displays help for a given command: @@ -38,16 +38,6 @@ To display the list of available commands, please use the list comm ### Options: -**xml:** - -* Name: `--xml` -* Shortcut: -* Accept value: no -* Is value required: no -* Is multiple: no -* Description: To output help as XML -* Default: `false` - **format:** * Name: `--format` @@ -144,7 +134,7 @@ list * Description: Lists commands * Usage: - * `list [--xml] [--raw] [--format FORMAT] [--] []` + * `list [--raw] [--format FORMAT] [--] []` The list command lists all commands: @@ -174,16 +164,6 @@ It's also possible to get raw list of commands (useful for embedding command run ### Options: -**xml:** - -* Name: `--xml` -* Shortcut: -* Accept value: no -* Is value required: no -* Is multiple: no -* Description: To output list as XML -* Default: `false` - **raw:** * Name: `--raw` From 505e84d9f35d21600f57ddbb845f945087330149 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Mon, 2 Jan 2017 16:57:42 +0100 Subject: [PATCH 069/106] Fixed `@return self` with `$this` --- .../Form/FormConfigBuilderInterface.php | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) 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); From b47915c34e93a54dd05482a9d6f5fcd655ab4235 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 2 Jan 2017 17:04:05 +0100 Subject: [PATCH 070/106] [Form] Fix forward compat of AbstractLayoutTest --- src/Symfony/Component/Form/Tests/AbstractLayoutTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 4ebff46056715..e7dc2ce9ea617 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -2422,7 +2422,11 @@ public function testWidgetAttributes() $html = $this->renderWidget($form->createView()); // compare plain HTML to check the whitespace - $this->assertSame('', $html); + try { + $this->assertSame('', $html); + } catch (\PHPUnit_Framework_AssertionFailedError $e) { + $this->assertSame('', $html); + } } public function testWidgetAttributeNameRepeatedIfTrue() From 9879c8193ff5fbe3f61b4ce89c5a76dc6f912022 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 2 Jan 2017 12:30:00 -0800 Subject: [PATCH 071/106] updated LICENSE year --- LICENSE | 2 +- src/Symfony/Bridge/Doctrine/LICENSE | 2 +- src/Symfony/Bridge/Monolog/LICENSE | 2 +- src/Symfony/Bridge/PhpUnit/LICENSE | 2 +- src/Symfony/Bridge/ProxyManager/LICENSE | 2 +- src/Symfony/Bridge/Swiftmailer/LICENSE | 2 +- src/Symfony/Bridge/Twig/LICENSE | 2 +- src/Symfony/Bundle/DebugBundle/LICENSE | 2 +- src/Symfony/Bundle/FrameworkBundle/LICENSE | 2 +- src/Symfony/Bundle/SecurityBundle/LICENSE | 2 +- src/Symfony/Bundle/TwigBundle/LICENSE | 2 +- src/Symfony/Bundle/WebProfilerBundle/LICENSE | 2 +- src/Symfony/Component/Asset/LICENSE | 2 +- src/Symfony/Component/BrowserKit/LICENSE | 2 +- src/Symfony/Component/ClassLoader/LICENSE | 2 +- src/Symfony/Component/Config/LICENSE | 2 +- src/Symfony/Component/Console/LICENSE | 2 +- src/Symfony/Component/CssSelector/LICENSE | 2 +- src/Symfony/Component/Debug/LICENSE | 2 +- src/Symfony/Component/DependencyInjection/LICENSE | 2 +- src/Symfony/Component/DomCrawler/LICENSE | 2 +- src/Symfony/Component/EventDispatcher/LICENSE | 2 +- src/Symfony/Component/ExpressionLanguage/LICENSE | 2 +- src/Symfony/Component/Filesystem/LICENSE | 2 +- src/Symfony/Component/Finder/LICENSE | 2 +- src/Symfony/Component/Form/LICENSE | 2 +- src/Symfony/Component/HttpFoundation/LICENSE | 2 +- src/Symfony/Component/HttpKernel/LICENSE | 2 +- src/Symfony/Component/Intl/LICENSE | 2 +- src/Symfony/Component/Locale/LICENSE | 2 +- src/Symfony/Component/OptionsResolver/LICENSE | 2 +- src/Symfony/Component/Process/LICENSE | 2 +- src/Symfony/Component/PropertyAccess/LICENSE | 2 +- src/Symfony/Component/Routing/LICENSE | 2 +- src/Symfony/Component/Security/Acl/LICENSE | 2 +- src/Symfony/Component/Security/Core/LICENSE | 2 +- src/Symfony/Component/Security/Csrf/LICENSE | 2 +- src/Symfony/Component/Security/Http/LICENSE | 2 +- src/Symfony/Component/Security/LICENSE | 2 +- src/Symfony/Component/Serializer/LICENSE | 2 +- src/Symfony/Component/Stopwatch/LICENSE | 2 +- src/Symfony/Component/Templating/LICENSE | 2 +- src/Symfony/Component/Translation/LICENSE | 2 +- src/Symfony/Component/Validator/LICENSE | 2 +- src/Symfony/Component/VarDumper/LICENSE | 2 +- src/Symfony/Component/Yaml/LICENSE | 2 +- 46 files changed, 46 insertions(+), 46 deletions(-) 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/src/Symfony/Bridge/Doctrine/LICENSE b/src/Symfony/Bridge/Doctrine/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Bridge/Doctrine/LICENSE +++ b/src/Symfony/Bridge/Doctrine/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/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/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/Swiftmailer/LICENSE b/src/Symfony/Bridge/Swiftmailer/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Bridge/Swiftmailer/LICENSE +++ b/src/Symfony/Bridge/Swiftmailer/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/Locale/LICENSE b/src/Symfony/Component/Locale/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Locale/LICENSE +++ b/src/Symfony/Component/Locale/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/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/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/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/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/Security/Acl/LICENSE b/src/Symfony/Component/Security/Acl/LICENSE index 12a74531e40a4..17d16a13367dd 100644 --- a/src/Symfony/Component/Security/Acl/LICENSE +++ b/src/Symfony/Component/Security/Acl/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/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/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/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/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/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/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/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/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/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/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 From 5ea8f3f147294f697f557eb34002592db804885b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 2 Jan 2017 12:30:51 -0800 Subject: [PATCH 072/106] updated LICENSE year --- src/Symfony/Component/PropertyInfo/LICENSE | 2 +- src/Symfony/Component/Security/Guard/LICENSE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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 From 32b8d98bedfe3a9e9a73177e0dd71e0e16b928a3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 3 Jan 2017 08:41:06 +0100 Subject: [PATCH 073/106] [ci] Update travis/appveyor --- .travis.yml | 6 +++--- appveyor.yml | 5 ++--- phpunit | 2 ++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e48a5600600a..e69b554b4de0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,7 +78,7 @@ 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: @@ -87,5 +87,5 @@ script: - 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' && echo -e "\\e[33mOK\\e[0m {}" || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1))'; 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 && echo -e "\\e[33mOK\\e[0m {}" || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1))'; fi diff --git a/appveyor.yml b/appveyor.yml index f8162c0689ff0..5f3953ed8acca 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: @@ -48,13 +48,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..4f83ee83aed9c 100755 --- a/phpunit +++ b/phpunit @@ -1,6 +1,8 @@ #!/usr/bin/env php Date: Tue, 3 Jan 2017 14:47:01 +0100 Subject: [PATCH 074/106] [appveyor] Update phpunit-bridge cache-id --- phpunit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit b/phpunit index 4f83ee83aed9c..217d23ad83700 100755 --- a/phpunit +++ b/phpunit @@ -1,7 +1,7 @@ #!/usr/bin/env php Date: Tue, 3 Jan 2017 15:49:55 +0100 Subject: [PATCH 075/106] Minor fixes found while ugrading the CI --- .github/build-packages.php | 10 +++++++--- .travis.yml | 11 ++++++----- phpunit | 2 +- .../Tests/Extension/Validator/Type/TypeTestCase.php | 6 ++---- 4 files changed, 16 insertions(+), 13 deletions(-) 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/.travis.yml b/.travis.yml index e69b554b4de0b..3d7476fd540f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -82,10 +82,11 @@ install: - 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 -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi - - if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group 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"$REPORT"; fi + - if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group benchmark,intl-data"$REPORT"; 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' && echo -e "\\e[33mOK\\e[0m {}" || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1))'; 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 && echo -e "\\e[33mOK\\e[0m {}" || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1))'; 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 diff --git a/phpunit b/phpunit index 217d23ad83700..1e79197e316d3 100755 --- a/phpunit +++ b/phpunit @@ -1,7 +1,7 @@ #!/usr/bin/env php validator = $this->getMockBuilder('Symfony\Component\Validator\ValidatorInterface')->getMock(); - $metadataFactory = $this->getMockBuilder('Symfony\Component\Validator\MetadataFactoryInterface')->getMock(); - $this->validator->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory)); + $this->validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue($metadata)); + $this->validator->expects($this->once())->method('getMetadataFor')->will($this->returnValue($metadata)); parent::setUp(); } From d294051fe893f95f1dd9d65474ea8f17eb89eb53 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 3 Jan 2017 17:38:07 +0100 Subject: [PATCH 076/106] Fix hhvm & tty tests --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3d7476fd540f4..93ec75cd0a4e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -85,8 +85,8 @@ 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 {}'"$REPORT"; fi - - if [[ ! $deps && ! $PHP = hhvm* ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty"$REPORT"; fi - - if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group 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"$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 From b282076d8a0b886976fb321c2116b678226a592f Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Tue, 3 Jan 2017 20:12:28 +0100 Subject: [PATCH 077/106] [Profiler][VarDumper] Fix minor color issue & duplicated selector --- .../Resources/views/Profiler/toolbar.css.twig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 14dd2d4b591ce..22a11b03a4361 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; } From fef3146b3b68db7f367f766e046e6ee624ef51fe Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sat, 31 Dec 2016 12:06:43 +0100 Subject: [PATCH 078/106] Fix serializer/translations/validator resources loading for bundles overriding getPath() --- .../FrameworkExtension.php | 20 +++++------- .../Resources/config/validation.xml | 0 .../Resources/config/validation.yml | 0 .../CustomPathBundle/src/CustomPathBundle.php | 20 ++++++++++++ .../FrameworkExtensionTest.php | 31 ++++++++++++++++++- .../Bundle/FrameworkBundle/composer.json | 2 +- .../DependencyInjection/TwigExtension.php | 11 +++---- .../DependencyInjection/TwigExtensionTest.php | 1 + src/Symfony/Bundle/TwigBundle/composer.json | 2 +- src/Symfony/Component/HttpKernel/Kernel.php | 8 +++++ 10 files changed, 73 insertions(+), 22 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources/config/validation.xml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources/config/validation.yml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 13966eb99dbd4..b6b7a450e08ff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -692,12 +692,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; } } @@ -809,11 +808,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)); @@ -924,10 +920,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/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 922d6f95738f6..9736cf17c3231 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -342,7 +342,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(); @@ -370,6 +371,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'); @@ -472,6 +500,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', diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index ead3235670602..63c43e003506b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -23,7 +23,7 @@ "symfony/event-dispatcher": "~2.5", "symfony/finder": "~2.0,>=2.0.5", "symfony/http-foundation": "~2.7", - "symfony/http-kernel": "~2.7.15|~2.8.8", + "symfony/http-kernel": "~2.7.23|~2.8.16", "symfony/filesystem": "~2.3", "symfony/routing": "~2.6,>2.6.4", "symfony/security-core": "~2.6.13|~2.7.9|~2.8", diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index 5eb163c8869bb..e9f55f758da21 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -89,14 +89,13 @@ public function load(array $configs, ContainerBuilder $container) } // register bundles as Twig namespaces - foreach ($container->getParameter('kernel.bundles') as $bundle => $class) { - if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$bundle.'/views')) { - $this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle); + foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { + if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$name.'/views')) { + $this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $name); } - $reflection = new \ReflectionClass($class); - if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/views')) { - $this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle); + if (is_dir($dir = $bundle['path'].'/Resources/views')) { + $this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $name); } } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index fcfa38a4bb1a8..ab4d649428a58 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -255,6 +255,7 @@ private function createContainer() 'kernel.charset' => 'UTF-8', 'kernel.debug' => false, 'kernel.bundles' => array('TwigBundle' => 'Symfony\\Bundle\\TwigBundle\\TwigBundle'), + 'kernel.bundles_metadata' => array('TwigBundle' => array('namespace' => 'Symfony\\Bundle\\TwigBundle', 'parent' => null, 'path' => realpath(__DIR__.'/../..'))), ))); return $container; diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 8c4947db65f27..861b45d56178d 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -21,7 +21,7 @@ "symfony/twig-bridge": "~2.7", "twig/twig": "~1.28|~2.0", "symfony/http-foundation": "~2.5", - "symfony/http-kernel": "~2.7" + "symfony/http-kernel": "~2.7.23|~2.8.16" }, "require-dev": { "symfony/stopwatch": "~2.2", diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 81f7b2a6140ae..d4e79f35b6510 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -531,8 +531,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( @@ -544,6 +551,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(), ), From fccb98c5513b12b9bd531f809218cc3a546dc511 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 4 Jan 2017 12:00:29 -0800 Subject: [PATCH 079/106] [TwigBundle] fixed typo in composer.json --- src/Symfony/Bundle/TwigBundle/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 78c01d8e9b624..2c0a4e92e285e 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -20,7 +20,7 @@ "symfony/asset": "~2.7|~3.0.0", "symfony/twig-bridge": "~2.7|~3.0.0", "symfony/http-foundation": "~2.5|~3.0.0", - "symfony/http-kernel": "~2.7.23|~2.8.16" + "symfony/http-kernel": "~2.7.23|~2.8.16", "twig/twig": "~1.28|~2.0" }, "require-dev": { From 4864e9dd515cdb674ab9668efb70f2d56d9d886c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 4 Jan 2017 14:00:53 -0800 Subject: [PATCH 080/106] tweaked php cs fixer configuration --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 86ff5eab4d2e2..bbb62c2d3cdce 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -6,6 +6,7 @@ return PhpCsFixer\Config::create() '@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, )) ->setRiskyAllowed(true) From df552af2f24eab26a61932b8178f5cf12688487e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 4 Jan 2017 22:53:34 +0100 Subject: [PATCH 081/106] [Cache] Fix order of writes in ChainAdapter --- .../Component/Cache/Adapter/ChainAdapter.php | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) 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; From c9c2474a2cf6fd9b54305fae3d4a5fb41c002585 Mon Sep 17 00:00:00 2001 From: Iltar van der Berg Date: Fri, 6 Jan 2017 08:41:29 +0100 Subject: [PATCH 082/106] Added missing headers in fixture files --- .../Tests/Fixtures/Controller/BasicTypesController.php | 9 +++++++++ .../Tests/Fixtures/Controller/ExtendingRequest.php | 9 +++++++++ .../Tests/Fixtures/Controller/VariadicController.php | 9 +++++++++ 3 files changed, 27 insertions(+) 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 From ab4ba23931437973386ffa0d32709053fb16681d Mon Sep 17 00:00:00 2001 From: ShinDarth Date: Mon, 2 Jan 2017 09:16:49 +0100 Subject: [PATCH 083/106] [Console] increased code coverage of Output classes --- .../Tests/Output/ConsoleOutputTest.php | 16 +++++++ .../Console/Tests/Output/NullOutputTest.php | 48 +++++++++++++++++++ 2 files changed, 64 insertions(+) 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()); + } } From 4125455775aed7d495d102f6ddfb6b3d95f9e163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 4 Jan 2017 22:43:03 +0100 Subject: [PATCH 084/106] [Serializer] int is valid when float is expected when deserializing JSON --- .../Normalizer/AbstractObjectNormalizer.php | 11 ++++++++ .../Tests/Normalizer/ObjectNormalizerTest.php | 28 +++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) 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/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 30a936d95cadb..72f035462cdb9 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -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; +} From 05bce71d7a60f49214071f57cca5d069e7458035 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Sat, 17 Dec 2016 14:58:06 +0000 Subject: [PATCH 085/106] [HttpFoundation] Improved set cookie header tests --- .../Tests/ResponseHeaderBagTest.php | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) 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)); + } } From dbc41485357b09b9f0e3ed623c6471fa1ea986cd Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sun, 8 Jan 2017 13:55:49 +0100 Subject: [PATCH 086/106] [Filesystem] Check that the directory is writable after created it in dumpFile() --- src/Symfony/Component/Filesystem/Filesystem.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 79e8420688821..a1ff41e892b70 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -498,7 +498,9 @@ public function dumpFile($filename, $content, $mode = 0666) 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); } From d087d0ffea25072b451c91982e6d2ac8e6f80b5e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 8 Jan 2017 14:57:38 +0100 Subject: [PATCH 087/106] [Cache] Add changelog --- src/Symfony/Component/Cache/CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/Symfony/Component/Cache/CHANGELOG.md 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 From 8fa45a130b3eda9c40a691e1926f29d591dfd097 Mon Sep 17 00:00:00 2001 From: Pavel Batanov Date: Wed, 4 Jan 2017 12:18:44 +0300 Subject: [PATCH 088/106] [Validator] Check cascasdedGroups for being countable --- .../Validator/Validator/RecursiveContextualValidator.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index bbd09b821241c..a9e9f7f0e8a12 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -746,9 +746,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 From 6aa98d163d57ef1e2a154266dc258516106b9d96 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 8 Jan 2017 11:25:14 -0800 Subject: [PATCH 089/106] [TwigBundle] fixed usage when Templating is not installed --- .../DependencyInjection/Compiler/ExtensionPass.php | 12 +++++++----- .../TwigBundle/DependencyInjection/TwigExtension.php | 2 +- .../TwigBundle/Resources/config/templating.xml | 2 -- .../Bundle/TwigBundle/Resources/config/twig.xml | 1 + .../Tests/DependencyInjection/TwigExtensionTest.php | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index d619de0d81cec..36cea3d0fed1a 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -45,7 +45,7 @@ public function process(ContainerBuilder $container) 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('fragment.handler')) { @@ -88,11 +88,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 e9f55f758da21..e6ea35b3bdc1f 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -77,7 +77,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) { diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml index 5a39c95018c0b..c1c57d928da71 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml @@ -10,8 +10,6 @@ - - diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index c08be1f0399ed..457cb5c06abf1 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -53,6 +53,7 @@ + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index ab4d649428a58..ff4103d29135c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -187,7 +187,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')) { From 390cb335fab2854407eb2a13f53d067b3a8f6915 Mon Sep 17 00:00:00 2001 From: Bertalan Attila Date: Fri, 6 Jan 2017 14:37:03 +0100 Subject: [PATCH 090/106] Fixing regression in TwigEngine exception handling. --- src/Symfony/Bundle/TwigBundle/TwigEngine.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php index fb4b728a5bede..d4b88be79755f 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php +++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php @@ -74,11 +74,11 @@ public function render($name, array $parameters = array()) if ($name instanceof TemplateReference) { 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)); + $e->setSourceContext($e->getSourceContext()); } else { + $templateName = $e->getTemplateName(); + $path = (string) $this->locator->locate($this->parser->parse($templateName)); $e->setTemplateName($path); } } catch (\Exception $e2) { From 3c887da4f3552478b3367d384c8f5688e92aa3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 9 Jan 2017 00:56:52 +0100 Subject: [PATCH 091/106] [ClassLoader] Throw an exception if the cache is not writeable --- .../Component/ClassLoader/ClassCollectionLoader.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index 5d09848952e8e..6f88286de0ff5 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -275,7 +275,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()); From 101a165d0da707f99007bc2fe86104f33ea492f1 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Mon, 9 Jan 2017 19:49:53 +0100 Subject: [PATCH 092/106] [DI] Fix missing new line after private alias --- src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php | 2 +- .../DependencyInjection/Tests/Fixtures/yaml/services6.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index 955cb7c14ecca..1fa08e2b32912 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -165,7 +165,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/Tests/Fixtures/yaml/services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml index e9e91fa6ba83a..9601516633d1c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml @@ -23,6 +23,8 @@ services: another_alias_for_foo: alias: foo public: false + another_third_alias_for_foo: + alias: foo decorator_service: decorates: decorated decorator_service_with_name: From 9a60057f42fa72094c973b779cd2b88523813cb8 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 6 Jan 2017 14:26:32 +0100 Subject: [PATCH 093/106] respect groups when merging constraints --- src/Symfony/Component/Validator/Mapping/ClassMetadata.php | 5 ++++- .../Validator/Tests/Mapping/ClassMetadataTest.php | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index a079454c70519..dc825e1fa9c2f 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -354,7 +354,10 @@ public function mergeConstraints(ClassMetadata $source) $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()); } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php index 9538977167546..99b15aa9a4cc8 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php @@ -135,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()); @@ -148,9 +149,13 @@ public function testMergeConstraintsMergesMemberConstraints() 'Default', 'Entity', ))); + $constraintB = new ConstraintB(array( + 'groups' => array('foo'), + )); $constraints = array( $constraintA1, + $constraintB, $constraintA2, ); @@ -166,6 +171,9 @@ public function testMergeConstraintsMergesMemberConstraints() $constraintA1, $constraintA2, ), + 'foo' => array( + $constraintB, + ), ); $members = $this->metadata->getPropertyMetadata('firstName'); From 24b93cc75cd403dce481c898a2e6cc8cd2485c1a Mon Sep 17 00:00:00 2001 From: Nikita Nefedov Date: Tue, 10 Jan 2017 14:14:08 +0300 Subject: [PATCH 094/106] Fix Container and PhpDumper test inaccuracies --- .../DependencyInjection/Tests/ContainerTest.php | 16 ++++++++-------- .../Tests/Dumper/PhpDumperTest.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index b4eba04f97340..83a805d612120 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -134,7 +134,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() @@ -196,15 +196,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 ab9d5926106a5..05918b14ec52b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -230,7 +230,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() From 814f63390d0c96a376a3771ab2af1383ddfc8981 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Jan 2017 11:21:41 +0100 Subject: [PATCH 095/106] [DI] Dont share service when no id provided --- .../DependencyInjection/FrameworkExtensionTest.php | 2 +- .../DependencyInjection/CompleteConfigurationTest.php | 2 +- .../Component/DependencyInjection/ContainerBuilder.php | 10 +++++----- .../Component/HttpKernel/Tests/Bundle/BundleTest.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 9736cf17c3231..b9116d39a3602 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -587,7 +587,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/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index 16e5787bdf60e..a07b3fc82910a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -162,7 +162,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/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 012a8e946e3bd..496adb9426fcb 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -430,7 +430,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV } if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) { - return $this->get($this->aliasDefinitions[$id], $invalidBehavior); + return $this->get((string) $this->aliasDefinitions[$id], $invalidBehavior); } try { @@ -1099,15 +1099,15 @@ 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 * * @throws InactiveScopeException */ private function shareService(Definition $definition, $service, $id) { - if (self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) { + if (null !== $id && self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) { if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) { throw new InactiveScopeException($id, $scope); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php index 5faf795f87815..58644336984b9 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php @@ -46,7 +46,7 @@ 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->getMockBuilder('Symfony\Component\Console\Application')->getMock(); // add() is never called when the found command classes are already registered as services From 87db587fa68a96ce08d82a28c6d6cf4dfcd2fd9e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Jan 2017 15:07:18 +0100 Subject: [PATCH 096/106] Fix merge --- .../Tests/Compiler/AutowirePassTest.php | 224 +----------------- 1 file changed, 2 insertions(+), 222 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index bb7bed43becd9..c9445c01dc1b1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -211,13 +211,13 @@ public function testCreateDefinition() $pass->process($container); $this->assertCount(1, $container->getDefinition('coop_tilleuls')->getArguments()); - $this->assertEquals('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas', $container->getDefinition('coop_tilleuls')->getArgument(0)); + $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'); $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)); + $this->assertEquals('autowired.symfony\component\dependencyinjection\tests\compiler\lille', $dunglasDefinition->getArgument(0)); $lilleDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Lille'); $this->assertEquals(__NAMESPACE__.'\Lille', $lilleDefinition->getClass()); @@ -429,107 +429,6 @@ public function testOptionalScalarArgsNotPassedIfLast() ); } - public function testSetterInjection() - { - $container = new ContainerBuilder(); - $container->register('app_foo', Foo::class); - $container->register('app_a', A::class); - $container->register('app_collision_a', CollisionA::class); - $container->register('app_collision_b', CollisionB::class); - - // manually configure *one* call, to override autowiring - $container - ->register('setter_injection', SetterInjection::class) - ->setAutowiredMethods(array('__construct', 'set*')) - ->addMethodCall('setWithCallsConfigured', array('manual_arg1', 'manual_arg2')) - ; - - $pass = new AutowirePass(); - $pass->process($container); - - $methodCalls = $container->getDefinition('setter_injection')->getMethodCalls(); - - // grab the call method names - $actualMethodNameCalls = array_map(function ($call) { - return $call[0]; - }, $methodCalls); - $this->assertEquals( - array('setWithCallsConfigured', 'setFoo', 'setDependencies'), - $actualMethodNameCalls - ); - - // test setWithCallsConfigured args - $this->assertEquals( - array('manual_arg1', 'manual_arg2'), - $methodCalls[0][1] - ); - // test setFoo args - $this->assertEquals( - array(new Reference('app_foo')), - $methodCalls[1][1] - ); - } - - public function testExplicitMethodInjection() - { - $container = new ContainerBuilder(); - $container->register('app_foo', Foo::class); - $container->register('app_a', A::class); - $container->register('app_collision_a', CollisionA::class); - $container->register('app_collision_b', CollisionB::class); - - $container - ->register('setter_injection', SetterInjection::class) - ->setAutowiredMethods(array('setFoo', 'notASetter')) - ; - - $pass = new AutowirePass(); - $pass->process($container); - - $methodCalls = $container->getDefinition('setter_injection')->getMethodCalls(); - - $actualMethodNameCalls = array_map(function ($call) { - return $call[0]; - }, $methodCalls); - $this->assertEquals( - array('setFoo', 'notASetter'), - $actualMethodNameCalls - ); - } - - /** - * @dataProvider getCreateResourceTests - */ - public function testCreateResourceForClass($className, $isEqual) - { - $startingResource = AutowirePass::createResourceForClass( - new \ReflectionClass(__NAMESPACE__.'\ClassForResource') - ); - $newResource = AutowirePass::createResourceForClass( - new \ReflectionClass(__NAMESPACE__.'\\'.$className) - ); - - // hack so the objects don't differ by the class name - $startingReflObject = new \ReflectionObject($startingResource); - $reflProp = $startingReflObject->getProperty('class'); - $reflProp->setAccessible(true); - $reflProp->setValue($startingResource, __NAMESPACE__.'\\'.$className); - - if ($isEqual) { - $this->assertEquals($startingResource, $newResource); - } else { - $this->assertNotEquals($startingResource, $newResource); - } - } - - public function getCreateResourceTests() - { - return array( - array('IdenticalClassResource', true), - array('ClassChangedConstructorArgs', false), - ); - } - public function testIgnoreServiceWithClassNotExisting() { $container = new ContainerBuilder(); @@ -544,37 +443,6 @@ public function testIgnoreServiceWithClassNotExisting() $this->assertTrue($container->hasDefinition('bar')); } - - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException - * @expectedExceptionMessage Unable to autowire argument of type "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" for the service "setter_injection_collision". Multiple services exist for this interface (c1, c2). - * @expectedExceptionCode 1 - */ - public function testSetterInjectionCollisionThrowsException() - { - $container = new ContainerBuilder(); - - $container->register('c1', CollisionA::class); - $container->register('c2', CollisionB::class); - $aDefinition = $container->register('setter_injection_collision', SetterInjectionCollision::class); - $aDefinition->setAutowiredMethods(array('__construct', 'set*')); - - $pass = new AutowirePass(); - $pass->process($container); - } - - public function testLogUnusedPatterns() - { - $container = new ContainerBuilder(); - - $definition = $container->register('foo', Foo::class); - $definition->setAutowiredMethods(array('not', 'exist*')); - - $pass = new AutowirePass(); - $pass->process($container); - - $this->assertEquals(array(AutowirePass::class.': Autowiring\'s patterns "not", "exist*" for service "foo" don\'t match any method.'), $container->getCompiler()->getLog()); - } } class Foo @@ -730,91 +598,3 @@ public function __construct(A $a, $foo = 'default_val', Lille $lille) { } } - -/* - * Classes used for testing createResourceForClass - */ -class ClassForResource -{ - public function __construct($foo, Bar $bar = null) - { - } - - public function setBar(Bar $bar) - { - } -} -class IdenticalClassResource extends ClassForResource -{ -} - -class ClassChangedConstructorArgs extends ClassForResource -{ - public function __construct($foo, Bar $bar, $baz) - { - } -} - -class SetterInjection -{ - public function setFoo(Foo $foo) - { - // should be called - } - - public function setDependencies(Foo $foo, A $a) - { - // should be called - } - - public function setBar() - { - // should not be called - } - - public function setNotAutowireable(NotARealClass $n) - { - // should not be called - } - - public function setArgCannotAutowire($foo) - { - // should not be called - } - - public function setOptionalNotAutowireable(NotARealClass $n = null) - { - // should not be called - } - - public function setOptionalNoTypeHint($foo = null) - { - // should not be called - } - - public function setOptionalArgNoAutowireable($other = 'default_val') - { - // should not be called - } - - public function setWithCallsConfigured(A $a) - { - // this method has a calls configured on it - // should not be called - } - - public function notASetter(A $a) - { - // should be called only when explicitly specified - } -} - -class SetterInjectionCollision -{ - public function setMultipleInstancesForOneArg(CollisionInterface $collision) - { - // The CollisionInterface cannot be autowired - there are multiple - - // should throw an exception - } -} From c5847696eac0c71615f1c2ea9ed0b2ac8dd32302 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Jan 2017 15:26:05 +0100 Subject: [PATCH 097/106] [DI] Add missing legacy group on testLegacy --- .../DependencyInjection/Tests/ContainerBuilderTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index b95574ab4645f..77015aab2500f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -308,6 +308,9 @@ public function testCreateServiceFactory() $this->assertTrue($builder->get('baz')->called, '->createService() uses another service as factory'); } + /** + * @group legacy + */ public function testLegacyCreateServiceFactory() { $builder = new ContainerBuilder(); @@ -324,6 +327,9 @@ public function testLegacyCreateServiceFactory() $this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', $builder->get('bar')), $builder->get('foo1')->arguments, '->createService() passes the arguments to the factory method'); } + /** + * @group legacy + */ public function testLegacyCreateServiceFactoryService() { $builder = new ContainerBuilder(); From 5441e9bc9046a7fbcedb5f945daa126e90a03850 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 11 Jan 2017 15:50:59 +0100 Subject: [PATCH 098/106] [FrameworkBundle] Fix relative paths used as cache keys --- .../Templating/Loader/TemplateLocator.php | 9 +++++++-- .../FrameworkBundle/Tests/Fixtures/templates.php | 5 +++++ .../Tests/Templating/Loader/TemplateLocatorTest.php | 11 +++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/templates.php 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/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/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'); From 0c77ce2355dad4d5011421b88755f2c6e430ef0f Mon Sep 17 00:00:00 2001 From: Wesley Lancel Date: Wed, 4 Jan 2017 21:54:50 +0100 Subject: [PATCH 099/106] [TwigBundle] Fix bug where namespaced paths don't take parent bundles in account --- .../DependencyInjection/TwigExtension.php | 77 +++++++++++++++++-- .../Resources/views/layout.html.twig | 1 + .../Resources/views/layout.html.twig | 1 + .../Resources/views/layout.html.twig | 1 + .../Resources/views/layout.html.twig | 1 + .../DependencyInjection/TwigExtensionTest.php | 50 +++++++++++- 6 files changed, 121 insertions(+), 10 deletions(-) create mode 100644 src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig create mode 100644 src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig create mode 100644 src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig create mode 100644 src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index e9f55f758da21..c4637a45dba7d 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -88,14 +88,19 @@ public function load(array $configs, ContainerBuilder $container) } } - // register bundles as Twig namespaces - foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { - if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$name.'/views')) { - $this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $name); + $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)); + } } - if (is_dir($dir = $bundle['path'].'/Resources/views')) { - $this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $name); + foreach ($bundle['paths'] as $path) { + $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace)); } } @@ -139,13 +144,69 @@ public function load(array $configs, ContainerBuilder $container) )); } + 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; + } + + if (is_dir($dir = $bundle['path'].'/Resources/views')) { + $bundleHierarchy[$name]['paths'][] = $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 addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle) { - $name = $bundle; + $name = $this->normalizeBundleName($bundle); + $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir, $name)); + } + + private function normalizeBundleName($name) + { 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/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 ab4d649428a58..f0f8ad048466a 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -201,8 +201,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); } @@ -254,8 +268,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_metadata' => array('TwigBundle' => array('namespace' => 'Symfony\\Bundle\\TwigBundle', 'parent' => null, 'path' => realpath(__DIR__.'/../..'))), + '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; From 9dd6b0cf643380f3ffb67fcc85eef1255ecfb910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Ja=CC=88ger?= Date: Sat, 3 Dec 2016 12:44:28 +0100 Subject: [PATCH 100/106] [Validator] Fix caching of constraints derived from non-serializable parents --- .../Factory/LazyLoadingMetadataFactory.php | 33 +++++++----- .../LazyLoadingMetadataFactoryTest.php | 51 ++++++++++++++++--- 2 files changed, 64 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php index 68236fc1eb069..82e1cf6bffd44 100644 --- a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php +++ b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php @@ -101,8 +101,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)) { @@ -111,6 +114,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)); @@ -141,16 +160,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/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php index c1aaa9f8c7bf2..a8295cd0ab8c0 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', ))), ); @@ -80,8 +81,8 @@ public function testWriteMetadataToCache() $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'))), @@ -122,17 +123,51 @@ public function testReadMetadataFromCache() $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->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface'); + $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 From 031d8c2c8b6417dc9187e20a2f724c84f4580b73 Mon Sep 17 00:00:00 2001 From: Baptiste Lafontaine Date: Mon, 9 Jan 2017 18:34:08 +0100 Subject: [PATCH 101/106] [Form] DateTimeToLocalizedStringTransformer does not use TZ when using only date --- .../DateTimeToLocalizedStringTransformer.php | 8 ++++---- .../DateTimeToLocalizedStringTransformerTest.php | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index d2e5ddba5cd9d..9411de82b4393 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -130,11 +130,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/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index d5abfe7047b5f..a023f6cf4e7af 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -240,6 +240,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'); From 7775ec210fbb5a8e29f54fb135a5de029db92fd9 Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Wed, 23 Nov 2016 15:20:43 +0100 Subject: [PATCH 102/106] [Ldap] Always have a valid connection when using the EntryManager --- .../Ldap/Adapter/EntryManagerInterface.php | 12 +++++++ .../Ldap/Adapter/ExtLdap/Adapter.php | 2 +- .../Ldap/Adapter/ExtLdap/EntryManager.php | 21 ++++++++++-- .../Component/Ldap/Adapter/ExtLdap/Query.php | 8 +++-- .../Component/Ldap/Adapter/QueryInterface.php | 6 ++++ .../Ldap/Exception/NotBoundException.php | 21 ++++++++++++ .../Tests/Adapter/ExtLdap/AdapterTest.php | 12 +++++++ .../Tests/Adapter/ExtLdap/LdapManagerTest.php | 34 +++++++++++++++++++ 8 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 src/Symfony/Component/Ldap/Exception/NotBoundException.php 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/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[] */ From 49fb0c033c96ada1dd305fbb1e78a426384c5256 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 12 Jan 2017 20:18:32 +0100 Subject: [PATCH 103/106] Remove dead code --- .../Bundle/TwigBundle/DependencyInjection/TwigExtension.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index c741813b86bf5..286c8f6bfabdc 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -194,12 +194,6 @@ private function getBundleHierarchy(ContainerBuilder $container) return $bundleHierarchy; } - private function addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle) - { - $name = $this->normalizeBundleName($bundle); - $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir, $name)); - } - private function normalizeBundleName($name) { if ('Bundle' === substr($name, -6)) { From 52eeddc24e9ec9d0315cd99db242021758ea0fbd Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 12 Jan 2017 20:23:39 +0100 Subject: [PATCH 104/106] Fix getMock usage --- .../Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php index 7ffb33e8db8fc..9696744166537 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php @@ -150,7 +150,7 @@ public function testReadMetadataFromCache() public function testMetadataCacheWithRuntimeConstraint() { - $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); $cache From 7e12e0ad308e8ab84138d06406ceb91174b6287a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 12 Jan 2017 12:43:31 -0800 Subject: [PATCH 105/106] updated CHANGELOG for 3.1.9 --- CHANGELOG-3.1.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) 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) From bb172ebfc506938c3aec01f783e79a588d50fedb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 12 Jan 2017 12:43:39 -0800 Subject: [PATCH 106/106] updated VERSION for 3.1.9 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 19d952e0a1dcc..ff4537f788611 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '3.1.9-DEV'; + const VERSION = '3.1.9'; const VERSION_ID = 30109; const MAJOR_VERSION = 3; const MINOR_VERSION = 1; const RELEASE_VERSION = 9; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2017'; const END_OF_LIFE = '07/2017';