Merge branch 'master' of https://github.com/symfony/symfony into finder_search_by_contents
This commit is contained in:
commit
33e119a7dc
@ -14,6 +14,7 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
|
||||
|
||||
* added a default implementation of the ManagerRegistry
|
||||
* added a session storage for Doctrine DBAL
|
||||
* DoctrineOrmTypeGuesser now guesses "collection" for array Doctrine type
|
||||
|
||||
### TwigBridge
|
||||
|
||||
@ -273,6 +274,7 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
|
||||
* deprecated FieldType and merged it into FormType
|
||||
* [BC BREAK] renamed "field_*" theme blocks to "form_*" and "field_widget" to
|
||||
"input"
|
||||
* ValidatorTypeGuesser now guesses "collection" for array type constraint
|
||||
|
||||
### HttpFoundation
|
||||
|
||||
|
@ -13,6 +13,14 @@
|
||||
configuration (i.e. `config.yml`), merging could yield a set of base URL's
|
||||
for multiple environments.
|
||||
|
||||
### Doctrine
|
||||
|
||||
The DoctrineBundle is moved from the Symfony repository to the Doctrine repository.
|
||||
Therefore you should change the namespace of this bundle in your AppKernel.php:
|
||||
|
||||
Before: `new Symfony\Bundle\DoctrineBundle\DoctrineBundle()`
|
||||
After: `new Doctrine\Bundle\DoctrineBundle\DoctrineBundle()`
|
||||
|
||||
### HttpFoundation
|
||||
|
||||
* Locale management was moved from the Session class to the Request class.
|
||||
|
@ -50,8 +50,8 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
|
||||
switch ($metadata->getTypeOfField($property))
|
||||
{
|
||||
//case 'array':
|
||||
// return new TypeGuess('Collection', array(), Guess::HIGH_CONFIDENCE);
|
||||
case 'array':
|
||||
return new TypeGuess('collection', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
case 'boolean':
|
||||
return new TypeGuess('checkbox', array(), Guess::HIGH_CONFIDENCE);
|
||||
case 'datetime':
|
||||
|
@ -181,7 +181,7 @@ class ClassCollectionLoader
|
||||
{
|
||||
$tmpFile = tempnam(dirname($file), basename($file));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
chmod($file, 0644);
|
||||
chmod($file, 0666 ^ umask());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class ConfigCache
|
||||
|
||||
$tmpFile = tempnam(dirname($this->file), basename($this->file));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $this->file)) {
|
||||
chmod($this->file, 0666);
|
||||
chmod($this->file, 0666 ^ umask());
|
||||
} else {
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $this->file));
|
||||
}
|
||||
@ -110,7 +110,7 @@ class ConfigCache
|
||||
$file = $this->file.'.meta';
|
||||
$tmpFile = tempnam(dirname($file), basename($file));
|
||||
if (false !== @file_put_contents($tmpFile, serialize($metadata)) && @rename($tmpFile, $file)) {
|
||||
chmod($file, 0666);
|
||||
chmod($file, 0666 ^ umask());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class Container implements ContainerInterface
|
||||
class Container implements IntrospectableContainerInterface
|
||||
{
|
||||
protected $parameterBag;
|
||||
protected $services;
|
||||
@ -265,6 +265,18 @@ class Container implements ContainerInterface
|
||||
throw new ServiceNotFoundException($id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given service has actually been initialized
|
||||
*
|
||||
* @param string $id The service identifier
|
||||
*
|
||||
* @return Boolean true if service has already been initialized, false otherwise
|
||||
*/
|
||||
public function initialized($id)
|
||||
{
|
||||
return isset($this->services[strtolower($id)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all service ids.
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?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\DependencyInjection;
|
||||
|
||||
/**
|
||||
* IntrospectableContainerInterface defines additional introspection functionality
|
||||
* for containers, allowing logic to be implemented based on a Container's state.
|
||||
*
|
||||
* @author Evan Villemez <evillemez@gmail.com>
|
||||
*
|
||||
*/
|
||||
interface IntrospectableContainerInterface extends ContainerInterface
|
||||
{
|
||||
/**
|
||||
* Check for whether or not a service has been initialized.
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return Boolean true if the service has been initialized, false otherwise
|
||||
*
|
||||
*/
|
||||
function initialized($id);
|
||||
|
||||
}
|
@ -193,6 +193,18 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($sc->has('foo.baz'), '->has() returns true if a get*Method() is defined');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Container::initialized
|
||||
*/
|
||||
public function testInitialized()
|
||||
{
|
||||
$sc = new ProjectServiceContainer();
|
||||
$sc->set('foo', new \stdClass());
|
||||
$this->assertTrue($sc->initialized('foo'), '->initialized() returns true if service is loaded');
|
||||
$this->assertFalse($sc->initialized('foo1'), '->initialized() returns false if service is not loaded');
|
||||
$this->assertFalse($sc->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded');
|
||||
}
|
||||
|
||||
public function testEnterLeaveCurrentScope()
|
||||
{
|
||||
$container = new ProjectServiceContainer();
|
||||
|
@ -106,19 +106,14 @@ class Filesystem
|
||||
* Change mode for an array of files or directories.
|
||||
*
|
||||
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to change mode
|
||||
* @param integer $mode The new mode
|
||||
* @param integer $mode The new mode (octal)
|
||||
* @param integer $umask The mode mask (octal)
|
||||
*/
|
||||
public function chmod($files, $mode, $umask = 0000)
|
||||
{
|
||||
$currentUmask = umask();
|
||||
umask($umask);
|
||||
|
||||
foreach ($this->toIterator($files) as $file) {
|
||||
chmod($file, $mode);
|
||||
chmod($file, $mode ^ $umask);
|
||||
}
|
||||
|
||||
umask($currentUmask);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,6 +176,12 @@ class Filesystem
|
||||
*/
|
||||
public function makePathRelative($endPath, $startPath)
|
||||
{
|
||||
// Normalize separators on windows
|
||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||
$endPath = strtr($endPath, '\\', '/');
|
||||
$startPath = strtr($startPath, '\\', '/');
|
||||
}
|
||||
|
||||
// Find for which character the the common path stops
|
||||
$offset = 0;
|
||||
while (isset($startPath[$offset]) && isset($endPath[$offset]) && $startPath[$offset] === $endPath[$offset]) {
|
||||
@ -188,8 +189,8 @@ class Filesystem
|
||||
}
|
||||
|
||||
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
|
||||
$diffPath = trim(substr($startPath, $offset), DIRECTORY_SEPARATOR);
|
||||
$depth = strlen($diffPath) > 0 ? substr_count($diffPath, DIRECTORY_SEPARATOR) + 1 : 0;
|
||||
$diffPath = trim(substr($startPath, $offset), '/');
|
||||
$depth = strlen($diffPath) > 0 ? substr_count($diffPath, '/') + 1 : 0;
|
||||
|
||||
// Repeated "../" for each level need to reach the common path
|
||||
$traverser = str_repeat('../', $depth);
|
||||
|
@ -299,7 +299,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRemoveCleansInvalidLinks()
|
||||
{
|
||||
$this->markAsSkippeIfSymlinkIsMissing();
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
$basePath = $this->workspace.DIRECTORY_SEPARATOR.'directory'.DIRECTORY_SEPARATOR;
|
||||
|
||||
@ -315,6 +315,8 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testChmodChangesFileMode()
|
||||
{
|
||||
$this->markAsSkippedIfChmodIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
touch($file);
|
||||
|
||||
@ -323,8 +325,21 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(753, $this->getFilePermisions($file));
|
||||
}
|
||||
|
||||
public function testChmodAppliesUmask()
|
||||
{
|
||||
$this->markAsSkippedIfChmodIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->chmod($file, 0777, 0022);
|
||||
$this->assertEquals(755, $this->getFilePermisions($file));
|
||||
}
|
||||
|
||||
public function testChmodChangesModeOfArrayOfFiles()
|
||||
{
|
||||
$this->markAsSkippedIfChmodIsMissing();
|
||||
|
||||
$directory = $this->workspace.DIRECTORY_SEPARATOR.'directory';
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$files = array($directory, $file);
|
||||
@ -340,6 +355,8 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testChmodChangesModeOfTraversableFileObject()
|
||||
{
|
||||
$this->markAsSkippedIfChmodIsMissing();
|
||||
|
||||
$directory = $this->workspace.DIRECTORY_SEPARATOR.'directory';
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$files = new \ArrayObject(array($directory, $file));
|
||||
@ -392,7 +409,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testSymlink()
|
||||
{
|
||||
$this->markAsSkippeIfSymlinkIsMissing();
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
@ -407,7 +424,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
|
||||
{
|
||||
$this->markAsSkippeIfSymlinkIsMissing();
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
@ -423,7 +440,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testSymlinkIsNotOverwrittenIfAlreadyCreated()
|
||||
{
|
||||
$this->markAsSkippeIfSymlinkIsMissing();
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
@ -462,11 +479,8 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/', 'src/Symfony/'),
|
||||
);
|
||||
|
||||
// fix directory separator
|
||||
foreach ($paths as $i => $pathItems) {
|
||||
foreach ($pathItems as $k => $path) {
|
||||
$paths[$i][$k] = str_replace('/', DIRECTORY_SEPARATOR, $path);
|
||||
}
|
||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||
$paths[] = array('c:\var\lib/symfony/src/Symfony/', 'c:/var/lib/symfony/', 'src/Symfony/');
|
||||
}
|
||||
|
||||
return $paths;
|
||||
@ -496,7 +510,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testMirrorCopiesLinks()
|
||||
{
|
||||
$this->markAsSkippeIfSymlinkIsMissing();
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
|
||||
|
||||
@ -547,10 +561,17 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
return (int) substr(sprintf('%o', fileperms($filePath)), -3);
|
||||
}
|
||||
|
||||
private function markAsSkippeIfSymlinkIsMissing()
|
||||
private function markAsSkippedIfSymlinkIsMissing()
|
||||
{
|
||||
if (!function_exists('symlink')) {
|
||||
$this->markTestSkipped('symlink is not supported');
|
||||
}
|
||||
}
|
||||
|
||||
private function markAsSkippedIfChmodIsMissing()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||
$this->markTestSkipped('chmod is not supported on windows');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,9 +63,9 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
|
||||
* @param FormView $view The form view
|
||||
* @param FormInterface $form The form
|
||||
*/
|
||||
public function buildView(FormView $view, FormInterface $form)
|
||||
public function buildViewBottomUp(FormView $view, FormInterface $form)
|
||||
{
|
||||
if ($form->isRoot() && $form->hasChildren() && $form->hasAttribute('csrf_field_name')) {
|
||||
if (!$view->hasParent() && $view->hasChildren() && $form->hasAttribute('csrf_field_name')) {
|
||||
$name = $form->getAttribute('csrf_field_name');
|
||||
$csrfProvider = $form->getAttribute('csrf_provider');
|
||||
$intention = $form->getAttribute('csrf_intention');
|
||||
|
@ -89,6 +89,8 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
|
||||
switch (get_class($constraint)) {
|
||||
case 'Symfony\Component\Validator\Constraints\Type':
|
||||
switch ($constraint->type) {
|
||||
case 'array':
|
||||
return new TypeGuess('collection', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
case 'boolean':
|
||||
case 'bool':
|
||||
return new TypeGuess('checkbox', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
|
@ -96,10 +96,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$html = $this->renderRest($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
/following-sibling::div
|
||||
'/div
|
||||
[
|
||||
./label[@for="name_field1"]
|
||||
/following-sibling::input[@type="text"][@id="name_field1"]
|
||||
@ -112,6 +109,9 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
[count(../div)=2]
|
||||
[count(..//label)=2]
|
||||
[count(..//input)=3]
|
||||
/following-sibling::input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
'
|
||||
);
|
||||
}
|
||||
@ -144,8 +144,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$html = $this->renderRest($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input[@type="hidden"][@id="parent__token"]
|
||||
/following-sibling::div
|
||||
'/div
|
||||
[
|
||||
./label[not(@for)]
|
||||
/following-sibling::div[@id="parent_child1"]
|
||||
@ -172,6 +171,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
]
|
||||
[count(//label)=4]
|
||||
[count(//input[@type="text"])=2]
|
||||
/following-sibling::input[@type="hidden"][@id="parent__token"]
|
||||
'
|
||||
);
|
||||
}
|
||||
@ -189,15 +189,15 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$html = $this->renderRest($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
/following-sibling::div
|
||||
'/div
|
||||
[
|
||||
./label[@for="name_first"]
|
||||
/following-sibling::input[@type="text"][@id="name_first"]
|
||||
]
|
||||
[count(.//input)=1]
|
||||
/following-sibling::input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
'
|
||||
);
|
||||
}
|
||||
@ -216,16 +216,16 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$html = $this->renderRest($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
/following-sibling::div
|
||||
'/div
|
||||
[
|
||||
./label[@for="name_first"]
|
||||
/following-sibling::input[@type="text"][@id="name_first"]
|
||||
]
|
||||
[count(.//input)=1]
|
||||
[count(.//label)=1]
|
||||
/following-sibling::input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
'
|
||||
);
|
||||
}
|
||||
@ -246,16 +246,16 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$html = $this->renderRest($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
/following-sibling::div
|
||||
'/div
|
||||
[
|
||||
./label[@for="name_first"]
|
||||
/following-sibling::input[@type="text"][@id="name_first"]
|
||||
]
|
||||
[count(//input)=2]
|
||||
[count(//label)=1]
|
||||
/following-sibling::input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
'
|
||||
);
|
||||
}
|
||||
@ -293,8 +293,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"][@id="form__token"]
|
||||
/following-sibling::div
|
||||
./div
|
||||
[
|
||||
./label[not(@for)]
|
||||
/following-sibling::div
|
||||
@ -311,6 +310,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
]
|
||||
]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="form__token"]
|
||||
]
|
||||
[count(.//input)=3]
|
||||
'
|
||||
@ -327,8 +327,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"][@id="name__token"]
|
||||
/following-sibling::div
|
||||
./div
|
||||
[
|
||||
./label[@for="name_firstName"]
|
||||
/following-sibling::input[@type="text"][@id="name_firstName"]
|
||||
@ -338,6 +337,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
./label[@for="name_lastName"]
|
||||
/following-sibling::input[@type="text"][@id="name_lastName"]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
[count(.//input)=3]
|
||||
'
|
||||
@ -383,8 +383,8 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"][@id="name__token"][@value="foo&bar"]
|
||||
/following-sibling::div
|
||||
./div
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"][@value="foo&bar"]
|
||||
]
|
||||
[count(.//input[@type="hidden"])=1]
|
||||
'
|
||||
@ -400,8 +400,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"][@id="name__token"]
|
||||
/following-sibling::div
|
||||
./div
|
||||
[
|
||||
./label[@for="name_first"]
|
||||
/following-sibling::input[@type="text"][@id="name_first"]
|
||||
@ -411,6 +410,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
./label[@for="name_second"]
|
||||
/following-sibling::input[@type="text"][@id="name_second"]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
[count(.//input)=3]
|
||||
'
|
||||
@ -428,8 +428,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"][@id="name__token"]
|
||||
/following-sibling::div
|
||||
./div
|
||||
[
|
||||
./label[@for="name_first"][.="[trans]Test[/trans]"]
|
||||
/following-sibling::input[@type="text"][@id="name_first"][@required="required"]
|
||||
@ -439,6 +438,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
./label[@for="name_second"][.="[trans]Test2[/trans]"]
|
||||
/following-sibling::input[@type="text"][@id="name_second"][@required="required"]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
[count(.//input)=3]
|
||||
'
|
||||
@ -454,12 +454,12 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"][@id="full__token"]
|
||||
/following-sibling::div
|
||||
./div
|
||||
[
|
||||
./label[@for="full_name"]
|
||||
/following-sibling::input[@type="search"][@id="full_name"][@name="full[name]"]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="full__token"]
|
||||
]
|
||||
[count(//input)=2]
|
||||
'
|
||||
@ -521,8 +521,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($view, array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"]
|
||||
/following-sibling::div
|
||||
./div
|
||||
[
|
||||
./label[.="parent"]
|
||||
/following-sibling::input[@type="text"]
|
||||
@ -539,6 +538,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
]
|
||||
]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"]
|
||||
]
|
||||
'
|
||||
);
|
||||
|
@ -646,11 +646,11 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"][@id="name__token"]
|
||||
/following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
|
||||
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
|
||||
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
|
||||
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
|
||||
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
[count(./input)=3]
|
||||
'
|
||||
@ -669,11 +669,11 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"][@id="name__token"]
|
||||
/following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@checked]
|
||||
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
|
||||
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
|
||||
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
|
||||
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
[count(./input)=3]
|
||||
'
|
||||
@ -691,11 +691,11 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"][@id="name__token"]
|
||||
/following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@checked]
|
||||
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
|
||||
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
|
||||
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
|
||||
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
[count(./input)=3]
|
||||
'
|
||||
@ -714,13 +714,13 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./input[@type="hidden"][@id="name__token"]
|
||||
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
|
||||
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
|
||||
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
|
||||
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)]
|
||||
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
|
||||
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)]
|
||||
/following-sibling::label[@for="name_2"][.="[trans]Choice&C[/trans]"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
[count(./input)=4]
|
||||
'
|
||||
|
@ -45,12 +45,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
$html = $this->renderRow($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
/following-sibling::tr
|
||||
'/tr
|
||||
[
|
||||
./td
|
||||
[./label[@for="name_first"]]
|
||||
@ -65,6 +60,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
[./input[@id="name_second"]]
|
||||
]
|
||||
[count(../tr)=3]
|
||||
/following-sibling::tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
'
|
||||
);
|
||||
}
|
||||
@ -81,11 +81,6 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
[./td[@colspan="2"]/ul
|
||||
[./li[.="[trans]Error![/trans]"]]
|
||||
]
|
||||
/following-sibling::tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
/following-sibling::tr
|
||||
[
|
||||
./td
|
||||
@ -101,6 +96,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
[./input[@id="name_second"]]
|
||||
]
|
||||
[count(../tr)=4]
|
||||
/following-sibling::tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
'
|
||||
);
|
||||
}
|
||||
@ -126,12 +126,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
$html = $this->renderRest($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
/following-sibling::tr
|
||||
'/tr
|
||||
[
|
||||
./td
|
||||
[./label[@for="name_field1"]]
|
||||
@ -148,6 +143,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
[count(../tr)=3]
|
||||
[count(..//label)=2]
|
||||
[count(..//input)=3]
|
||||
/following-sibling::tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
'
|
||||
);
|
||||
}
|
||||
@ -161,9 +161,9 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/table
|
||||
[
|
||||
./tr[@style="display: none"][./td[@colspan="2"]/input[@type="hidden"][@id="name__token"]]
|
||||
/following-sibling::tr[./td/input[@type="text"][@value="a"]]
|
||||
./tr[./td/input[@type="text"][@value="a"]]
|
||||
/following-sibling::tr[./td/input[@type="text"][@value="b"]]
|
||||
/following-sibling::tr[@style="display: none"][./td[@colspan="2"]/input[@type="hidden"][@id="name__token"]]
|
||||
]
|
||||
[count(./tr[./td/input])=3]
|
||||
'
|
||||
@ -181,12 +181,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($view, array(),
|
||||
'/table
|
||||
[
|
||||
./tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
/following-sibling::tr
|
||||
./tr
|
||||
[
|
||||
./td
|
||||
[./label[@for="name_firstName"]]
|
||||
@ -200,6 +195,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
/following-sibling::td
|
||||
[./input[@id="name_lastName"]]
|
||||
]
|
||||
/following-sibling::tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
]
|
||||
[count(.//input)=3]
|
||||
'
|
||||
@ -267,12 +267,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/table
|
||||
[
|
||||
./tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
/following-sibling::tr
|
||||
./tr
|
||||
[
|
||||
./td
|
||||
[./label[@for="name_first"]]
|
||||
@ -286,6 +281,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
/following-sibling::td
|
||||
[./input[@type="text"][@id="name_second"]]
|
||||
]
|
||||
/following-sibling::tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
]
|
||||
[count(.//input)=3]
|
||||
'
|
||||
@ -303,12 +303,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/table
|
||||
[
|
||||
./tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
/following-sibling::tr
|
||||
./tr
|
||||
[
|
||||
./td
|
||||
[./label[@for="name_first"][.="[trans]Test[/trans]"]]
|
||||
@ -322,6 +317,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
/following-sibling::td
|
||||
[./input[@type="password"][@id="name_second"][@required="required"]]
|
||||
]
|
||||
/following-sibling::tr[@style="display: none"]
|
||||
[./td[@colspan="2"]/input
|
||||
[@type="hidden"]
|
||||
[@id="name__token"]
|
||||
]
|
||||
]
|
||||
[count(.//input)=3]
|
||||
'
|
||||
|
@ -11,9 +11,26 @@
|
||||
|
||||
namespace Symfony\Component\Form\Tests\Extension\Csrf\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
||||
use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase;
|
||||
|
||||
class FormTypeCsrfExtensionTest_ChildType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilder $builder, array $options)
|
||||
{
|
||||
// The form needs a child in order to trigger CSRF protection by
|
||||
// default
|
||||
$builder->add('name', 'text');
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'csrf_collection_test';
|
||||
}
|
||||
}
|
||||
|
||||
class FormTypeCsrfExtensionTest extends TypeTestCase
|
||||
{
|
||||
protected $csrfProvider;
|
||||
@ -195,4 +212,22 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
||||
'csrf' => 'token',
|
||||
));
|
||||
}
|
||||
|
||||
public function testNoCsrfProtectionOnPrototype()
|
||||
{
|
||||
$prototypeView = $this->factory
|
||||
->create('collection', null, array(
|
||||
'type' => new FormTypeCsrfExtensionTest_ChildType(),
|
||||
'options' => array(
|
||||
'csrf_field_name' => 'csrf',
|
||||
),
|
||||
'prototype' => true,
|
||||
'allow_add' => true,
|
||||
))
|
||||
->createView()
|
||||
->get('prototype');
|
||||
|
||||
$this->assertFalse($prototypeView->hasChild('csrf'));
|
||||
$this->assertCount(1, $prototypeView);
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class File extends \SplFileInfo
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message'])));
|
||||
}
|
||||
|
||||
chmod($target, 0666);
|
||||
chmod($target, 0666 ^ umask());
|
||||
|
||||
return new File($target);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ abstract class CacheWarmer implements CacheWarmerInterface
|
||||
{
|
||||
$tmpFile = tempnam(dirname($file), basename($file));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
chmod($file, 0644);
|
||||
chmod($file, 0666 ^ umask());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ class Store implements StoreInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
chmod($path, 0644);
|
||||
chmod($path, 0666 ^ umask());
|
||||
}
|
||||
|
||||
public function getPath($key)
|
||||
|
@ -51,7 +51,7 @@ class PathPackage extends Package
|
||||
$url = $this->applyVersion($path);
|
||||
|
||||
// apply the base path
|
||||
if ($url && '/' != $url[0]) {
|
||||
if ('/' !== substr($url, 0, 1)) {
|
||||
$url = $this->basePath.$url;
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,9 @@ class AssetsHelperTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$helper = new AssetsHelper('/bar', 'http://www.example.com/foo', 'abcd');
|
||||
$this->assertEquals('http://www.example.com/foo/foo.js?abcd', $helper->getUrl('foo.js'), '->getUrl() appends the version if defined');
|
||||
|
||||
$helper = new AssetsHelper();
|
||||
$this->assertEquals('/', $helper->getUrl(''), '->getUrl() with empty arg returns the prefix alone');
|
||||
}
|
||||
|
||||
public function testGetUrlLeavesProtocolRelativePathsUntouched()
|
||||
|
Reference in New Issue
Block a user