Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '2.1'

* 2.1:
  fixed CS
  fixed CS
  [Security] fixed path info encoding (closes #6040, closes #5695)
  [HttpFoundation] added some tests for the previous merge and removed dead code (closes #6037)
  Improved Cache-Control header when no-cache is sent
  removed unneeded comment
  Fix to allow null values in labels array
  fix date in changelog
  removed the Travis icon (as this is not stable enough -- many false positive, closes #6186)
  Revert "merged branch gajdaw/finder_splfileinfo_fpassthu (PR #4751)" (closes #6224)
  Fixed a typo
  Fixed: HeaderBag::parseCacheControl() not parsing quoted zero correctly
  [Form] Fix const inside an anonymous function
  [Config] Loader::import must return imported data
  [DoctrineBridge] Fixed caching in DoctrineType when "choices" or "preferred_choices" is passed
  [Form] Fixed the default value of "format" in DateType to DateType::DEFAULT_FORMAT if "widget" is not "single_text"
  [HttpFoundation] fixed a small regression

Conflicts:
	src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
  • Loading branch information...
commit 3c010db2cb61876092f571894c6794c0ecf260eb 2 parents f25750e + 7f3be5c
@fabpot fabpot authored
Showing with 183 additions and 86 deletions.
  1. +1 −1  CHANGELOG-2.1.md
  2. +0 −2  README.md
  3. +4 −4 src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
  4. +1 −1  src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
  5. +43 −2 src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
  6. +0 −1  src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
  7. +1 −1  src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
  8. +2 −2 src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php
  9. +3 −1 src/Symfony/Component/Config/Loader/Loader.php
  10. +9 −0 src/Symfony/Component/Config/Tests/Loader/LoaderTest.php
  11. +0 −1  src/Symfony/Component/Console/Tests/ApplicationTest.php
  12. +0 −1  src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php
  13. +0 −2  src/Symfony/Component/CssSelector/Node/FunctionNode.php
  14. +3 −3 src/Symfony/Component/Filesystem/Filesystem.php
  15. +8 −4 src/Symfony/Component/Finder/SplFileInfo.php
  16. +1 −1  src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php
  17. +0 −1  src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php
  18. +5 −1 src/Symfony/Component/Form/Extension/Core/Type/DateType.php
  19. +1 −1  src/Symfony/Component/Form/Extension/Core/Type/FileType.php
  20. +1 −1  src/Symfony/Component/Form/Guess/Guess.php
  21. +32 −32 src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
  22. +13 −0 src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php
  23. +0 −1  src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php
  24. +3 −3 src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php
  25. +0 −2  src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
  26. +1 −1  src/Symfony/Component/HttpFoundation/HeaderBag.php
  27. +1 −1  src/Symfony/Component/HttpFoundation/Request.php
  28. +0 −1  src/Symfony/Component/HttpFoundation/RequestMatcher.php
  29. +6 −0 src/Symfony/Component/HttpFoundation/Response.php
  30. +7 −0 src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php
  31. +17 −0 src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
  32. +1 −0  src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php
  33. +1 −2  src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php
  34. +7 −4 src/Symfony/Component/Locale/Resources/data/build-data.php
  35. +1 −2  src/Symfony/Component/Process/Tests/AbstractProcessTest.php
  36. +0 −1  src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php
  37. +1 −0  src/Symfony/Component/Security/Http/Firewall/ContextListener.php
  38. +1 −1  src/Symfony/Component/Security/Http/HttpUtils.php
  39. +5 −0 src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php
  40. +2 −2 src/Symfony/Component/Validator/Constraints/Regex.php
  41. +1 −2  src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php
View
2  CHANGELOG-2.1.md
@@ -7,7 +7,7 @@ in 2.1 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.1.0...v2.1.1
-* 2.1.4 (2012-12-29)
+* 2.1.4 (2012-11-29)
* e5536f0: replaced magic strings by proper constants
* 6a3ba52: fixed the logic in Request::isSecure() (if the information comes from a source that we trust, don't check other ones)
View
2  README.md
@@ -1,8 +1,6 @@
README
======
-[![Build Status](https://secure.travis-ci.org/symfony/symfony.png?branch=master)](http://travis-ci.org/symfony/symfony)
-
What is Symfony2?
-----------------
View
8 src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
@@ -77,16 +77,16 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
// A second parameter ($key) is passed, so we cannot use
// spl_object_hash() directly (which strictly requires
// one parameter)
- array_walk_recursive($choiceHashes, function ($value) {
- return spl_object_hash($value);
+ array_walk_recursive($choiceHashes, function (&$value) {
+ $value = spl_object_hash($value);
});
}
$preferredChoiceHashes = $options['preferred_choices'];
if (is_array($preferredChoiceHashes)) {
- array_walk_recursive($preferredChoiceHashes, function ($value) {
- return spl_object_hash($value);
+ array_walk_recursive($preferredChoiceHashes, function (&$value) {
+ $value = spl_object_hash($value);
});
}
View
2  src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
@@ -86,4 +86,4 @@ private function getGuesser(ClassMetadata $classMetadata)
return new DoctrineOrmTypeGuesser($registry);
}
-}
+}
View
45 src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
@@ -104,7 +104,7 @@ public function testCollapsedEntityField()
{
$this->setMaxRunningTime(1);
- for ($i = 0; $i < 20; ++$i) {
+ for ($i = 0; $i < 40; ++$i) {
$form = $this->factory->create('entity', null, array(
'class' => self::ENTITY_CLASS,
));
@@ -114,11 +114,14 @@ public function testCollapsedEntityField()
}
}
+ /**
+ * @group benchmark
+ */
public function testCollapsedEntityFieldWithQueryBuilder()
{
$this->setMaxRunningTime(1);
- for ($i = 0; $i < 20; ++$i) {
+ for ($i = 0; $i < 40; ++$i) {
$form = $this->factory->create('entity', null, array(
'class' => self::ENTITY_CLASS,
'query_builder' => function (EntityRepository $repo) {
@@ -130,4 +133,42 @@ public function testCollapsedEntityFieldWithQueryBuilder()
$form->createView();
}
}
+
+ /**
+ * @group benchmark
+ */
+ public function testCollapsedEntityFieldWithChoices()
+ {
+ $choices = $this->em->createQuery('SELECT c FROM ' . self::ENTITY_CLASS . ' c')->getResult();
+ $this->setMaxRunningTime(1);
+
+ for ($i = 0; $i < 40; ++$i) {
+ $form = $this->factory->create('entity', null, array(
+ 'class' => self::ENTITY_CLASS,
+ 'choices' => $choices,
+ ));
+
+ // force loading of the choice list
+ $form->createView();
+ }
+ }
+
+ /**
+ * @group benchmark
+ */
+ public function testCollapsedEntityFieldWithPreferredChoices()
+ {
+ $choices = $this->em->createQuery('SELECT c FROM ' . self::ENTITY_CLASS . ' c')->getResult();
+ $this->setMaxRunningTime(1);
+
+ for ($i = 0; $i < 40; ++$i) {
+ $form = $this->factory->create('entity', null, array(
+ 'class' => self::ENTITY_CLASS,
+ 'preferred_choices' => $choices,
+ ));
+
+ // force loading of the choice list
+ $form->createView();
+ }
+ }
}
View
1  src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
@@ -11,7 +11,6 @@
namespace Symfony\Bridge\Doctrine\Tests\Logger;
-
class DbalLoggerTest extends \PHPUnit_Framework_TestCase
{
/**
View
2  src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
@@ -78,7 +78,7 @@ public function redirect($url, $status = 302)
* @param string $view The view name
* @param array $parameters An array of parameters to pass to the view
*
- * @return string The renderer view
+ * @return string The rendered view
*/
public function renderView($view, array $parameters = array())
{
View
4 src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php
@@ -23,7 +23,7 @@ public function values(array $values)
}
$this->values = $values;
-
+
return $this;
}
@@ -40,4 +40,4 @@ protected function instantiateNode()
return new EnumNode($this->name, $this->parent, $this->values);
}
-}
+}
View
4 src/Symfony/Component/Config/Loader/Loader.php
@@ -47,10 +47,12 @@ public function setResolver(LoaderResolverInterface $resolver)
*
* @param mixed $resource A Resource
* @param string $type The resource type
+ *
+ * @return mixed
*/
public function import($resource, $type = null)
{
- $this->resolve($resource)->load($resource, $type);
+ return $this->resolve($resource)->load($resource, $type);
}
/**
View
9 src/Symfony/Component/Config/Tests/Loader/LoaderTest.php
@@ -55,6 +55,15 @@ public function testResolve()
$this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderLoadException', $e, '->resolve() throws a FileLoaderLoadException if the resource cannot be loaded');
}
}
+
+ public function testImport()
+ {
+ $loader = $this->getMock('Symfony\Component\Config\Loader\Loader', array('supports', 'load'));
+ $loader->expects($this->once())->method('supports')->will($this->returnValue(true));
+ $loader->expects($this->once())->method('load')->will($this->returnValue('yes'));
+
+ $this->assertEquals('yes', $loader->import('foo'));
+ }
}
class ProjectLoader1 extends Loader
View
1  src/Symfony/Component/Console/Tests/ApplicationTest.php
@@ -242,7 +242,6 @@ public function testFindAlternativeExceptionMessage()
$this->assertRegExp('/Did you mean this/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with one alternative');
}
-
$application->add(new \Foo1Command());
$application->add(new \Foo2Command());
View
1  src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php
@@ -9,7 +9,6 @@
* file that was distributed with this source code.
*/
-
namespace Symfony\Component\Console\Tests\Formatter;
use Symfony\Component\Console\Formatter\OutputFormatter;
View
2  src/Symfony/Component/CssSelector/Node/FunctionNode.php
@@ -209,7 +209,6 @@ protected function _xpath_contains($xpath, $expr)
$xpath->addCondition(sprintf('contains(string(.), %s)', XPathExpr::xpathLiteral($expr)));
// FIXME: Currently case insensitive matching doesn't seem to be happening
-
return $xpath;
}
@@ -264,7 +263,6 @@ protected function parseSeries($s)
if (false === strpos($s, 'n')) {
// Just a b
-
return array(0, intval((string) $s));
}
View
6 src/Symfony/Component/Filesystem/Filesystem.php
@@ -360,7 +360,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
if ($copyOnWindows) {
if (is_link($file) || is_file($file)) {
$this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
- } else if (is_dir($file)) {
+ } elseif (is_dir($file)) {
$this->mkdir($target);
} else {
throw new IOException(sprintf('Unable to guess "%s" file type.', $file));
@@ -368,9 +368,9 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
} else {
if (is_link($file)) {
$this->symlink($file, $target);
- } else if (is_dir($file)) {
+ } elseif (is_dir($file)) {
$this->mkdir($target);
- } else if (is_file($file)) {
+ } elseif (is_file($file)) {
$this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
} else {
throw new IOException(sprintf('Unable to guess "%s" file type.', $file));
View
12 src/Symfony/Component/Finder/SplFileInfo.php
@@ -62,10 +62,14 @@ public function getRelativePathname()
*/
public function getContents()
{
- $file = new \SplFileObject($this->getRealpath(), 'rb');
- ob_start();
- $file->fpassthru();
+ $level = error_reporting(0);
+ $content = file_get_contents($this->getRealpath());
+ error_reporting($level);
+ if (false === $content) {
+ $error = error_get_last();
+ throw new \RuntimeException($error['message']);
+ }
- return ob_get_clean();
+ return $content;
}
}
View
2  src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php
@@ -261,7 +261,7 @@ protected function addChoices(array &$bucketForPreferred, array &$bucketForRemai
{
// Add choices to the nested buckets
foreach ($choices as $group => $choice) {
- if (!isset($labels[$group])) {
+ if (!array_key_exists($group, $labels)) {
throw new \InvalidArgumentException('The structures of the choices and labels array do not match.');
}
View
1  src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php
@@ -53,7 +53,6 @@ public function reverseTransform($rfc3339)
return null;
}
-
$dateTime = new \DateTime($rfc3339);
if ($this->outputTimezone !== $this->inputTimezone) {
View
6 src/Symfony/Component/Form/Extension/Core/Type/DateType.php
@@ -180,6 +180,10 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
);
};
+ $format = function (Options $options) {
+ return $options['widget'] === 'single_text' ? DateType::HTML5_FORMAT : DateType::DEFAULT_FORMAT;
+ };
+
// BC until Symfony 2.3
$modelTimezone = function (Options $options) {
return $options['data_timezone'];
@@ -196,7 +200,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'days' => range(1, 31),
'widget' => 'choice',
'input' => 'datetime',
- 'format' => self::HTML5_FORMAT,
+ 'format' => $format,
'model_timezone' => $modelTimezone,
'view_timezone' => $viewTimezone,
// Deprecated timezone options
View
2  src/Symfony/Component/Form/Extension/Core/Type/FileType.php
@@ -46,7 +46,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'compound' => false,
- 'data_class' => 'Symfony\Component\HttpFoundation\File\File'
+ 'data_class' => 'Symfony\Component\HttpFoundation\File\File'
));
}
View
2  src/Symfony/Component/Form/Guess/Guess.php
@@ -90,7 +90,7 @@ public static function getBestGuess(array $guesses)
*/
public function __construct($confidence)
{
- if (self::VERY_HIGH_CONFIDENCE !== $confidence && self::HIGH_CONFIDENCE !== $confidence &&
+ if (self::VERY_HIGH_CONFIDENCE !== $confidence && self::HIGH_CONFIDENCE !== $confidence &&
self::MEDIUM_CONFIDENCE !== $confidence && self::LOW_CONFIDENCE !== $confidence) {
throw new \InvalidArgumentException('The confidence should be one of the constants defined in Guess.');
}
View
64 src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
@@ -809,14 +809,14 @@ public function testDateTime()
[@id="name_date"]
[
./select
- [@id="name_date_year"]
- [./option[@value="2011"][@selected="selected"]]
- /following-sibling::select
[@id="name_date_month"]
[./option[@value="2"][@selected="selected"]]
/following-sibling::select
[@id="name_date_day"]
[./option[@value="3"][@selected="selected"]]
+ /following-sibling::select
+ [@id="name_date_year"]
+ [./option[@value="2011"][@selected="selected"]]
]
/following-sibling::div
[@id="name_time"]
@@ -849,14 +849,14 @@ public function testDateTimeWithEmptyValueGlobal()
[@id="name_date"]
[
./select
- [@id="name_date_year"]
- [./option[@value=""][.="[trans]Change&Me[/trans]"]]
- /following-sibling::select
[@id="name_date_month"]
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
/following-sibling::select
[@id="name_date_day"]
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
+ /following-sibling::select
+ [@id="name_date_year"]
+ [./option[@value=""][.="[trans]Change&Me[/trans]"]]
]
/following-sibling::div
[@id="name_time"]
@@ -889,14 +889,14 @@ public function testDateTimeWithEmptyValueOnTime()
[@id="name_date"]
[
./select
- [@id="name_date_year"]
- [./option[@value="2011"][@selected="selected"]]
- /following-sibling::select
[@id="name_date_month"]
[./option[@value="2"][@selected="selected"]]
/following-sibling::select
[@id="name_date_day"]
[./option[@value="3"][@selected="selected"]]
+ /following-sibling::select
+ [@id="name_date_year"]
+ [./option[@value="2011"][@selected="selected"]]
]
/following-sibling::div
[@id="name_time"]
@@ -928,14 +928,14 @@ public function testDateTimeWithSeconds()
[@id="name_date"]
[
./select
- [@id="name_date_year"]
- [./option[@value="2011"][@selected="selected"]]
- /following-sibling::select
[@id="name_date_month"]
[./option[@value="2"][@selected="selected"]]
/following-sibling::select
[@id="name_date_day"]
[./option[@value="3"][@selected="selected"]]
+ /following-sibling::select
+ [@id="name_date_year"]
+ [./option[@value="2011"][@selected="selected"]]
]
/following-sibling::div
[@id="name_time"]
@@ -1031,14 +1031,14 @@ public function testDateChoice()
'/div
[
./select
- [@id="name_year"]
- [./option[@value="2011"][@selected="selected"]]
- /following-sibling::select
[@id="name_month"]
[./option[@value="2"][@selected="selected"]]
/following-sibling::select
[@id="name_day"]
[./option[@value="3"][@selected="selected"]]
+ /following-sibling::select
+ [@id="name_year"]
+ [./option[@value="2011"][@selected="selected"]]
]
[count(./select)=3]
'
@@ -1058,14 +1058,14 @@ public function testDateChoiceWithEmptyValueGlobal()
'/div
[
./select
- [@id="name_year"]
- [./option[@value=""][.="[trans]Change&Me[/trans]"]]
- /following-sibling::select
[@id="name_month"]
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
/following-sibling::select
[@id="name_day"]
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
+ /following-sibling::select
+ [@id="name_year"]
+ [./option[@value=""][.="[trans]Change&Me[/trans]"]]
]
[count(./select)=3]
'
@@ -1085,14 +1085,14 @@ public function testDateChoiceWithEmptyValueOnYear()
'/div
[
./select
- [@id="name_year"]
- [./option[@value=""][.="[trans]Change&Me[/trans]"]]
- /following-sibling::select
[@id="name_month"]
[./option[@value="1"]]
/following-sibling::select
[@id="name_day"]
[./option[@value="1"]]
+ /following-sibling::select
+ [@id="name_year"]
+ [./option[@value=""][.="[trans]Change&Me[/trans]"]]
]
[count(./select)=3]
'
@@ -1110,10 +1110,6 @@ public function testDateText()
'/div
[
./input
- [@id="name_year"]
- [@type="text"]
- [@value="2011"]
- /following-sibling::input
[@id="name_month"]
[@type="text"]
[@value="2"]
@@ -1121,6 +1117,10 @@ public function testDateText()
[@id="name_day"]
[@type="text"]
[@value="3"]
+ /following-sibling::input
+ [@id="name_year"]
+ [@type="text"]
+ [@value="2011"]
]
[count(./input)=3]
'
@@ -1164,14 +1164,14 @@ public function testBirthDay()
'/div
[
./select
- [@id="name_year"]
- [./option[@value="2000"][@selected="selected"]]
- /following-sibling::select
[@id="name_month"]
[./option[@value="2"][@selected="selected"]]
/following-sibling::select
[@id="name_day"]
[./option[@value="3"][@selected="selected"]]
+ /following-sibling::select
+ [@id="name_year"]
+ [./option[@value="2000"][@selected="selected"]]
]
[count(./select)=3]
'
@@ -1190,10 +1190,6 @@ public function testBirthDayWithEmptyValue()
'/div
[
./select
- [@id="name_year"]
- [./option[@value=""][.="[trans][/trans]"]]
- [./option[@value="1950"][@selected="selected"]]
- /following-sibling::select
[@id="name_month"]
[./option[@value=""][.="[trans][/trans]"]]
[./option[@value="1"][@selected="selected"]]
@@ -1201,6 +1197,10 @@ public function testBirthDayWithEmptyValue()
[@id="name_day"]
[./option[@value=""][.="[trans][/trans]"]]
[./option[@value="1"][@selected="selected"]]
+ /following-sibling::select
+ [@id="name_year"]
+ [./option[@value=""][.="[trans][/trans]"]]
+ [./option[@value="1950"][@selected="selected"]]
]
[count(./select)=3]
'
View
13 src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php
@@ -184,4 +184,17 @@ public function testNonMatchingLabels()
array('A')
);
}
+
+ public function testLabelsContainingNull()
+ {
+ $this->list = new ChoiceList(
+ array($this->obj1, $this->obj2),
+ array('A', null)
+ );
+
+ $this->assertEquals(
+ array(0 => new ChoiceView($this->obj1, '0', 'A'), 1 => new ChoiceView($this->obj2, '1', null)),
+ $this->list->getRemainingViews()
+ );
+ }
}
View
1  src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php
@@ -18,4 +18,3 @@ public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actu
self::assertEquals($expected->format('c'), $actual->format('c'));
}
}
-
View
6 src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php
@@ -510,18 +510,18 @@ public function testPassDatePatternToView()
$form = $this->factory->create('date');
$view = $form->createView();
- $this->assertSame('{{ year }}-{{ month }}-{{ day }}', $view->vars['date_pattern']);
+ $this->assertSame('{{ day }}.{{ month }}.{{ year }}', $view->vars['date_pattern']);
}
public function testPassDatePatternToViewDifferentFormat()
{
$form = $this->factory->create('date', null, array(
- 'format' => \IntlDateFormatter::MEDIUM,
+ 'format' => \IntlDateFormatter::LONG,
));
$view = $form->createView();
- $this->assertSame('{{ day }}.{{ month }}.{{ year }}', $view->vars['date_pattern']);
+ $this->assertSame('{{ day }}. {{ month }} {{ year }}', $view->vars['date_pattern']);
}
public function testPassDatePatternToViewDifferentPattern()
View
2  src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
@@ -227,7 +227,6 @@ public function provideDefaultTests()
{
// The mapping must be deterministic! If a child has the property path "[street]",
// "data[street]" should be mapped, but "data.street" should not!
-
return array(
// mapping target, child name, its property path, grand child name, its property path, violation path
array(self::LEVEL_0, 'address', 'address', 'street', 'street', ''),
@@ -1260,7 +1259,6 @@ public function provideCustomFormErrorTests()
// 1) the error actually maps to an existing child and
// 2) the property path of that child (relative to the form providing
// the mapping) matches the left side of the mapping
-
return array(
// mapping target, map from, map to, child name, its property path, grand child name, its property path, violation path
array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'),
View
2  src/Symfony/Component/HttpFoundation/HeaderBag.php
@@ -317,7 +317,7 @@ protected function parseCacheControl($header)
$cacheControl = array();
preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
- $cacheControl[strtolower($match[1])] = isset($match[2]) && $match[2] ? $match[2] : (isset($match[3]) ? $match[3] : true);
+ $cacheControl[strtolower($match[1])] = isset($match[3]) ? $match[3] : (isset($match[2]) ? $match[2] : true);
}
return $cacheControl;
View
2  src/Symfony/Component/HttpFoundation/Request.php
@@ -1007,7 +1007,7 @@ public function getHost()
// trim and remove port number from host
// host is lowercase as per RFC 952/2181
- $host = strtolower(trim(preg_replace('/:\d+$/', '', $host)));
+ $host = strtolower(preg_replace('/:\d+$/', '', trim($host)));
// as the host can come from the user (HTTP_HOST and depending on the configuration, SERVER_NAME too can come from the user)
// check that it does not contain forbidden characters (see RFC 952 and RFC 2181)
View
1  src/Symfony/Component/HttpFoundation/RequestMatcher.php
@@ -150,4 +150,3 @@ public function matches(Request $request)
return true;
}
}
-
View
6 src/Symfony/Component/HttpFoundation/Response.php
@@ -245,6 +245,12 @@ public function prepare(Request $request)
$this->setProtocolVersion('1.1');
}
+ // Check if we need to send extra expire info headers
+ if ('1.0' == $this->getProtocolVersion() && 'no-cache' == $this->headers->get('Cache-Control')) {
+ $this->headers->set('pragma', 'no-cache');
+ $this->headers->set('expires', -1);
+ }
+
return $this;
}
View
7 src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php
@@ -168,6 +168,13 @@ public function testCacheControlDirectiveParsing()
$this->assertEquals('max-age=10, public, s-maxage=100', $bag->get('cache-control'));
}
+ public function testCacheControlDirectiveParsingQuotedZero()
+ {
+ $bag = new HeaderBag(array('cache-control' => 'max-age="0"'));
+ $this->assertTrue($bag->hasCacheControlDirective('max-age'));
+ $this->assertEquals(0, $bag->getCacheControlDirective('max-age'));
+ }
+
public function testCacheControlDirectiveOverrideWithReplace()
{
$bag = new HeaderBag(array('cache-control' => 'private, max-age=100'));
View
17 src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
@@ -351,6 +351,23 @@ public function testPrepareRemovesContentForHeadRequests()
$this->assertEquals('', $response->getContent());
}
+ public function testPrepareSetsPragmaOnHttp10Only()
+ {
+ $request = Request::create('/', 'GET');
+ $request->server->set('SERVER_PROTOCOL', 'HTTP/1.0');
+
+ $response = new Response('foo');
+ $response->prepare($request);
+ $this->assertEquals('no-cache', $response->headers->get('pragma'));
+ $this->assertEquals('-1', $response->headers->get('expires'));
+
+ $request->server->set('SERVER_PROTOCOL', 'HTTP/1.1');
+ $response = new Response('foo');
+ $response->prepare($request);
+ $this->assertFalse($response->headers->has('pragma'));
+ $this->assertFalse($response->headers->has('expires'));
+ }
+
public function testSetCache()
{
$response = new Response();
View
1  ...y/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php
@@ -54,6 +54,7 @@ public function test__ConstructSavePath($savePath, $expectedSavePath, $path)
public function savePathDataProvider()
{
$base = sys_get_temp_dir();
+
return array(
array("$base/foo", "$base/foo", "$base/foo"),
array("5;$base/foo", "5;$base/foo", "$base/foo"),
View
3  src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php
@@ -40,7 +40,7 @@ public function getData()
public function collect(Request $request, Response $response, \Exception $exception = null)
{
}
-
+
public function getName()
{
return 'test_data_collector';
@@ -126,4 +126,3 @@ protected function setUp()
}
}
}
-
View
11 src/Symfony/Component/Locale/Resources/data/build-data.php
@@ -125,7 +125,8 @@ function get_data($index, $dataDir, $locale = 'en', $constraint = null)
return $data;
}
-function icu_version() {
+function icu_version()
+{
exec('icu-config --version', $output, $result);
if ($result !== 0 || !isset($output[0])) {
@@ -135,13 +136,15 @@ function icu_version() {
return $output[0];
}
-function normalize_icu_version($version) {
+function normalize_icu_version($version)
+{
preg_match('/^(?P<version>[0-9]\.[0-9]|[0-9]{2,})/', $version, $matches);
return $matches['version'];
}
-function download_icu_data($version) {
+function download_icu_data($version)
+{
$icu = parse_ini_file(__DIR__.'/icu.ini');
if (!isset($icu[$version])) {
@@ -624,4 +627,4 @@ function create_svn_info_file($source, $target)
// Clean up
clear_directory($currDir);
-rmdir($currDir);
+rmdir($currDir);
View
3  src/Symfony/Component/Process/Tests/AbstractProcessTest.php
@@ -18,7 +18,7 @@
*/
abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
{
- protected abstract function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array());
+ abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array());
/**
* @expectedException Symfony\Component\Process\Exception\InvalidArgumentException
@@ -282,7 +282,6 @@ public function testProcessWithTermSignal()
$this->markTestSkipped('Windows does not support POSIX signals');
}
-
$process = $this->getProcess('php -r "while (true) {}"');
$process->start();
$process->stop();
View
1  src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php
@@ -58,7 +58,6 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token)
return $this->httpUtils->createRedirectResponse($request, $this->determineTargetUrl($request));
}
-
/**
* Get the provider key.
*
View
1  src/Symfony/Component/Security/Http/Firewall/ContextListener.php
@@ -75,6 +75,7 @@ public function handle(GetResponseEvent $event)
if (null === $session || null === $token = $session->get('_security_'.$this->contextKey)) {
$this->context->setToken(null);
+
return;
}
View
2  src/Symfony/Component/Security/Http/HttpUtils.php
@@ -106,7 +106,7 @@ public function checkRequestPath(Request $request, $path)
}
}
- return $path === $request->getPathInfo();
+ return $path === rawurldecode($request->getPathInfo());
}
/**
View
5 src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php
@@ -97,6 +97,11 @@ public function testCheckRequestPath()
$this->assertTrue($utils->checkRequestPath($this->getRequest(), '/'));
$this->assertFalse($utils->checkRequestPath($this->getRequest(), '/foo'));
+ $this->assertTrue($utils->checkRequestPath($this->getRequest('/foo%20bar'), '/foo bar'));
+ // Plus must not decoded to space
+ $this->assertTrue($utils->checkRequestPath($this->getRequest('/foo+bar'), '/foo+bar'));
+ // Checking unicode
+ $this->assertTrue($utils->checkRequestPath($this->getRequest(urlencode('/вход')), '/вход'));
$urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface');
$urlMatcher
View
4 src/Symfony/Component/Validator/Constraints/Regex.php
@@ -62,7 +62,7 @@ public function getHtmlPattern()
* Convert the htmlPattern to a suitable format for HTML5 pattern.
* Example: /^[a-z]+$/ would be converted to [a-z]+
* However, if options are specified, it cannot be converted
- *
+ *
* Pattern is also ignored if match=false since the pattern should
* then be reversed before application.
*
@@ -78,7 +78,7 @@ private function getNonDelimitedPattern()
if (!$this->match) {
return null;
}
-
+
if (preg_match('/^(.)(\^?)(.*?)(\$?)\1$/', $this->pattern, $matches)) {
$delimiter = $matches[1];
$start = empty($matches[2]) ? '.*' : '';
View
3  src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php
@@ -162,7 +162,7 @@ public function testHtmlPattern()
'pattern' => '/[a-z]+/',
));
$this->assertEquals('.*[a-z]+.*', $constraint->getHtmlPattern());
-
+
// Dropped because of match=false
$constraint = new Regex(array(
'pattern' => '/[a-z]+/',
@@ -170,5 +170,4 @@ public function testHtmlPattern()
));
$this->assertNull($constraint->getHtmlPattern());
}
-
}
Please sign in to comment.
Something went wrong with that request. Please try again.