diff --git a/.travis.yml b/.travis.yml index ec9bf6da4d8b..3c3ba5b4ce19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ matrix: - php: 5.4 - php: 5.5 - php: 5.6 - - php: 5.3.3 + - php: 5.3 env: components=low - php: 5.6 env: components=high diff --git a/CHANGELOG-2.3.md b/CHANGELOG-2.3.md index c7acce7993ec..b3c47ea7c220 100644 --- a/CHANGELOG-2.3.md +++ b/CHANGELOG-2.3.md @@ -7,6 +7,28 @@ in 2.3 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.3.0...v2.3.1 +* 2.3.25 (2015-01-30) + + * bug #13528 [Validator] reject ill-formed strings (nicolas-grekas) + * bug #13525 [Validator] UniqueEntityValidator - invalidValue fixed. (Dawid Sajdak) + * bug #13527 [Validator] drop grapheme_strlen in LengthValidator (nicolas-grekas) + * bug #13376 [FrameworkBundle][config] allow multiple fallback locales. (aitboudad) + * bug #12972 Make the container considered non-fresh if the environment parameters are changed (thewilkybarkid) + * bug #13309 [Console] fixed 10531 (nacmartin) + * bug #13352 [Yaml] fixed parse shortcut Key after unindented collection. (aitboudad) + * bug #13039 [HttpFoundation] [Request] fix baseUrl parsing to fix wrong path_info (rk3rn3r) + * bug #13250 [Twig][Bridge][TranslationDefaultDomain] add support of named arguments. (aitboudad) + * bug #13332 [Console] ArgvInput and empty tokens (Taluu) + * bug #13293 [EventDispatcher] Add missing checks to RegisterListenersPass (znerol) + * bug #13262 [Yaml] Improve YAML boolean escaping (petert82, larowlan) + * bug #13420 [Debug] fix loading order for legacy classes (nicolas-grekas) + * bug #13371 fix missing comma in YamlDumper (garak) + * bug #13365 [HttpFoundation] Make use of isEmpty() method (xelaris) + * bug #13347 [Console] Helper\TableHelper->addRow optimization (boekkooi) + * bug #13346 [PropertyAccessor] Allow null value for a array (2.3) (boekkooi) + * bug #13170 [Form] Set a child type to text if added to the form without a type. (jakzal) + * bug #13334 [Yaml] Fixed #10597: Improved Yaml directive parsing (VictoriaQ) + * 2.3.24 (2015-01-07) * bug #13286 [Security] Don't destroy the session on buggy php releases. (derrabus) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0598e0ee353d..3a386a817f26 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -13,19 +13,19 @@ Symfony is the result of the work of many people who made the code better - Kris Wallsmith (kriswallsmith) - Christophe Coevoet (stof) - Nicolas Grekas (nicolas-grekas) - - Pascal Borreli (pborreli) - Jakub Zalas (jakubzalas) + - Pascal Borreli (pborreli) + - Hugo Hamon (hhamon) - Karma Dordrak (drak) - Joseph Bielawski (stloyd) - - Hugo Hamon (hhamon) - Ryan Weaver (weaverryan) - Lukas Kahwe Smith (lsmith) - Romain Neutron (romain) - Jeremy Mikola (jmikola) - Jean-François Simon (jfsimon) + - Christian Flothmann (xabbuh) - Benjamin Eberlei (beberlei) - Igor Wiedler (igorw) - - Christian Flothmann (xabbuh) - Martin Hasoň (hason) - Eriksen Costa (eriksencosta) - Jonathan Wage (jwage) @@ -33,9 +33,9 @@ Symfony is the result of the work of many people who made the code better - Alexandre Salomé (alexandresalome) - William Durand (couac) - ornicar + - Wouter De Jong (wouterj) - stealth35 ‏ (stealth35) - Alexander Mols (asm89) - - Wouter De Jong (wouterj) - Bulat Shakirzyanov (avalanche123) - Francis Besset (francisbesset) - Saša Stamenković (umpirsky) @@ -44,15 +44,15 @@ Symfony is the result of the work of many people who made the code better - Konstantin Kudryashov (everzet) - Bilal Amarni (bamarni) - Florin Patan (florinpatan) + - Abdellatif Ait Boudad (aitboudad) - Eric Clemmons (ericclemmons) + - Sarah Khalil (saro0h) - Andrej Hudec (pulzarraider) - Deni - Henrik Westphal (snc) - Dariusz Górecki (canni) - Arnout Boks (aboks) - Christian Raue - - Sarah Khalil (saro0h) - - Ait Boudad Abdellatif (aitboudad) - Michel Weimerskirch (mweimerskirch) - Lee McDermott - Brandon Turner @@ -69,6 +69,7 @@ Symfony is the result of the work of many people who made the code better - Kevin Bond (kbond) - Tim Nagel (merk) - Brice BERNARD (brikou) + - Kévin Dunglas (dunglas) - marc.weistroff - lenar - Graham Campbell (graham) @@ -81,7 +82,7 @@ Symfony is the result of the work of many people who made the code better - Jérôme Tamarelle (gromnan) - Adrien Brault (adrienbrault) - Fabien Pennequin (fabienpennequin) - - Kévin Dunglas (dunglas) + - Peter Kokot (maastermedia) - Michal Piotrowski (eventhorizon) - Gordon Franke (gimler) - Robert Schönthal (digitalkaoz) @@ -89,13 +90,13 @@ Symfony is the result of the work of many people who made the code better - Sebastian Hörl (blogsh) - Daniel Gomes (danielcsgomes) - Hidenori Goto (hidenorigoto) - - Peter Kokot (maastermedia) - David Buchmann (dbu) + - Jérémy DERUSSÉ (jderusse) - Pablo Godel (pgodel) - Eric GELOEN (gelo) + - Peter Rehm (rpet) - Jérémie Augustin (jaugustin) - Rafael Dohms (rdohms) - - Jérémy DERUSSÉ (jderusse) - Stefano Sala (stefano.sala) - Tigran Azatyan (tigranazatyan) - Javier Eguiluz (javier.eguiluz) @@ -113,7 +114,6 @@ Symfony is the result of the work of many people who made the code better - Rouven Weßling (realityking) - Dmitrii Chekaliuk (lazyhammer) - Clément JOBEILI (dator) - - Peter Rehm (rpet) - Dorian Villet (gnutix) - Richard Miller (mr_r_miller) - Arnaud Kleinpeter (nanocom) @@ -130,25 +130,27 @@ Symfony is the result of the work of many people who made the code better - bronze1man - sun (sun) - Larry Garfield (crell) + - Issei Murasawa (issei_m) - Martin Schuhfuß (usefulthink) - Thomas Rabaix (rande) - Matthieu Bontemps (mbontemps) - Pierre Minnieur (pminnieur) - fivestar - Dominique Bongiraud + - Iltar van der Berg - Leszek Prabucki (l3l0) - François Zaninotto (fzaninotto) - Dustin Whittle (dustinwhittle) - jeff - Justin Hileman (bobthecow) - Sven Paulus (subsven) + - Alexander Schwenn (xelaris) - Lars Strojny (lstrojny) - Rui Marinho (ruimarinho) - Julien Brochet (mewt) - Tugdual Saunier (tucksaun) - Sergey Linnik (linniksa) - Marcel Beerta (mazen) - - Iltar van der Berg - Francois Zaninotto - Alexander Kotynia (olden) - Daniel Tschinder @@ -158,6 +160,7 @@ Symfony is the result of the work of many people who made the code better - Roman Marintšenko (inori) - Xavier Montaña Carreras (xmontana) - Michele Orselli (orso) + - Chris Wilkinson (thewilkybarkid) - Xavier Perez - Arjen Brouwer (arjenjb) - Katsuhiro OGAWA @@ -167,7 +170,6 @@ Symfony is the result of the work of many people who made the code better - Joseph Rouff (rouffj) - Félix Labrecque (woodspire) - GordonsLondon - - Issei Murasawa (issei_m) - Jan Sorgalla (jsor) - Ray - Chekote @@ -181,10 +183,13 @@ Symfony is the result of the work of many people who made the code better - Beau Simensen (simensen) - Robert Kiss (kepten) - Kim Hemsø Rasmussen (kimhemsoe) + - Florian Lonqueu-Brochard (florianlb) - Tom Van Looy (tvlooy) - Wouter Van Hecke + - Joshua Thijssen - Peter Kruithof (pkruithof) - Michael Holm (hollo) + - Warnar Boekkooi (boekkooi) - Marc Weistroff (futurecat) - Chris Smith (cs278) - Florian Klein (docteurklein) @@ -195,10 +200,10 @@ Symfony is the result of the work of many people who made the code better - Bertrand Zuchuat (garfield-fr) - Gabor Toth (tgabi333) - realmfoo - - Chris Wilkinson (thewilkybarkid) - Thomas Tourlourat (armetiz) - Andrey Esaulov (andremaha) - Grégoire Passault (gregwar) + - Mikael Pajunen - Uwe Jäger (uwej711) - Aurelijus Valeiša (aurelijus) - Jan Decavele (jandc) @@ -219,7 +224,6 @@ Symfony is the result of the work of many people who made the code better - alquerci - Francesco Levorato - Vitaliy Zakharov (zakharovvi) - - Florian Lonqueu-Brochard (florianlb) - Gyula Sallai (salla) - Inal DJAFAR (inalgnu) - Christian Gärtner (dagardner) @@ -227,7 +231,6 @@ Symfony is the result of the work of many people who made the code better - Yaroslav Kiliba - Sébastien Lavoie (lavoiesl) - Terje Bråten - - Joshua Thijssen - Kristen Gilden (kgilden) - Robbert Klarenbeek (robbertkl) - Blanchon Vincent (blanchonvincent) @@ -239,6 +242,7 @@ Symfony is the result of the work of many people who made the code better - Philipp Kräutli (pkraeutli) - Kirill chEbba Chebunin (chebba) - Greg Thornton (xdissent) + - Baptiste Clavié (talus) - Grégoire Paris (greg0ire) - Costin Bereveanu (schniper) - Loïc Chardonnet (gnusat) @@ -246,7 +250,6 @@ Symfony is the result of the work of many people who made the code better - Vyacheslav Salakhutdinov (megazoll) - Alex Pott - Tamas Szijarto - - Mikael Pajunen - Pavel Volokitin (pvolok) - Endre Fejes - Tobias Naumann (tna) @@ -254,6 +257,7 @@ Symfony is the result of the work of many people who made the code better - Shein Alexey - Joe Lencioni - Kai + - Lee Rowlands - Maximilian Reichel (phramz) - Karoly Negyesi (chx) - Xavier HAUSHERR @@ -275,6 +279,7 @@ Symfony is the result of the work of many people who made the code better - Michel Salib (michelsalib) - geoffrey - Matthieu Auger (matthieuauger) + - Lorenz Schori - Jeanmonod David (jeanmonod) - Jan Schumann - Niklas Fiekas @@ -287,6 +292,7 @@ Symfony is the result of the work of many people who made the code better - Konstantin Myakshin (koc) - vagrant - Asier Illarramendi (doup) + - Alexander M. Turek (derrabus) - Chris Sedlmayr (catchamonkey) - Seb Koelen - Christoph Mewes (xrstf) @@ -306,7 +312,6 @@ Symfony is the result of the work of many people who made the code better - Jérôme Macias (jeromemacias) - Fabian Lange (codingfabian) - Yoshio HANAWA - - Baptiste Clavié (talus) - Sebastian Bergmann - Pablo Díez (pablodip) - Kevin McBride @@ -337,6 +342,7 @@ Symfony is the result of the work of many people who made the code better - Nils Adermann (naderman) - Gábor Fási - Benjamin Leveque (benji07) + - Javier Spagnoletti (phansys) - sasezaki - Dawid Pakuła (zulusx) - Florian Rey (nervo) @@ -348,6 +354,7 @@ Symfony is the result of the work of many people who made the code better - Ryan - Alexander Deruwe (aderuwe) - François Pluchino (francoispluchino) + - Massimiliano Arione (garak) - Ivan Rey (ivanrey) - Marcin Chyłek (songoq) - Ned Schwartz @@ -356,12 +363,10 @@ Symfony is the result of the work of many people who made the code better - Zach Badgett (zachbadgett) - Aurélien Fredouelle - Pavel Campr (pcampr) - - Alexander Schwenn (xelaris) - Disquedur - Geoffrey Tran (geoff) - Jan Behrens - Sebastian Krebs - - Lorenz Schori - Christopher Davis (chrisguitarguy) - Thomas Lallement (raziel057) - alcaeus @@ -386,8 +391,6 @@ Symfony is the result of the work of many people who made the code better - Javier López (loalf) - Reinier Kip - Dustin Dobervich (dustin10) - - Warnar Boekkooi - - Alexander M. Turek (derrabus) - Sebastian Marek (proofek) - Erkhembayar Gantulga (erheme318) - David Fuhr @@ -410,6 +413,7 @@ Symfony is the result of the work of many people who made the code better - Antoine Corcy - Arturs Vonda - Sascha Grossenbacher + - Szijarto Tamas - Ben Davies (bendavies) - Simon Schick (simonsimcity) - redstar504 @@ -472,7 +476,6 @@ Symfony is the result of the work of many people who made the code better - Loick Piera (pyrech) - cgonzalez - Ben - - Lee Rowlands - Jayson Xu (superjavason) - Jaik Dean (jaikdean) - Harm van Tilborg @@ -490,7 +493,6 @@ Symfony is the result of the work of many people who made the code better - frost-nzcr4 - Abhoryo - Fabian Vogler (fabian) - - Javier Spagnoletti (phansys) - Korvin Szanto - Maksim Kotlyar (makasim) - Neil Ferreira @@ -538,7 +540,6 @@ Symfony is the result of the work of many people who made the code better - Maks - Gábor Tóth - Daniel Cestari - - Massimiliano Arione (garak) - Brunet Laurent (lbrunet) - Magnus Nordlander (magnusnordlander) - Mikhail Yurasov (mym) @@ -597,6 +598,7 @@ Symfony is the result of the work of many people who made the code better - Per Sandström (per) - Goran Juric - Laurent Ghirardotti (laurentg) + - Jan Rosier (rosier) - Lin Clark - Jeremy David (jeremy.david) - Troy McCabe @@ -604,6 +606,7 @@ Symfony is the result of the work of many people who made the code better - Boris Vujicic (boris.vujicic) - Max Beutel - Catalin Dan + - nacho - Piotr Antosik (antek88) - Artem Lopata - Marcos Quesada (marcos_quesada) @@ -658,7 +661,6 @@ Symfony is the result of the work of many people who made the code better - Yannick - Luc Vieillescazes (iamluc) - Eduardo García Sanz (coma) - - Szijarto Tamas - Roy Van Ginneken - David de Boer (ddeboer) - Gilles Doge (gido) @@ -673,6 +675,7 @@ Symfony is the result of the work of many people who made the code better - Derek Lambert - MightyBranch - Kacper Gunia (cakper) + - Peter Thompson (petert82) - Felicitus - Krzysztof Przybyszewski - Paul Matthews @@ -700,6 +703,7 @@ Symfony is the result of the work of many people who made the code better - Aharon Perkel - Abdul.Mohsen B. A. A - Benoît Burnichon + - pthompson - Malaney J. Hill - Christian Flach (cmfcmf) - Cédric Girard (enk_) @@ -738,6 +742,7 @@ Symfony is the result of the work of many people who made the code better - Jason Desrosiers - m.chwedziak - Lance McNearney + - Frank Neff (fneff) - Giorgio Premi - caponica - Matt Daum (daum) @@ -784,6 +789,7 @@ Symfony is the result of the work of many people who made the code better - Klaus Silveira (klaussilveira) - Thomas Chmielowiec (chmielot) - Jānis Lukss + - rkerner - Vladyslav Petrovych - Matthew J Mucklo - fdgdfg (psampaz) @@ -832,6 +838,7 @@ Symfony is the result of the work of many people who made the code better - Przemysław Piechota (kibao) - Leonid Terentyev (li0n) - Adam Prager (padam87) + - victoria - Francisco Facioni (fran6co) - Iwan van Staveren (istaveren) - Povilas S. (povilas) @@ -912,6 +919,7 @@ Symfony is the result of the work of many people who made the code better - Daan van Renterghem - Bram Van der Sype (brammm) - Julien Moulin (lizjulien) + - Nikita Nefedov (nikita2206) - Yannick Warnier (ywarnier) - Kevin Decherf - Jason Woods @@ -958,6 +966,7 @@ Symfony is the result of the work of many people who made the code better - Florian Pfitzer (marmelatze) - Martin Mayer (martin) - Grzegorz Łukaszewicz (newicz) + - Richard van Laak (rvanlaak) - grifx - Robert Campbell - Matt Lehner @@ -965,6 +974,7 @@ Symfony is the result of the work of many people who made the code better - Ruben Kruiswijk - Michael J - Berny Cantos + - Joseph Maarek - Alex Pods - timaschew - Ian Phillips @@ -1020,6 +1030,7 @@ Symfony is the result of the work of many people who made the code better - Pablo Monterde Perez (plebs) - Jimmy Leger (redpanda) - Cyrille Jouineau (tuxosaurus) + - Vadim Kharitonov (virtuozzz) - Yorkie Chadwick (yorkie76) - Yanick Witschi - Ondrej Mirtes @@ -1128,6 +1139,7 @@ Symfony is the result of the work of many people who made the code better - Andreas Forsblom (aforsblo) - Alaattin Kahramanlar (alaattin) - Alex Olmos (alexolmos) + - Alain Hippolyte (aloneh) - Antonio Mansilla (amansilla) - Juan Ases García (ases) - Daniel Basten (axhm3a) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index b3398f35dcda..f1f5bbdc9806 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -244,35 +244,34 @@ public function testValidateUniquenessWithIgnoreNull() ->assertRaised(); } - public function testValidateUniquenessAfterConsideringMultipleQueryResults() + public function testValidateUniquenessWithValidCustomErrorPath() { $constraint = new UniqueEntity(array( 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => array('name', 'name2'), 'em' => self::EM_NAME, + 'errorPath' => "name2", )); - $entity1 = new SingleIntIdEntity(1, 'Foo'); - $entity2 = new SingleIntIdEntity(2, 'Foo'); + $entity1 = new DoubleNameEntity(1, 'Foo', "Bar"); + $entity2 = new DoubleNameEntity(2, 'Foo', "Bar"); + + $this->validator->validate($entity1, $constraint); + + $this->assertNoViolation(); $this->em->persist($entity1); - $this->em->persist($entity2); $this->em->flush(); $this->validator->validate($entity1, $constraint); - $this->buildViolation('myMessage') - ->atPath('property.path.name') - ->setInvalidValue('Foo') - ->assertRaised(); - - $this->context->getViolations()->remove(0); + $this->assertNoViolation(); $this->validator->validate($entity2, $constraint); $this->buildViolation('myMessage') - ->atPath('property.path.name') - ->setInvalidValue('Foo') + ->atPath('property.path.name2') + ->setInvalidValue('Bar') ->assertRaised(); } diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 892d0b4b5118..9aaf329abc18 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -132,10 +132,11 @@ public function validate($entity, Constraint $constraint) } $errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0]; + $invalidValue = isset($criteria[$errorPath]) ? $criteria[$errorPath] : $criteria[$fields[0]]; $this->buildViolation($constraint->message) ->atPath($errorPath) - ->setInvalidValue($criteria[$fields[0]]) + ->setInvalidValue($invalidValue) ->addViolation(); } } diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index e0eff7c4ea67..ae5b840fda39 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -184,7 +184,7 @@ public function getChoicesForValues(array $values) return array(); } - /** + /* * This performance optimization reflects a common scenario: * * A simple select of a model entry. * * The choice option "expanded" is set to false. @@ -239,7 +239,7 @@ public function getValuesForChoices(array $models) } if (!$this->loaded) { - /** + /* * This performance optimization assumes the validation of the respective values will be done by other means. * * It correlates with the performance optimization in {@link ModelChoiceList::getChoicesForValues()} diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 9354a549805a..759523cd766d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -449,8 +449,13 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode) ->arrayNode('translator') ->info('translator configuration') ->canBeEnabled() + ->fixXmlConfig('fallback') ->children() - ->scalarNode('fallback')->defaultValue('en')->end() + ->arrayNode('fallbacks') + ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() + ->prototype('scalar')->end() + ->defaultValue(array('en')) + ->end() ->booleanNode('logging')->defaultValue($this->debug)->end() ->end() ->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 340ff5a0acc6..f7886d6ec07c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -298,7 +298,7 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $ 'memcached' => 'Symfony\Component\HttpKernel\Profiler\MemcachedProfilerStorage', 'redis' => 'Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage', ); - list($class,) = explode(':', $config['dsn'], 2); + list($class, ) = explode(':', $config['dsn'], 2); if (!isset($supported[$class])) { throw new \LogicException(sprintf('Driver "%s" is not supported for the profiler.', $class)); } @@ -633,10 +633,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder // Use the "real" translator instead of the identity default $container->setAlias('translator', 'translator.default'); $translator = $container->findDefinition('translator.default'); - if (!is_array($config['fallback'])) { - $config['fallback'] = array($config['fallback']); - } - $translator->addMethodCall('setFallbackLocales', array($config['fallback'])); + $translator->addMethodCall('setFallbackLocales', array($config['fallbacks'])); $container->setParameter('translator.logging', $config['logging']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 5277da5c1e88..cc3cd1de47a6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -157,6 +157,9 @@ + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 9a4ad2770a44..fdf3173fb23d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -122,7 +122,7 @@ protected static function getBundleDefaultConfig() ), 'translator' => array( 'enabled' => false, - 'fallback' => 'en', + 'fallbacks' => array('en'), 'logging' => true, ), 'validation' => array( diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php new file mode 100644 index 000000000000..0abe3a46abbd --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php @@ -0,0 +1,7 @@ +loadFromExtension('framework', array( + 'translator' => array( + 'fallbacks' => array('en', 'fr'), + ), +)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_fallbacks.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_fallbacks.xml new file mode 100644 index 000000000000..a0e4f4ed32b2 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_fallbacks.xml @@ -0,0 +1,15 @@ + + + + + + + en + fr + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_fallbacks.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_fallbacks.yml new file mode 100644 index 000000000000..271d78118475 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_fallbacks.yml @@ -0,0 +1,3 @@ +framework: + translator: + fallbacks: [en, fr] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index acc3cff6ba41..4f17e8f879db 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -261,6 +261,14 @@ public function testTranslator() $this->assertEquals(array('fr'), $calls[0][1][0]); } + public function testTranslatorMultipleFullback() + { + $container = $this->createContainerFromFile('translator_fallbacks'); + + $calls = $container->getDefinition('translator.default')->getMethodCalls(); + $this->assertEquals(array('en', 'fr'), $calls[0][1][0]); + } + /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php index b796a8125ab4..2119b81b3a91 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php @@ -216,7 +216,7 @@ private function preProcess($eventName) $this->dispatcher->removeListener($eventName, $listener); $info = $this->getListenerInfo($listener, $eventName); $name = isset($info['class']) ? $info['class'] : $info['type']; - $this->dispatcher->addListener($eventName, new WrappedListener($listener, $name, $this->stopwatch)); + $this->dispatcher->addListener($eventName, new WrappedListener($listener, $name, $this->stopwatch, $this)); } } diff --git a/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php b/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php index c501662b07d1..e16627d6ad91 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php +++ b/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php @@ -25,12 +25,14 @@ class WrappedListener private $called; private $stoppedPropagation; private $stopwatch; + private $dispatcher; - public function __construct($listener, $name, Stopwatch $stopwatch) + public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null) { $this->listener = $listener; $this->name = $name; $this->stopwatch = $stopwatch; + $this->dispatcher = $dispatcher; $this->called = false; $this->stoppedPropagation = false; } @@ -56,7 +58,7 @@ public function __invoke(Event $event, $eventName, EventDispatcherInterface $dis $e = $this->stopwatch->start($this->name, 'event_listener'); - call_user_func($this->listener, $event, $eventName, $dispatcher); + call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher); if ($e->isStarted()) { $e->stop(); diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php index 47dd5da16823..68b95236547a 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php @@ -86,6 +86,20 @@ public function testGetCalledListeners() $this->assertEquals(array(), $tdispatcher->getNotCalledListeners()); } + public function testGetCalledListenersNested() + { + $tdispatcher = null; + $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); + $dispatcher->addListener('foo', function (Event $event, $eventName, $dispatcher) use (&$tdispatcher) { + $tdispatcher = $dispatcher; + $dispatcher->dispatch('bar'); + }); + $dispatcher->addListener('bar', function (Event $event) {}); + $dispatcher->dispatch('foo'); + $this->assertSame($dispatcher, $tdispatcher); + $this->assertCount(2, $dispatcher->getCalledListeners()); + } + public function testLogger() { $logger = $this->getMock('Psr\Log\LoggerInterface'); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php index 80d3ab892dc7..95d5cdbf5631 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php @@ -11,11 +11,8 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; -/** - * Adds SessionHandler functionality if available. - * - * @see http://php.net/sessionhandler - */ +// Adds SessionHandler functionality if available. +// @see http://php.net/sessionhandler if (PHP_VERSION_ID >= 50400) { class NativeSessionHandler extends \SessionHandler { diff --git a/src/Symfony/Component/HttpKernel/Exception/FatalErrorException.php b/src/Symfony/Component/HttpKernel/Exception/FatalErrorException.php index 0e7beda8e2c1..7a1cd23381af 100644 --- a/src/Symfony/Component/HttpKernel/Exception/FatalErrorException.php +++ b/src/Symfony/Component/HttpKernel/Exception/FatalErrorException.php @@ -11,7 +11,7 @@ namespace Symfony\Component\HttpKernel\Exception; -/** +/* * Fatal Error Exception. * * @author Konstanton Myakshin diff --git a/src/Symfony/Component/HttpKernel/Exception/FlattenException.php b/src/Symfony/Component/HttpKernel/Exception/FlattenException.php index c84b6fa7aef9..ebe45b458074 100644 --- a/src/Symfony/Component/HttpKernel/Exception/FlattenException.php +++ b/src/Symfony/Component/HttpKernel/Exception/FlattenException.php @@ -11,7 +11,7 @@ namespace Symfony\Component\HttpKernel\Exception; -/** +/* * FlattenException wraps a PHP Exception to be able to serialize it. * * Basically, this class removes all objects from the trace. diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index 5fe67bda5507..fa8237907f4a 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -373,11 +373,9 @@ private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null) } elseif ($key === '#') { $append = $this->selectNodeType($parentNode, $data); } elseif (is_array($data) && false === is_numeric($key)) { - /** - * Is this array fully numeric keys? - */ + // Is this array fully numeric keys? if (ctype_digit(implode('', array_keys($data)))) { - /** + /* * Create nodes to append to $parentNode based on the $key of this array * Produces 01 * From array("item" => array(0,1));. diff --git a/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php b/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php index 1818a3c5ece5..0e7de0881c11 100644 --- a/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php @@ -27,72 +27,52 @@ class CardSchemeValidator extends ConstraintValidator { protected $schemes = array( - /** - * American Express card numbers start with 34 or 37 and have 15 digits. - */ + // American Express card numbers start with 34 or 37 and have 15 digits. 'AMEX' => array( '/^3[47][0-9]{13}$/', ), - /** - * China UnionPay cards start with 62 and have between 16 and 19 digits. - * Please note that these cards do not follow Luhn Algorithm as a checksum. - */ + // China UnionPay cards start with 62 and have between 16 and 19 digits. + // Please note that these cards do not follow Luhn Algorithm as a checksum. 'CHINA_UNIONPAY' => array( '/^62[0-9]{14,17}$/', ), - /** - * Diners Club card numbers begin with 300 through 305, 36 or 38. All have 14 digits. - * There are Diners Club cards that begin with 5 and have 16 digits. - * These are a joint venture between Diners Club and MasterCard, and should be processed like a MasterCard. - */ + // Diners Club card numbers begin with 300 through 305, 36 or 38. All have 14 digits. + // There are Diners Club cards that begin with 5 and have 16 digits. + // These are a joint venture between Diners Club and MasterCard, and should be processed like a MasterCard. 'DINERS' => array( '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/', ), - /** - * Discover card numbers begin with 6011, 622126 through 622925, 644 through 649 or 65. - * All have 16 digits. - */ + // Discover card numbers begin with 6011, 622126 through 622925, 644 through 649 or 65. + // All have 16 digits. 'DISCOVER' => array( '/^6011[0-9]{12}$/', '/^64[4-9][0-9]{13}$/', '/^65[0-9]{14}$/', '/^622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|91[0-9]|92[0-5])[0-9]{10}$/', ), - /** - * InstaPayment cards begin with 637 through 639 and have 16 digits. - */ + // InstaPayment cards begin with 637 through 639 and have 16 digits. 'INSTAPAYMENT' => array( '/^63[7-9][0-9]{13}$/', ), - /** - * JCB cards beginning with 2131 or 1800 have 15 digits. - * JCB cards beginning with 35 have 16 digits. - */ + // JCB cards beginning with 2131 or 1800 have 15 digits. + // JCB cards beginning with 35 have 16 digits. 'JCB' => array( '/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/', ), - /** - * Laser cards begin with either 6304, 6706, 6709 or 6771 and have between 16 and 19 digits. - */ + // Laser cards begin with either 6304, 6706, 6709 or 6771 and have between 16 and 19 digits. 'LASER' => array( '/^(6304|670[69]|6771)[0-9]{12,15}$/', ), - /** - * Maestro cards begin with either 5018, 5020, 5038, 5893, 6304, 6759, 6761, 6762, 6763 or 0604 - * They have between 12 and 19 digits. - */ + // Maestro cards begin with either 5018, 5020, 5038, 5893, 6304, 6759, 6761, 6762, 6763 or 0604 + // They have between 12 and 19 digits. 'MAESTRO' => array( '/^(5018|5020|5038|6304|6759|6761|676[23]|0604)[0-9]{8,15}$/', ), - /** - * All MasterCard numbers start with the numbers 51 through 55. All have 16 digits. - */ + // All MasterCard numbers start with the numbers 51 through 55. All have 16 digits. 'MASTERCARD' => array( '/^5[1-5][0-9]{14}$/', ), - /** - * All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13. - */ + // All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13. 'VISA' => array( '/^4([0-9]{12}|[0-9]{15})$/', ), diff --git a/src/Symfony/Component/Validator/Constraints/Length.php b/src/Symfony/Component/Validator/Constraints/Length.php index 60a46cb8ea1f..8d004805cb10 100644 --- a/src/Symfony/Component/Validator/Constraints/Length.php +++ b/src/Symfony/Component/Validator/Constraints/Length.php @@ -35,6 +35,7 @@ class Length extends Constraint public $maxMessage = 'This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.'; public $minMessage = 'This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.'; public $exactMessage = 'This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters.'; + public $charsetMessage = 'This value does not match the expected {{ charset }} charset.'; public $max; public $min; public $charset = 'UTF-8'; diff --git a/src/Symfony/Component/Validator/Constraints/LengthValidator.php b/src/Symfony/Component/Validator/Constraints/LengthValidator.php index 19f3d3937b50..f82204779c75 100644 --- a/src/Symfony/Component/Validator/Constraints/LengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LengthValidator.php @@ -38,13 +38,39 @@ public function validate($value, Constraint $constraint) } $stringValue = (string) $value; + $invalidCharset = false; - if (function_exists('grapheme_strlen') && 'UTF-8' === $constraint->charset) { - $length = grapheme_strlen($stringValue); + if ('UTF8' === $charset = strtoupper($constraint->charset)) { + $charset = 'UTF-8'; + } + + if (function_exists('iconv_strlen')) { + $length = @iconv_strlen($stringValue, $constraint->charset); + $invalidCharset = false === $length; } elseif (function_exists('mb_strlen')) { - $length = mb_strlen($stringValue, $constraint->charset); - } else { + if (mb_check_encoding($stringValue, $constraint->charset)) { + $length = mb_strlen($stringValue, $constraint->charset); + } else { + $invalidCharset = true; + } + } elseif ('UTF-8' !== $charset) { $length = strlen($stringValue); + } elseif (!preg_match('//u', $stringValue)) { + $invalidCharset = true; + } elseif (function_exists('utf8_decode')) { + $length = strlen(utf8_decode($stringValue)); + } else { + preg_replace('/./u', '', $stringValue, -1, $length); + } + + if ($invalidCharset) { + $this->buildViolation($constraint->charsetMessage) + ->setParameter('{{ value }}', $this->formatValue($stringValue)) + ->setParameter('{{ charset }}', $constraint->charset) + ->setInvalidValue($value) + ->addViolation(); + + return; } if (null !== $constraint->max && $length > $constraint->max) { diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf index 9e53722217ab..d2e13c67e052 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf @@ -302,6 +302,10 @@ An empty file is not allowed. Eine leere Datei ist nicht erlaubt. + + This value does not match the expected {{ charset }} charset. + Dieser Wert entspricht nicht dem erwarteten Zeichensatz {{ charset }}. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf index 346ad0fd3484..6509ab19058a 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf @@ -302,6 +302,10 @@ An empty file is not allowed. An empty file is not allowed. + + This value does not match the expected {{ charset }} charset. + This value does not match the expected {{ charset }} charset. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf index 2bb9348a3efd..237a3b450dec 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf @@ -302,6 +302,10 @@ An empty file is not allowed. Un fichier vide n'est pas autorisé. + + This value does not match the expected {{ charset }} charset. + Cette valeur ne correspond pas au jeu de caractères {{ charset }} attendu. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf index 61062e114876..c2372c9e964d 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf @@ -302,6 +302,10 @@ An empty file is not allowed. Lege bestanden zijn niet toegestaan. + + This value does not match the expected {{ charset }} charset. + Deze waarde is niet in de verwachte tekencodering {{ charset }}. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf index 58c1389e2271..ac7406cbfca9 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf @@ -302,6 +302,10 @@ An empty file is not allowed. Plik nie może być pusty. + + This value does not match the expected {{ charset }} charset. + Ta wartość nie pasuje do oczekiwanego zestawu znaków {{ charset }}. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf index 2ad9b5502fb0..b41d1ae6127a 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf @@ -302,6 +302,10 @@ An empty file is not allowed. Prazna datoteka ni dovoljena. + + This value does not match the expected {{ charset }} charset. + Ta vrednost se ne ujema s pričakovanim naborom znakov {{ charset }}. + diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php index ae27ff25cb45..1224401358d9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php @@ -54,12 +54,12 @@ public function getThreeOrLessCharacters() return array( array(12), array('12'), - array('üü', true), - array('éé', true), + array('üü'), + array('éé'), array(123), array('123'), - array('üüü', true), - array('ééé', true), + array('üüü'), + array('ééé'), ); } @@ -68,8 +68,8 @@ public function getFourCharacters() return array( array(1234), array('1234'), - array('üüüü', true), - array('éééé', true), + array('üüüü'), + array('éééé'), ); } @@ -78,24 +78,34 @@ public function getFiveOrMoreCharacters() return array( array(12345), array('12345'), - array('üüüüü', true), - array('ééééé', true), + array('üüüüü'), + array('ééééé'), array(123456), array('123456'), - array('üüüüüü', true), - array('éééééé', true), + array('üüüüüü'), + array('éééééé'), + ); + } + + public function getOneCharset() + { + if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) { + $this->markTestSkipped('Mbstring or iconv is required for this test.'); + } + + return array( + array("é", "utf8", true), + array("\xE9", "CP1252", true), + array("\xE9", "XXX", false), + array("\xE9", "utf8", false), ); } /** * @dataProvider getFiveOrMoreCharacters */ - public function testValidValuesMin($value, $mbOnly = false) + public function testValidValuesMin($value) { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - $constraint = new Length(array('min' => 5)); $this->validator->validate($value, $constraint); @@ -105,12 +115,8 @@ public function testValidValuesMin($value, $mbOnly = false) /** * @dataProvider getThreeOrLessCharacters */ - public function testValidValuesMax($value, $mbOnly = false) + public function testValidValuesMax($value) { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - $constraint = new Length(array('max' => 3)); $this->validator->validate($value, $constraint); @@ -120,12 +126,8 @@ public function testValidValuesMax($value, $mbOnly = false) /** * @dataProvider getFourCharacters */ - public function testValidValuesExact($value, $mbOnly = false) + public function testValidValuesExact($value) { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - $constraint = new Length(4); $this->validator->validate($value, $constraint); @@ -135,12 +137,8 @@ public function testValidValuesExact($value, $mbOnly = false) /** * @dataProvider getThreeOrLessCharacters */ - public function testInvalidValuesMin($value, $mbOnly = false) + public function testInvalidValuesMin($value) { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - $constraint = new Length(array( 'min' => 4, 'minMessage' => 'myMessage', @@ -160,12 +158,8 @@ public function testInvalidValuesMin($value, $mbOnly = false) /** * @dataProvider getFiveOrMoreCharacters */ - public function testInvalidValuesMax($value, $mbOnly = false) + public function testInvalidValuesMax($value) { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - $constraint = new Length(array( 'max' => 4, 'maxMessage' => 'myMessage', @@ -185,12 +179,8 @@ public function testInvalidValuesMax($value, $mbOnly = false) /** * @dataProvider getThreeOrLessCharacters */ - public function testInvalidValuesExactLessThanFour($value, $mbOnly = false) + public function testInvalidValuesExactLessThanFour($value) { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - $constraint = new Length(array( 'min' => 4, 'max' => 4, @@ -211,12 +201,8 @@ public function testInvalidValuesExactLessThanFour($value, $mbOnly = false) /** * @dataProvider getFiveOrMoreCharacters */ - public function testInvalidValuesExactMoreThanFour($value, $mbOnly = false) + public function testInvalidValuesExactMoreThanFour($value) { - if ($mbOnly && !function_exists('mb_strlen')) { - $this->markTestSkipped('mb_strlen does not exist'); - } - $constraint = new Length(array( 'min' => 4, 'max' => 4, @@ -234,6 +220,31 @@ public function testInvalidValuesExactMoreThanFour($value, $mbOnly = false) ->assertRaised(); } + /** + * @dataProvider getOneCharset + */ + public function testOneCharset($value, $charset, $isValid) + { + $constraint = new Length(array( + 'min' => 1, + 'max' => 1, + 'charset' => $charset, + 'charsetMessage' => 'myMessage', + )); + + $this->validator->validate($value, $constraint); + + if ($isValid) { + $this->assertNoViolation(); + } else { + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$value.'"') + ->setParameter('{{ charset }}', $charset) + ->setInvalidValue($value) + ->assertRaised(); + } + } + public function testConstraintGetDefaultOption() { $constraint = new Length(5);