Merge branch '2.7' into 2.8
* 2.7: [HttpKernel] fixed internal subrequests having an if-modified-since-header [Validator] Added additional MasterCard range to the CardSchemeValidator Make the exception message more clear. [Form] fixed bug - name in ButtonBuilder [ClassLoader] Fix declared classes being computed when not needed
This commit is contained in:
commit
1f2d6fb590
@ -43,12 +43,12 @@ class ClassCollectionLoader
|
|||||||
|
|
||||||
self::$loaded[$name] = true;
|
self::$loaded[$name] = true;
|
||||||
|
|
||||||
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
|
|
||||||
if (function_exists('get_declared_traits')) {
|
|
||||||
$declared = array_merge($declared, get_declared_traits());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($adaptive) {
|
if ($adaptive) {
|
||||||
|
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
|
||||||
|
if (function_exists('get_declared_traits')) {
|
||||||
|
$declared = array_merge($declared, get_declared_traits());
|
||||||
|
}
|
||||||
|
|
||||||
// don't include already declared classes
|
// don't include already declared classes
|
||||||
$classes = array_diff($classes, $declared);
|
$classes = array_diff($classes, $declared);
|
||||||
|
|
||||||
@ -87,11 +87,17 @@ class ClassCollectionLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$reload && is_file($cache)) {
|
if (!$reload && file_exists($cache)) {
|
||||||
require_once $cache;
|
require_once $cache;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!$adaptive) {
|
||||||
|
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
|
||||||
|
if (function_exists('get_declared_traits')) {
|
||||||
|
$declared = array_merge($declared, get_declared_traits());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$files = array();
|
$files = array();
|
||||||
$content = '';
|
$content = '';
|
||||||
|
@ -62,11 +62,12 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
|
|||||||
*/
|
*/
|
||||||
public function __construct($name, array $options = array())
|
public function __construct($name, array $options = array())
|
||||||
{
|
{
|
||||||
if (empty($name) && 0 != $name) {
|
$name = (string) $name;
|
||||||
|
if ('' === $name) {
|
||||||
throw new InvalidArgumentException('Buttons cannot have empty names.');
|
throw new InvalidArgumentException('Buttons cannot have empty names.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->name = (string) $name;
|
$this->name = $name;
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
61
src/Symfony/Component/Form/Tests/ButtonBuilderTest.php
Normal file
61
src/Symfony/Component/Form/Tests/ButtonBuilderTest.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?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\Form\Tests;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\ButtonBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Alexander Cheprasov <cheprasov.84@ya.ru>
|
||||||
|
*/
|
||||||
|
class ButtonBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function getValidNames()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('reset'),
|
||||||
|
array('submit'),
|
||||||
|
array('foo'),
|
||||||
|
array('0'),
|
||||||
|
array(0),
|
||||||
|
array('button[]'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider getValidNames
|
||||||
|
*/
|
||||||
|
public function testValidNames($name)
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder($name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInvalidNames()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(''),
|
||||||
|
array(false),
|
||||||
|
array(null),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider getInvalidNames
|
||||||
|
*/
|
||||||
|
public function testInvalidNames($name)
|
||||||
|
{
|
||||||
|
$this->setExpectedException(
|
||||||
|
'\Symfony\Component\Form\Exception\InvalidArgumentException',
|
||||||
|
'Buttons cannot have empty names.'
|
||||||
|
);
|
||||||
|
new ButtonBuilder($name);
|
||||||
|
}
|
||||||
|
}
|
@ -129,6 +129,8 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
$server['REMOTE_ADDR'] = '127.0.0.1';
|
$server['REMOTE_ADDR'] = '127.0.0.1';
|
||||||
|
unset($server['HTTP_IF_MODIFIED_SINCE']);
|
||||||
|
unset($server['HTTP_IF_NONE_MATCH']);
|
||||||
|
|
||||||
$subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server);
|
$subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server);
|
||||||
if ($request->headers->has('Surrogate-Capability')) {
|
if ($request->headers->has('Surrogate-Capability')) {
|
||||||
|
@ -197,6 +197,19 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
|
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest()
|
||||||
|
{
|
||||||
|
$expectedSubRequest = Request::create('/');
|
||||||
|
if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
|
||||||
|
$expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
|
||||||
|
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
|
||||||
|
}
|
||||||
|
|
||||||
|
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
|
||||||
|
$request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*'));
|
||||||
|
$strategy->render('/', $request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bar
|
class Bar
|
||||||
|
@ -74,8 +74,10 @@ class CardSchemeValidator extends ConstraintValidator
|
|||||||
'/^6[0-9]{11,18}$/',
|
'/^6[0-9]{11,18}$/',
|
||||||
),
|
),
|
||||||
// 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.
|
||||||
|
// October 2016 MasterCard numbers can also start with 222100 through 272099.
|
||||||
'MASTERCARD' => array(
|
'MASTERCARD' => array(
|
||||||
'/^5[1-5][0-9]{14}$/',
|
'/^5[1-5][0-9]{14}$/',
|
||||||
|
'/^2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12})$/',
|
||||||
),
|
),
|
||||||
// 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(
|
'VISA' => array(
|
||||||
|
@ -39,7 +39,7 @@ class PropertyMetadata extends MemberMetadata
|
|||||||
public function __construct($class, $name)
|
public function __construct($class, $name)
|
||||||
{
|
{
|
||||||
if (!property_exists($class, $name)) {
|
if (!property_exists($class, $name)) {
|
||||||
throw new ValidatorException(sprintf('Property %s does not exist in class %s', $name, $class));
|
throw new ValidatorException(sprintf('Property "%s" does not exist in class "%s"', $name, $class));
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct($class, $name, $name);
|
parent::__construct($class, $name, $name);
|
||||||
|
@ -102,6 +102,12 @@ class CardSchemeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
array('MAESTRO', '6594371785970435599'),
|
array('MAESTRO', '6594371785970435599'),
|
||||||
array('MASTERCARD', '5555555555554444'),
|
array('MASTERCARD', '5555555555554444'),
|
||||||
array('MASTERCARD', '5105105105105100'),
|
array('MASTERCARD', '5105105105105100'),
|
||||||
|
array('MASTERCARD', '2221005555554444'),
|
||||||
|
array('MASTERCARD', '2230000000000000'),
|
||||||
|
array('MASTERCARD', '2300000000000000'),
|
||||||
|
array('MASTERCARD', '2699999999999999'),
|
||||||
|
array('MASTERCARD', '2709999999999999'),
|
||||||
|
array('MASTERCARD', '2720995105105100'),
|
||||||
array('VISA', '4111111111111111'),
|
array('VISA', '4111111111111111'),
|
||||||
array('VISA', '4012888888881881'),
|
array('VISA', '4012888888881881'),
|
||||||
array('VISA', '4222222222222'),
|
array('VISA', '4222222222222'),
|
||||||
@ -129,6 +135,8 @@ class CardSchemeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
array('AMEX', '000000000000', CardScheme::INVALID_FORMAT_ERROR), // a lone number
|
array('AMEX', '000000000000', CardScheme::INVALID_FORMAT_ERROR), // a lone number
|
||||||
array('DINERS', '3056930', CardScheme::INVALID_FORMAT_ERROR), // only first part of the number
|
array('DINERS', '3056930', CardScheme::INVALID_FORMAT_ERROR), // only first part of the number
|
||||||
array('DISCOVER', '1117', CardScheme::INVALID_FORMAT_ERROR), // only last 4 digits
|
array('DISCOVER', '1117', CardScheme::INVALID_FORMAT_ERROR), // only last 4 digits
|
||||||
|
array('MASTERCARD', '2721001234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet
|
||||||
|
array('MASTERCARD', '2220991234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user