Merge branch '2.8' into 3.2

* 2.8:
  Allow Upper Case property names
  fix some risky tests
  bumped Symfony version to 2.7.27
  updated VERSION for 2.7.26
  update CONTRIBUTORS for 2.7.26
  updated CHANGELOG for 2.7.26
This commit is contained in:
Fabien Potencier 2017-04-04 08:30:56 -07:00
commit ff286d6da9
28 changed files with 267 additions and 143 deletions

View File

@ -23,25 +23,26 @@ Symfony is the result of the work of many people who made the code better
- Pascal Borreli (pborreli)
- Wouter De Jong (wouterj)
- Romain Neutron (romain)
- Grégoire Pineau (lyrixx)
- Joseph Bielawski (stloyd)
- Karma Dordrak (drak)
- Lukas Kahwe Smith (lsmith)
- Grégoire Pineau (lyrixx)
- Martin Hasoň (hason)
- Jeremy Mikola (jmikola)
- Robin Chalas (chalas_r)
- Maxime Steinhausser (ogizanagi)
- Jeremy Mikola (jmikola)
- Jean-François Simon (jfsimon)
- Benjamin Eberlei (beberlei)
- Igor Wiedler (igorw)
- Robin Chalas (chalas_r)
- Eriksen Costa (eriksencosta)
- Jules Pietri (heah)
- Sarah Khalil (saro0h)
- Jonathan Wage (jwage)
- Guilhem Niot (energetick)
- Diego Saint Esteben (dosten)
- Roland Franssen (ro0)
- Alexandre Salomé (alexandresalome)
- William Durand (couac)
- Guilhem Niot (energetick)
- ornicar
- Francis Besset (francisbesset)
- stealth35 (stealth35)
@ -50,20 +51,20 @@ Symfony is the result of the work of many people who made the code better
- Peter Rehm (rpet)
- Saša Stamenković (umpirsky)
- Henrik Bjørnskov (henrikbjorn)
- Roland Franssen (ro0)
- Miha Vrhovnik
- Roland Franssen (ro0)
- Diego Saint Esteben (dii3g0)
- Konstantin Kudryashov (everzet)
- Bilal Amarni (bamarni)
- Florin Patan (florinpatan)
- Matthias Pigulla (mpdude)
- Kevin Bond (kbond)
- Andrej Hudec (pulzarraider)
- Gábor Egyed (1ed)
- Michel Weimerskirch (mweimerskirch)
- Eric Clemmons (ericclemmons)
- Charles Sarrazin (csarrazi)
- Matthias Pigulla (mpdude)
- Pierre du Plessis (pierredup)
- Christian Raue
- Arnout Boks (aboks)
- Deni
@ -71,39 +72,38 @@ Symfony is the result of the work of many people who made the code better
- Dariusz Górecki (canni)
- Titouan Galopin (tgalopin)
- Douglas Greenshields (shieldo)
- Pierre du Plessis (pierredup)
- Konstantin Myakshin (koc)
- Lee McDermott
- Brandon Turner
- Luis Cordova (cordoval)
- Jáchym Toušek (enumag)
- Graham Campbell (graham)
- Daniel Holmes (dholmes)
- Toni Uebernickel (havvg)
- Bart van den Burg (burgov)
- Jordan Alliot (jalliot)
- Jérémy DERUSSÉ (jderusse)
- John Wards (johnwards)
- Fran Moreno (franmomu)
- Jáchym Toušek (enumag)
- Antoine Hérault (herzult)
- Paráda József (paradajozsef)
- Dariusz Ruminski
- Arnaud Le Blanc (arnaud-lb)
- Jérôme Tamarelle (gromnan)
- Maxime STEINHAUSSER
- Michal Piotrowski (eventhorizon)
- Tim Nagel (merk)
- Maxime STEINHAUSSER
- Issei Murasawa (issei_m)
- Brice BERNARD (brikou)
- Alexander M. Turek (derrabus)
- Baptiste Clavié (talus)
- marc.weistroff
- lenar
- Włodzimierz Gajda (gajdaw)
- Baptiste Clavié (talus)
- Vladimir Reznichenko (kalessil)
- Alexander Schwenn (xelaris)
- Florian Voutzinos (florianv)
- Colin Frei
- Jérémy DERUSSÉ (jderusse)
- Adrien Brault (adrienbrault)
- Joshua Thijssen
- Peter Kokot (maastermedia)
@ -148,6 +148,7 @@ Symfony is the result of the work of many people who made the code better
- Teoh Han Hui (teohhanhui)
- Clemens Tolboom
- Helmer Aaviksoo
- Grégoire Paris (greg0ire)
- Hiromi Hishida (77web)
- Richard van Laak (rvanlaak)
- Matthieu Ouellette-Vachon (maoueh)
@ -160,7 +161,7 @@ Symfony is the result of the work of many people who made the code better
- Warnar Boekkooi (boekkooi)
- Dmitrii Chekaliuk (lazyhammer)
- Clément JOBEILI (dator)
- Grégoire Paris (greg0ire)
- Dawid Nowak
- Possum
- Dorian Villet (gnutix)
- Richard Miller (mr_r_miller)
@ -169,6 +170,7 @@ Symfony is the result of the work of many people who made the code better
- Benjamin Dulau (dbenjamin)
- James Halsall (jaitsu)
- Mathieu Lemoine (lemoinem)
- Chris Wilkinson (thewilkybarkid)
- Andreas Hucks (meandmymonkey)
- Noel Guilbert (noel)
- Lars Strojny (lstrojny)
@ -192,16 +194,15 @@ Symfony is the result of the work of many people who made the code better
- John Kary (johnkary)
- Justin Hileman (bobthecow)
- Blanchon Vincent (blanchonvincent)
- Chris Wilkinson (thewilkybarkid)
- Christian Schmidt
- Michele Orselli (orso)
- Tom Van Looy (tvlooy)
- Sven Paulus (subsven)
- Rui Marinho (ruimarinho)
- SpacePossum
- Dawid Nowak
- Eugene Wissner
- Julien Brochet (mewt)
- Julien Falque (julienfalque)
- Tristan Darricau (nicofuma)
- Grégoire Paris (greg0ire)
- Sergey Linnik (linniksa)
@ -213,6 +214,7 @@ Symfony is the result of the work of many people who made the code better
- julien pauli (jpauli)
- Lorenz Schori
- Sébastien Lavoie (lavoiesl)
- David Maicher (dmaicher)
- Francois Zaninotto
- Alexander Kotynia (olden)
- Daniel Tschinder
@ -237,7 +239,6 @@ Symfony is the result of the work of many people who made the code better
- Uwe Jäger (uwej711)
- Eugene Leonovich (rybakit)
- Filippo Tessarotto
- Julien Falque (julienfalque)
- Joseph Rouff (rouffj)
- Félix Labrecque (woodspire)
- GordonsLondon
@ -259,7 +260,6 @@ Symfony is the result of the work of many people who made the code better
- Beau Simensen (simensen)
- Michael Hirschler (mvhirsch)
- Robert Kiss (kepten)
- David Maicher (dmaicher)
- Roumen Damianoff (roumen)
- Antonio J. García Lagar (ajgarlag)
- Kim Hemsø Rasmussen (kimhemsoe)
@ -397,6 +397,7 @@ Symfony is the result of the work of many people who made the code better
- EdgarPE
- Florian Pfitzer (marmelatze)
- Asier Illarramendi (doup)
- Andreas Braun
- Chris Sedlmayr (catchamonkey)
- Seb Koelen
- Dany Maillard (maidmaid)
@ -416,6 +417,7 @@ Symfony is the result of the work of many people who made the code better
- Gintautas Miselis
- Rob Bast
- David Badura (davidbadura)
- Jordan Samouh (jordansamouh)
- Zander Baldwin
- Adam Harvey
- Alex Bakhturin
@ -460,11 +462,13 @@ Symfony is the result of the work of many people who made the code better
- Jakub Škvára (jskvara)
- Andrew Udvare (audvare)
- alexpods
- Nikolay Labinskiy (e-moe)
- Arjen van der Meijden
- Michele Locati
- Dariusz Ruminski
- Erik Trapman (eriktrapman)
- De Cock Xavier (xdecock)
- Arthur de Moulins (4rthem)
- Almog Baku (almogbaku)
- Scott Arciszewski
- Norbert Orzechowicz (norzechowicz)
@ -511,8 +515,10 @@ Symfony is the result of the work of many people who made the code better
- Disquedur
- Michiel Boeckaert (milio)
- Geoffrey Tran (geoff)
- Romain Pierre (romain-pierre)
- Jan Behrens
- Mantas Var (mvar)
- Frank de Jonge (frenkynet)
- Sebastian Krebs
- Jean-Christophe Cuvelier [Artack]
- Christopher Davis (chrisguitarguy)
@ -540,8 +546,8 @@ Symfony is the result of the work of many people who made the code better
- Maxime Douailin
- Jean Pasdeloup (pasdeloup)
- Benjamin Cremer (bcremer)
- Thierry Thuon (lepiaf)
- Javier López (loalf)
- Andreas Braun
- Reinier Kip
- Geoffrey Brier (geoffrey-brier)
- Dustin Dobervich (dustin10)
@ -554,6 +560,7 @@ Symfony is the result of the work of many people who made the code better
- Kamil Kokot (pamil)
- Aurimas Niekis (gcds)
- Max Grigorian (maxakawizard)
- mcfedr (mcfedr)
- Rostyslav Kinash
- Maciej Malarz (malarzm)
- Daisuke Ohata
@ -571,6 +578,7 @@ Symfony is the result of the work of many people who made the code better
- Denis Brumann (dbrumann)
- Quentin de Longraye (quentinus95)
- Chris Heng (gigablah)
- Richard Bradley
- Ulumuddin Yunus (joenoez)
- Luc Vieillescazes (iamluc)
- Johann Saunier (prophet777)
@ -630,6 +638,7 @@ Symfony is the result of the work of many people who made the code better
- Besnik Br
- Dariusz Ruminski
- Joshua Nye
- Claudio Zizza
- Dave Marshall (davedevelopment)
- avorobiev
- Venu
@ -648,6 +657,7 @@ Symfony is the result of the work of many people who made the code better
- John Bohn (jbohn)
- Marc Morera (mmoreram)
- Andrew Hilobok (hilobok)
- Noah Heck (myesain)
- Christian Soronellas (theunic)
- Yosmany Garcia (yosmanyga)
- Wouter de Wild
@ -655,17 +665,18 @@ Symfony is the result of the work of many people who made the code better
- Degory Valentine
- Benoit Lévêque (benoit_leveque)
- Jeroen Fiege (fieg)
- Arthur de Moulins (4rthem)
- Krzysiek Łabuś
- Xavier Lacot (xavier)
- possum
- Denis Zunke (donalberto)
- Ahmed TAILOULOUTE (ahmedtai)
- Olivier Maisonneuve (olineuve)
- Masterklavi
- Francis Turmel (fturmel)
- Nikita Nefedov (nikita2206)
- cgonzalez
- Ben
- Vincent Composieux (eko)
- Jayson Xu (superjavason)
- Jaik Dean (jaikdean)
- fago
@ -676,6 +687,7 @@ Symfony is the result of the work of many people who made the code better
- James Michael DuPont
- Tom Klingenberg
- Christopher Hall (mythmakr)
- Patrick Dawkins (pjcdawkins)
- Paul Kamer (pkamer)
- Rafał Wrzeszcz (rafalwrzeszcz)
- Reen Lokum
@ -721,6 +733,7 @@ Symfony is the result of the work of many people who made the code better
- corphi
- grizlik
- Derek ROTH
- Dmytro Boiko (eagle)
- Shin Ohno (ganchiku)
- Geert De Deckere (geertdd)
- Jan Kramer (jankramer)
@ -783,7 +796,6 @@ Symfony is the result of the work of many people who made the code better
- Phan Thanh Ha (haphan)
- Chris Jones (leek)
- Colin O'Dell (colinodell)
- Frank de Jonge (frenkynet)
- xaav
- Mahmoud Mostafa (mahmoud)
- Alessandro Lai
@ -809,7 +821,6 @@ Symfony is the result of the work of many people who made the code better
- Zachary Tong (polyfractal)
- Hryhorii Hrebiniuk
- Dennis Fridrich (dfridrich)
- mcfedr (mcfedr)
- hamza
- dantleech
- Bastien DURAND (deamon)
@ -842,6 +853,7 @@ Symfony is the result of the work of many people who made the code better
- Troy McCabe
- Ville Mattila
- ilyes kooli
- gr1ev0us
- Boris Vujicic (boris.vujicic)
- Max Beutel
- Antanas Arvasevicius
@ -865,10 +877,12 @@ Symfony is the result of the work of many people who made the code better
- Martynas Narbutas
- Bailey Parker
- Eddie Jaoude
- Antanas Arvasevicius
- Haritz Iturbe (hizai)
- Nerijus Arlauskas (nercury)
- SPolischook
- Diego Sapriza
- Anton A. Sumin
- Joan Cruz
- inspiran
- Cristobal Dabed
@ -965,6 +979,7 @@ Symfony is the result of the work of many people who made the code better
- Aharon Perkel
- matze
- Abdul.Mohsen B. A. A
- Martin Auswöger
- Benoît Burnichon
- pthompson
- Malaney J. Hill
@ -1010,7 +1025,9 @@ Symfony is the result of the work of many people who made the code better
- Klaas Cuvelier (kcuvelier)
- markusu49
- Steve Frécinaux
- Jules Lamur
- ShiraNai7
- Markus Fasselt (digilist)
- Vašek Purchart (vasek-purchart)
- Janusz Jabłoński (yanoosh)
- Sandro Hopf
@ -1035,17 +1052,16 @@ Symfony is the result of the work of many people who made the code better
- Luis Galeas
- Martin Pärtel
- George Mponos (gmponos)
- Noah Heck (myesain)
- Patrick Daley (padrig)
- Xavier Briand (xavierbriand)
- Max Summe
- WedgeSama
- Felds Liscia
- Ahmed TAILOULOUTE (ahmedtai)
- Maxime Veber (nek-)
- Sullivan SENECHAL
- Tadcka
- Beth Binkovitz
- Gonzalo Míguez
- Romain Geissler
- Adrien Moiruad
- Tomaz Ahlin
@ -1105,7 +1121,6 @@ Symfony is the result of the work of many people who made the code better
- Konrad Mohrfeldt
- Lance Chen
- Andrew (drew)
- Nikolay Labinskiy (e-moe)
- kor3k kor3k (kor3k)
- Stelian Mocanita (stelian)
- Flavian (2much)
@ -1144,11 +1159,9 @@ Symfony is the result of the work of many people who made the code better
- victoria
- Francisco Facioni (fran6co)
- Iwan van Staveren (istaveren)
- Thierry Thuon (lepiaf)
- Povilas S. (povilas)
- pborreli
- Eric Caron
- Richard Bradley
- 2manypeople
- Wing
- Thomas Bibb
@ -1172,6 +1185,7 @@ Symfony is the result of the work of many people who made the code better
- Michal Gebauer
- Gleb Sidora
- David Stone
- Niels Keurentjes (curry684)
- Jovan Perovic (jperovic)
- Pablo Maria Martelletti (pmartelletti)
- Yassine Guedidi (yguedidi)
@ -1229,6 +1243,7 @@ Symfony is the result of the work of many people who made the code better
- Brian Graham (incognito)
- Kevin Vergauwen (innocenzo)
- Alessio Baglio (ioalessio)
- Johannes Müller (johmue)
- Jordi Llonch (jordillonch)
- Cédric Dugat (ph3nol)
- Philip Dahlstrøm (phidah)
@ -1290,6 +1305,7 @@ Symfony is the result of the work of many people who made the code better
- Jérémy M (th3mouk)
- Vincent LEFORT (vlefort)
- Sadicov Vladimir (xtech)
- Kevin EMO (zarcox)
- Alexander Zogheb
- Rémi Blaise
- Joel Marcey
@ -1302,7 +1318,6 @@ Symfony is the result of the work of many people who made the code better
- adenkejawen
- Ari Pringle (apringle)
- Dan Ordille (dordille)
- Dmytro Boiko (eagle)
- Jan Eichhorn (exeu)
- Grégory Pelletier (ip512)
- John Nickell (jrnickell)
@ -1351,7 +1366,6 @@ Symfony is the result of the work of many people who made the code better
- ddebree
- Tomas Liubinas
- Alex
- Patrick Dawkins
- Klaas Naaijkens
- Daniel González Cerviño
- Rafał
@ -1364,7 +1378,6 @@ Symfony is the result of the work of many people who made the code better
- David Joos (djoos)
- Denis Klementjev (dklementjev)
- Tomáš Polívka (draczris)
- Vincent Composieux (eko)
- Franz Liedke (franzliedke)
- Christophe BECKER (goabonga)
- gondo (gondo)
@ -1400,6 +1413,7 @@ Symfony is the result of the work of many people who made the code better
- Curtis
- Gabriel Moreira
- Alexey Popkov
- ChS
- Joseph Deray
- Damian Sromek
- Ben
@ -1438,6 +1452,7 @@ Symfony is the result of the work of many people who made the code better
- znerol
- Christian Eikermann
- Antonio Angelino
- Matt Fields
- Shawn Iwinski
- Niklas Keller
- Vladimir Sazhin
@ -1563,6 +1578,7 @@ Symfony is the result of the work of many people who made the code better
- ibasaw (ibasaw)
- Vladislav Krupenkin (ideea)
- Imangazaliev Muhammad (imangazaliev)
- j0k (j0k)
- joris de wit (jdewit)
- Jérémy CROMBEZ (jeremy)
- Jose Manuel Gonzalez (jgonzalez)

View File

@ -145,13 +145,16 @@ class ArrayNodeDefinitionTest extends TestCase
public function testNestedPrototypedArrayNodes()
{
$node = new ArrayNodeDefinition('root');
$node
$nodeDefinition = new ArrayNodeDefinition('root');
$nodeDefinition
->addDefaultChildrenIfNoneSet()
->prototype('array')
->prototype('array')
;
$node->getNode();
$node = $nodeDefinition->getNode();
$this->assertInstanceOf('Symfony\Component\Config\Definition\PrototypedArrayNode', $node);
$this->assertInstanceOf('Symfony\Component\Config\Definition\PrototypedArrayNode', $node->getPrototype());
}
public function testEnabledNodeDefaults()

View File

@ -71,6 +71,8 @@ class TreeBuilderTest extends TestCase
$root = $builder->root('override', 'array', new CustomNodeBuilder());
$root->prototype('bar')->end();
$this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\BarNode', $root->getNode(true)->getPrototype());
}
public function testAnExtendedNodeBuilderGetsPropagatedToTheChildren()
@ -79,7 +81,7 @@ class TreeBuilderTest extends TestCase
$builder->root('propagation')
->children()
->setNodeClass('extended', 'Symfony\Component\Config\Tests\Definition\Builder\VariableNodeDefinition')
->setNodeClass('extended', 'Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition')
->node('foo', 'extended')->end()
->arrayNode('child')
->children()
@ -88,6 +90,15 @@ class TreeBuilderTest extends TestCase
->end()
->end()
->end();
$node = $builder->buildTree();
$children = $node->getChildren();
$this->assertInstanceOf('Symfony\Component\Config\Definition\BooleanNode', $children['foo']);
$childChildren = $children['child']->getChildren();
$this->assertInstanceOf('Symfony\Component\Config\Definition\BooleanNode', $childChildren['foo']);
}
public function testDefinitionInfoGetsTransferredToNode()

View File

@ -0,0 +1,18 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Config\Tests\Fixtures;
use Symfony\Component\Config\Definition\ArrayNode;
class BarNode extends ArrayNode
{
}

View File

@ -12,10 +12,12 @@
namespace Symfony\Component\Config\Tests\Definition\Builder;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Tests\Fixtures\BarNode;
class BarNodeDefinition extends NodeDefinition
{
protected function createNode()
{
return new BarNode($this->name);
}
}

View File

@ -299,6 +299,8 @@ class CompoundFormTest extends AbstractFormTest
public function testRemoveIgnoresUnknownName()
{
$this->form->remove('notexisting');
$this->assertCount(0, $this->form);
}
public function testArrayAccess()

View File

@ -102,7 +102,9 @@ class ChoiceTypeTest extends BaseTypeTest
public function testChoiceListAndChoicesCanBeEmpty()
{
$this->factory->create(static::TESTED_TYPE);
$this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->create(static::TESTED_TYPE, null, array(
'choices_as_values' => true,
)));
}
public function testExpandedChoicesOptionsTurnIntoChildren()
@ -1705,9 +1707,9 @@ class ChoiceTypeTest extends BaseTypeTest
// https://github.com/symfony/symfony/issues/3298
public function testInitializeWithEmptyChoices()
{
$this->factory->createNamed('name', static::TESTED_TYPE, null, array(
$this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->createNamed('name', static::TESTED_TYPE, null, array(
'choices' => array(),
));
)));
}
public function testInitializeWithDefaultObjectChoice()

View File

@ -43,11 +43,13 @@ class CountryTypeTest extends BaseTypeTest
$choices = $this->factory->create(static::TESTED_TYPE, 'country')
->createView()->vars['choices'];
$countryCodes = array();
foreach ($choices as $choice) {
if ('ZZ' === $choice->value) {
$this->fail('Should not contain choice "ZZ"');
}
$countryCodes[] = $choice->value;
}
$this->assertNotContains('ZZ', $countryCodes);
}
public function testSubmitNull($expected = null, $norm = null, $view = null)

View File

@ -273,7 +273,7 @@ class DateTimeTypeTest extends BaseTypeTest
{
// Throws an exception if "data_class" option is not explicitly set
// to null in the type
$this->factory->create(static::TESTED_TYPE, new \DateTime());
$this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->create(static::TESTED_TYPE, new \DateTime()));
}
public function testSingleTextWidgetShouldUseTheRightInputType()

View File

@ -711,7 +711,7 @@ class DateTypeTest extends BaseTypeTest
{
// Throws an exception if "data_class" option is not explicitly set
// to null in the type
$this->factory->create(static::TESTED_TYPE, new \DateTime());
$this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->create(static::TESTED_TYPE, new \DateTime()));
}
public function testSingleTextWidgetShouldUseTheRightInputType()

View File

@ -141,23 +141,23 @@ class FormTypeTest extends BaseTypeTest
public function testDataClassMayBeNull()
{
$this->factory->createBuilder(static::TESTED_TYPE, null, array(
$this->assertInstanceOf('Symfony\Component\Form\FormBuilderInterface', $this->factory->createBuilder(static::TESTED_TYPE, null, array(
'data_class' => null,
));
)));
}
public function testDataClassMayBeAbstractClass()
{
$this->factory->createBuilder(static::TESTED_TYPE, null, array(
$this->assertInstanceOf('Symfony\Component\Form\FormBuilderInterface', $this->factory->createBuilder(static::TESTED_TYPE, null, array(
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AbstractAuthor',
));
)));
}
public function testDataClassMayBeInterface()
{
$this->factory->createBuilder(static::TESTED_TYPE, null, array(
$this->assertInstanceOf('Symfony\Component\Form\FormBuilderInterface', $this->factory->createBuilder(static::TESTED_TYPE, null, array(
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AuthorInterface',
));
)));
}
/**

View File

@ -488,7 +488,7 @@ class TimeTypeTest extends BaseTypeTest
{
// Throws an exception if "data_class" option is not explicitly set
// to null in the type
$this->factory->create(static::TESTED_TYPE, new \DateTime());
$this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->create(static::TESTED_TYPE, new \DateTime()));
}
public function testSingleTextWidgetShouldUseTheRightInputType()

View File

@ -62,21 +62,21 @@ class DependencyInjectionExtensionTest extends TestCase
*/
public function testThrowExceptionForInvalidExtendedType()
{
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$formTypeExtension = $this->createFormTypeExtensionMock('unmatched');
$typeExtension = $this->getMockBuilder('Symfony\Component\Form\FormTypeExtensionInterface')->getMock();
$typeExtension->expects($this->any())
->method('getExtendedType')
->willReturn('unmatched');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->any())
->method('get')
->with('extension')
->willReturn($typeExtension);
->willReturn($formTypeExtension);
$extension = new DependencyInjectionExtension($container, array(), array('test' => array('extension')), array());
$extension->getTypeExtensions('test');
$extensions = $extension->getTypeExtensions('test');
$this->assertCount(1, $extensions);
$this->assertSame($formTypeExtension, $extensions[0]);
}
public function testGetTypeGuesser()

View File

@ -161,6 +161,8 @@ class FormBuilderTest extends TestCase
{
$this->builder->add(new ButtonBuilder('reset'));
$this->builder->add(new SubmitButtonBuilder('submit'));
$this->assertCount(2, $this->builder->all());
}
public function testGetUnknown()

View File

@ -12,9 +12,7 @@
namespace Symfony\Component\Form\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\FormConfigBuilder;
use Symfony\Component\Form\Exception\InvalidArgumentException;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
@ -24,72 +22,65 @@ class FormConfigTest extends TestCase
public function getHtml4Ids()
{
return array(
array('z0', true),
array('A0', true),
array('A9', true),
array('Z0', true),
array('#', false),
array('a#', false),
array('a$', false),
array('a%', false),
array('a ', false),
array("a\t", false),
array("a\n", false),
array('a-', true),
array('a_', true),
array('a:', true),
array('z0'),
array('A0'),
array('A9'),
array('Z0'),
array('#', 'Symfony\Component\Form\Exception\InvalidArgumentException'),
array('a#', 'Symfony\Component\Form\Exception\InvalidArgumentException'),
array('a$', 'Symfony\Component\Form\Exception\InvalidArgumentException'),
array('a%', 'Symfony\Component\Form\Exception\InvalidArgumentException'),
array('a ', 'Symfony\Component\Form\Exception\InvalidArgumentException'),
array("a\t", 'Symfony\Component\Form\Exception\InvalidArgumentException'),
array("a\n", 'Symfony\Component\Form\Exception\InvalidArgumentException'),
array('a-'),
array('a_'),
array('a:'),
// Periods are allowed by the HTML4 spec, but disallowed by us
// because they break the generated property paths
array('a.', false),
array('a.', 'Symfony\Component\Form\Exception\InvalidArgumentException'),
// Contrary to the HTML4 spec, we allow names starting with a
// number, otherwise naming fields by collection indices is not
// possible.
// For root forms, leading digits will be stripped from the
// "id" attribute to produce valid HTML4.
array('0', true),
array('9', true),
array('0'),
array('9'),
// Contrary to the HTML4 spec, we allow names starting with an
// underscore, since this is already a widely used practice in
// Symfony.
// For root forms, leading underscores will be stripped from the
// "id" attribute to produce valid HTML4.
array('_', true),
array('_'),
// Integers are allowed
array(0, true),
array(123, true),
array(0),
array(123),
// NULL is allowed
array(null, true),
array(null),
// Other types are not
array(1.23, false),
array(5., false),
array(true, false),
array(new \stdClass(), false),
array(1.23, 'Symfony\Component\Form\Exception\UnexpectedTypeException'),
array(5., 'Symfony\Component\Form\Exception\UnexpectedTypeException'),
array(true, 'Symfony\Component\Form\Exception\UnexpectedTypeException'),
array(new \stdClass(), 'Symfony\Component\Form\Exception\UnexpectedTypeException'),
);
}
/**
* @dataProvider getHtml4Ids
*/
public function testNameAcceptsOnlyNamesValidAsIdsInHtml4($name, $accepted)
public function testNameAcceptsOnlyNamesValidAsIdsInHtml4($name, $expectedException = null)
{
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
try {
new FormConfigBuilder($name, null, $dispatcher);
if (!$accepted) {
$this->fail(sprintf('The value "%s" should not be accepted', $name));
}
} catch (UnexpectedTypeException $e) {
// if the value was not accepted, but should be, rethrow exception
if ($accepted) {
throw $e;
}
} catch (InvalidArgumentException $e) {
// if the value was not accepted, but should be, rethrow exception
if ($accepted) {
throw $e;
}
if (null !== $expectedException && method_exists($this, 'expectException')) {
$this->expectException($expectedException);
} elseif (null !== $expectedException) {
$this->setExpectedException($expectedException);
}
$formConfigBuilder = new FormConfigBuilder($name, null, $dispatcher);
$this->assertSame((string) $name, $formConfigBuilder->getName());
}
public function testGetRequestHandlerCreatesNativeRequestHandlerIfNotSet()
@ -109,27 +100,42 @@ class FormConfigTest extends TestCase
public function testSetMethodAllowsGet()
{
$this->getConfigBuilder()->setMethod('GET');
$formConfigBuilder = $this->getConfigBuilder();
$formConfigBuilder->setMethod('GET');
self::assertSame('GET', $formConfigBuilder->getMethod());
}
public function testSetMethodAllowsPost()
{
$this->getConfigBuilder()->setMethod('POST');
$formConfigBuilder = $this->getConfigBuilder();
$formConfigBuilder->setMethod('POST');
self::assertSame('POST', $formConfigBuilder->getMethod());
}
public function testSetMethodAllowsPut()
{
$this->getConfigBuilder()->setMethod('PUT');
$formConfigBuilder = $this->getConfigBuilder();
$formConfigBuilder->setMethod('PUT');
self::assertSame('PUT', $formConfigBuilder->getMethod());
}
public function testSetMethodAllowsDelete()
{
$this->getConfigBuilder()->setMethod('DELETE');
$formConfigBuilder = $this->getConfigBuilder();
$formConfigBuilder->setMethod('DELETE');
self::assertSame('DELETE', $formConfigBuilder->getMethod());
}
public function testSetMethodAllowsPatch()
{
$this->getConfigBuilder()->setMethod('PATCH');
$formConfigBuilder = $this->getConfigBuilder();
$formConfigBuilder->setMethod('PATCH');
self::assertSame('PATCH', $formConfigBuilder->getMethod());
}
/**

View File

@ -912,10 +912,11 @@ class SimpleFormTest extends AbstractFormTest
public function testSubmittingWrongDataIsIgnored()
{
$called = 0;
$child = $this->getBuilder('child', $this->dispatcher);
$child->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
// child form doesn't receive the wrong data that is submitted on parent
$this->assertNull($event->getData());
$child->addEventListener(FormEvents::PRE_SUBMIT, function () use (&$called) {
++$called;
});
$parent = $this->getBuilder('parent', new EventDispatcher())
@ -925,6 +926,8 @@ class SimpleFormTest extends AbstractFormTest
->getForm();
$parent->submit('not-an-array');
$this->assertSame(0, $called, 'PRE_SUBMIT event listeners are not called for wrong data');
}
public function testHandleRequestForwardsToRequestHandler()
@ -1027,14 +1030,17 @@ class SimpleFormTest extends AbstractFormTest
public function testSubmitIsNeverFiredIfInheritData()
{
$called = 0;
$form = $this->getBuilder()
->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
$this->fail('The SUBMIT event should not be fired');
->addEventListener(FormEvents::SUBMIT, function () use (&$called) {
++$called;
})
->setInheritData(true)
->getForm();
$form->submit('foo');
$this->assertSame(0, $called, 'The SUBMIT event is not fired when data are inherited from the parent form');
}
public function testInitializeSetsDefaultData()

View File

@ -114,8 +114,11 @@ class OrderedHashMapTest extends TestCase
public function testUnsetNonExistingSucceeds()
{
$map = new OrderedHashMap();
$map['second'] = 2;
unset($map['first']);
$this->assertSame(array('second' => 2), iterator_to_array($map));
}
public function testEmptyIteration()

View File

@ -17,14 +17,14 @@ use Symfony\Component\HttpFoundation\IpUtils;
class IpUtilsTest extends TestCase
{
/**
* @dataProvider testIpv4Provider
* @dataProvider getIpv4Data
*/
public function testIpv4($matches, $remoteAddr, $cidr)
{
$this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr));
}
public function testIpv4Provider()
public function getIpv4Data()
{
return array(
array(true, '192.168.1.1', '192.168.1.1'),
@ -43,7 +43,7 @@ class IpUtilsTest extends TestCase
}
/**
* @dataProvider testIpv6Provider
* @dataProvider getIpv6Data
*/
public function testIpv6($matches, $remoteAddr, $cidr)
{
@ -54,7 +54,7 @@ class IpUtilsTest extends TestCase
$this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr));
}
public function testIpv6Provider()
public function getIpv6Data()
{
return array(
array(true, '2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'),

View File

@ -18,7 +18,7 @@ use Symfony\Component\HttpFoundation\Request;
class RequestMatcherTest extends TestCase
{
/**
* @dataProvider testMethodFixtures
* @dataProvider getMethodData
*/
public function testMethod($requestMethod, $matcherMethod, $isMatch)
{
@ -32,7 +32,7 @@ class RequestMatcherTest extends TestCase
$this->assertSame($isMatch, $matcher->matches($request));
}
public function testMethodFixtures()
public function getMethodData()
{
return array(
array('get', 'get', true),
@ -64,7 +64,7 @@ class RequestMatcherTest extends TestCase
}
/**
* @dataProvider testHostFixture
* @dataProvider getHostData
*/
public function testHost($pattern, $isMatch)
{
@ -78,7 +78,7 @@ class RequestMatcherTest extends TestCase
$this->assertSame($isMatch, $matcher->matches($request));
}
public function testHostFixture()
public function getHostData()
{
return array(
array('.*\.example\.com', true),

View File

@ -306,6 +306,10 @@ class RequestTest extends TestCase
$request->setFormat($format, $mimeTypes);
foreach ($mimeTypes as $mime) {
$this->assertEquals($format, $request->getFormat($mime));
if (null !== $format) {
$this->assertEquals($mimeTypes[0], $request->getMimeType($format));
}
}
}
@ -838,7 +842,7 @@ class RequestTest extends TestCase
}
/**
* @dataProvider testGetClientIpsProvider
* @dataProvider getClientIpsProvider
*/
public function testGetClientIp($expected, $remoteAddr, $httpForwardedFor, $trustedProxies)
{
@ -850,7 +854,7 @@ class RequestTest extends TestCase
}
/**
* @dataProvider testGetClientIpsProvider
* @dataProvider getClientIpsProvider
*/
public function testGetClientIps($expected, $remoteAddr, $httpForwardedFor, $trustedProxies)
{
@ -862,7 +866,7 @@ class RequestTest extends TestCase
}
/**
* @dataProvider testGetClientIpsForwardedProvider
* @dataProvider getClientIpsForwardedProvider
*/
public function testGetClientIpsForwarded($expected, $remoteAddr, $httpForwarded, $trustedProxies)
{
@ -873,7 +877,7 @@ class RequestTest extends TestCase
Request::setTrustedProxies(array());
}
public function testGetClientIpsForwardedProvider()
public function getClientIpsForwardedProvider()
{
// $expected $remoteAddr $httpForwarded $trustedProxies
return array(
@ -886,7 +890,7 @@ class RequestTest extends TestCase
);
}
public function testGetClientIpsProvider()
public function getClientIpsProvider()
{
// $expected $remoteAddr $httpForwardedFor $trustedProxies
return array(
@ -943,7 +947,7 @@ class RequestTest extends TestCase
/**
* @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
* @dataProvider testGetClientIpsWithConflictingHeadersProvider
* @dataProvider getClientIpsWithConflictingHeadersProvider
*/
public function testGetClientIpsWithConflictingHeaders($httpForwarded, $httpXForwardedFor)
{
@ -962,7 +966,7 @@ class RequestTest extends TestCase
$request->getClientIps();
}
public function testGetClientIpsWithConflictingHeadersProvider()
public function getClientIpsWithConflictingHeadersProvider()
{
// $httpForwarded $httpXForwardedFor
return array(
@ -975,9 +979,9 @@ class RequestTest extends TestCase
}
/**
* @dataProvider testGetClientIpsWithAgreeingHeadersProvider
* @dataProvider getClientIpsWithAgreeingHeadersProvider
*/
public function testGetClientIpsWithAgreeingHeaders($httpForwarded, $httpXForwardedFor)
public function testGetClientIpsWithAgreeingHeaders($httpForwarded, $httpXForwardedFor, $expectedIps)
{
$request = new Request();
@ -991,21 +995,23 @@ class RequestTest extends TestCase
$request->initialize(array(), array(), array(), array(), array(), $server);
$request->getClientIps();
$clientIps = $request->getClientIps();
Request::setTrustedProxies(array());
$this->assertSame($expectedIps, $clientIps);
}
public function testGetClientIpsWithAgreeingHeadersProvider()
public function getClientIpsWithAgreeingHeadersProvider()
{
// $httpForwarded $httpXForwardedFor
return array(
array('for="192.0.2.60"', '192.0.2.60'),
array('for=192.0.2.60, for=87.65.43.21', '192.0.2.60,87.65.43.21'),
array('for="[::face]", for=192.0.2.60', '::face,192.0.2.60'),
array('for="192.0.2.60:80"', '192.0.2.60'),
array('for=192.0.2.60;proto=http;by=203.0.113.43', '192.0.2.60'),
array('for="[2001:db8:cafe::17]:4711"', '2001:db8:cafe::17'),
array('for="192.0.2.60"', '192.0.2.60', array('192.0.2.60')),
array('for=192.0.2.60, for=87.65.43.21', '192.0.2.60,87.65.43.21', array('87.65.43.21', '192.0.2.60')),
array('for="[::face]", for=192.0.2.60', '::face,192.0.2.60', array('192.0.2.60', '::face')),
array('for="192.0.2.60:80"', '192.0.2.60', array('192.0.2.60')),
array('for=192.0.2.60;proto=http;by=203.0.113.43', '192.0.2.60', array('192.0.2.60')),
array('for="[2001:db8:cafe::17]:4711"', '2001:db8:cafe::17', array('2001:db8:cafe::17')),
);
}

View File

@ -177,6 +177,8 @@ class SessionTest extends TestCase
{
$this->session->start();
$this->session->save();
$this->assertFalse($this->session->isStarted());
}
public function testGetId()

View File

@ -103,6 +103,9 @@ class MetadataBagTest extends TestCase
public function testClear()
{
$this->bag->clear();
// the clear method has no side effects, we just want to ensure it doesn't trigger any exceptions
$this->addToAssertionCount(1);
}
public function testSkipLastUsedUpdate()

View File

@ -51,10 +51,12 @@ class StreamedResponseTest extends TestCase
public function testPrepareWithHeadRequest()
{
$response = new StreamedResponse(function () { echo 'foo'; });
$response = new StreamedResponse(function () { echo 'foo'; }, 200, array('Content-Length' => '123'));
$request = Request::create('/', 'HEAD');
$response->prepare($request);
$this->assertSame('123', $response->headers->get('Content-Length'));
}
public function testPrepareWithCacheHeaders()

View File

@ -81,7 +81,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
if (!$propertyName || isset($properties[$propertyName])) {
continue;
}
if (!preg_match('/^[A-Z]{2,}/', $propertyName)) {
if (!$reflectionClass->hasProperty($propertyName) && !preg_match('/^[A-Z]{2,}/', $propertyName)) {
$propertyName = lcfirst($propertyName);
}
$properties[$propertyName] = true;

View File

@ -39,6 +39,7 @@ class ReflectionExtractorTest extends TestCase
'parent',
'collection',
'B',
'Guid',
'g',
'foo',
'foo2',
@ -48,6 +49,7 @@ class ReflectionExtractorTest extends TestCase
'files',
'a',
'DOB',
'Id',
'c',
'd',
'e',
@ -130,6 +132,10 @@ class ReflectionExtractorTest extends TestCase
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'd', array()));
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'e', array()));
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'f', array()));
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Id', array()));
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'id', array()));
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Guid', array()));
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'guid', array()));
}
public function testIsWritable()
@ -143,6 +149,9 @@ class ReflectionExtractorTest extends TestCase
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'd', array()));
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'e', array()));
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'f', array()));
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Id', array()));
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Guid', array()));
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'guid', array()));
}
public function testSingularize()

View File

@ -51,6 +51,16 @@ class Dummy extends ParentDummy
*/
public $B;
/**
* @var int
*/
protected $Id;
/**
* @var string
*/
public $Guid;
/**
* Nullable array.
*
@ -99,4 +109,11 @@ class Dummy extends ParentDummy
public function getDOB()
{
}
/**
* @return int
*/
public function getId()
{
}
}

View File

@ -39,11 +39,20 @@ class BCryptPasswordEncoderTest extends TestCase
new BCryptPasswordEncoder(32);
}
public function testCostInRange()
/**
* @dataProvider validRangeData
*/
public function testCostInRange($cost)
{
for ($cost = 4; $cost <= 31; ++$cost) {
new BCryptPasswordEncoder($cost);
}
$this->assertInstanceOf('Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder', new BCryptPasswordEncoder($cost));
}
public function validRangeData()
{
$costs = range(4, 31);
array_walk($costs, function (&$cost) { $cost = array($cost); });
return $costs;
}
public function testResultLength()

View File

@ -100,6 +100,9 @@ class DigestDataTest extends TestCase
$this->assertEquals('"u\\ser"', $digestAuth->getUsername());
}
/**
* @group time-sensitive
*/
public function testValidateAndDecode()
{
$time = microtime(true);
@ -112,11 +115,11 @@ class DigestDataTest extends TestCase
'response="b52938fc9e6d7c01be7702ece9031b42"'
);
try {
$digestAuth->validateAndDecode($key, 'Welcome, robot!');
} catch (\Exception $e) {
$this->fail(sprintf('testValidateAndDecode fail with message: %s', $e->getMessage()));
}
$digestAuth->validateAndDecode($key, 'Welcome, robot!');
sleep(1);
$this->assertTrue($digestAuth->isNonceExpired());
}
public function testCalculateServerDigest()