Merge branch '2.1'
* 2.1: [Yaml] fixed default value Added Yaml\Dumper::setIndentation() method to allow a custom indentation level of nested nodes. added a way to enable/disable object support when parsing/dumping added a way to enable/disable PHP support when parsing a YAML input via Yaml::parse() fixed CS [Process] Fix docblocks, remove `return` from `PhpProcess#start()` as parent returns nothing, cleaned up `ExecutableFinder` fixes a bug when output/error output contains a % character [Console] fixed input bug when the value of an option is empty (closes #6649, closes #6689) [Profiler] [Redis] Fix sort of profiler rows. Fix version_compare() calls for PHP 5.5. Removed underscores from test method names to be consistent with other components. [Process] In edge cases `getcwd()` can return `false`, then `proc_open()` should get `null` to use default value (the working dir of the current PHP process) Fix version_compare() calls for PHP 5.5. Handle the deprecation of IntlDateFormatter::setTimeZoneId() in PHP 5.5. removed the .gitattributes files (closes #6605, reverts #5674) [HttpKernel] Clarify misleading comment in ExceptionListener Conflicts: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_style.html.twig src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php src/Symfony/Component/Process/Process.php
This commit is contained in:
commit
1f762c7723
2
src/Symfony/Bridge/Doctrine/.gitattributes
vendored
2
src/Symfony/Bridge/Doctrine/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -351,7 +351,7 @@ class EntityTypeTest extends TypeTestCase
|
||||
$this->assertSame(array('1', '3'), $field->getClientData());
|
||||
}
|
||||
|
||||
public function testSubmitMultipleNonExpandedSingleIdentifier_existingData()
|
||||
public function testSubmitMultipleNonExpandedSingleIdentifierForExistingData()
|
||||
{
|
||||
$entity1 = new SingleIdentEntity(1, 'Foo');
|
||||
$entity2 = new SingleIdentEntity(2, 'Bar');
|
||||
@ -408,7 +408,7 @@ class EntityTypeTest extends TypeTestCase
|
||||
$this->assertSame(array('0', '2'), $field->getClientData());
|
||||
}
|
||||
|
||||
public function testSubmitMultipleNonExpandedCompositeIdentifier_existingData()
|
||||
public function testSubmitMultipleNonExpandedCompositeIdentifierExistingData()
|
||||
{
|
||||
$entity1 = new CompositeIdentEntity(10, 20, 'Foo');
|
||||
$entity2 = new CompositeIdentEntity(30, 40, 'Bar');
|
||||
@ -584,7 +584,7 @@ class EntityTypeTest extends TypeTestCase
|
||||
$this->assertEquals(array(2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']);
|
||||
}
|
||||
|
||||
public function testDisallowChoicesThatAreNotIncluded_choicesSingleIdentifier()
|
||||
public function testDisallowChoicesThatAreNotIncludedChoicesSingleIdentifier()
|
||||
{
|
||||
$entity1 = new SingleIdentEntity(1, 'Foo');
|
||||
$entity2 = new SingleIdentEntity(2, 'Bar');
|
||||
@ -605,7 +605,7 @@ class EntityTypeTest extends TypeTestCase
|
||||
$this->assertNull($field->getData());
|
||||
}
|
||||
|
||||
public function testDisallowChoicesThatAreNotIncluded_choicesCompositeIdentifier()
|
||||
public function testDisallowChoicesThatAreNotIncludedChoicesCompositeIdentifier()
|
||||
{
|
||||
$entity1 = new CompositeIdentEntity(10, 20, 'Foo');
|
||||
$entity2 = new CompositeIdentEntity(30, 40, 'Bar');
|
||||
|
2
src/Symfony/Bridge/Monolog/.gitattributes
vendored
2
src/Symfony/Bridge/Monolog/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
2
src/Symfony/Bridge/Propel1/.gitattributes
vendored
2
src/Symfony/Bridge/Propel1/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
2
src/Symfony/Bridge/Twig/.gitattributes
vendored
2
src/Symfony/Bridge/Twig/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -31,7 +31,7 @@ class YamlExtension extends \Twig_Extension
|
||||
);
|
||||
}
|
||||
|
||||
public function encode($input, $inline = 0)
|
||||
public function encode($input, $inline = 0, $dumpObjects = false)
|
||||
{
|
||||
static $dumper;
|
||||
|
||||
@ -39,20 +39,20 @@ class YamlExtension extends \Twig_Extension
|
||||
$dumper = new YamlDumper();
|
||||
}
|
||||
|
||||
return $dumper->dump($input, $inline);
|
||||
return $dumper->dump($input, $inline, false, $dumpObjects);
|
||||
}
|
||||
|
||||
public function dump($value)
|
||||
public function dump($value, $inline = 0, $dumpObjects = false)
|
||||
{
|
||||
if (is_resource($value)) {
|
||||
return '%Resource%';
|
||||
}
|
||||
|
||||
if (is_array($value) || is_object($value)) {
|
||||
return '%'.gettype($value).'% '.$this->encode($value);
|
||||
return '%'.gettype($value).'% '.$this->encode($value, $inline, $dumpObjects);
|
||||
}
|
||||
|
||||
return $this->encode($value);
|
||||
return $this->encode($value, $inline, $dumpObjects);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
2
src/Symfony/Bundle/TwigBundle/.gitattributes
vendored
2
src/Symfony/Bundle/TwigBundle/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
2
src/Symfony/Component/Config/.gitattributes
vendored
2
src/Symfony/Component/Config/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
2
src/Symfony/Component/Console/.gitattributes
vendored
2
src/Symfony/Component/Console/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -215,12 +215,14 @@ class ArgvInput extends Input
|
||||
|
||||
$option = $this->definition->getOption($name);
|
||||
|
||||
if (null === $value && $option->acceptValue()) {
|
||||
if (null === $value && $option->acceptValue() && count($this->parsed)) {
|
||||
// if option accepts an optional or mandatory argument
|
||||
// let's see if there is one provided
|
||||
$next = array_shift($this->parsed);
|
||||
if ('-' !== $next[0]) {
|
||||
if (isset($next[0]) && '-' !== $next[0]) {
|
||||
$value = $next;
|
||||
} elseif (empty($next)) {
|
||||
$value = '';
|
||||
} else {
|
||||
array_unshift($this->parsed, $next);
|
||||
}
|
||||
|
@ -71,6 +71,18 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
|
||||
$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))));
|
||||
$this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options with a required value (with a space separator)');
|
||||
|
||||
$input = new ArgvInput(array('cli.php', '-f', ''));
|
||||
$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL))));
|
||||
$this->assertEquals(array('foo' => ''), $input->getOptions(), '->parse() parses short options with an optional empty value');
|
||||
|
||||
$input = new ArgvInput(array('cli.php', '-f', '', 'foo'));
|
||||
$input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL))));
|
||||
$this->assertEquals(array('foo' => ''), $input->getOptions(), '->parse() parses short options with an optional empty value followed by an argument');
|
||||
|
||||
$input = new ArgvInput(array('cli.php', '-f', '', '-b'));
|
||||
$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b'))));
|
||||
$this->assertEquals(array('foo' => '', 'bar' => true), $input->getOptions(), '->parse() parses short options with an optional empty value followed by an option');
|
||||
|
||||
$input = new ArgvInput(array('cli.php', '-f', '-b', 'foo'));
|
||||
$input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b'))));
|
||||
$this->assertEquals(array('foo' => null, 'bar' => true), $input->getOptions(), '->parse() parses short options with an optional value which is not present');
|
||||
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -48,7 +48,7 @@ class GenericEventTest extends \PHPUnit_Framework_TestCase
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test__construct()
|
||||
public function testConstruct()
|
||||
{
|
||||
$this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event')));
|
||||
}
|
||||
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
2
src/Symfony/Component/Finder/.gitattributes
vendored
2
src/Symfony/Component/Finder/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
2
src/Symfony/Component/Form/.gitattributes
vendored
2
src/Symfony/Component/Form/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -268,7 +268,11 @@ class DateType extends AbstractType
|
||||
$pattern = $formatter->getPattern();
|
||||
$timezone = $formatter->getTimezoneId();
|
||||
|
||||
$formatter->setTimezoneId(\DateTimeZone::UTC);
|
||||
if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
|
||||
$formatter->setTimeZone(\DateTimeZone::UTC);
|
||||
} else {
|
||||
$formatter->setTimeZoneId(\DateTimeZone::UTC);
|
||||
}
|
||||
|
||||
if (preg_match($regex, $pattern, $matches)) {
|
||||
$formatter->setPattern($matches[0]);
|
||||
@ -282,7 +286,11 @@ class DateType extends AbstractType
|
||||
$formatter->setPattern($pattern);
|
||||
}
|
||||
|
||||
$formatter->setTimezoneId($timezone);
|
||||
if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
|
||||
$formatter->setTimeZone($timezone);
|
||||
} else {
|
||||
$formatter->setTimeZoneId($timezone);
|
||||
}
|
||||
|
||||
return $timestamps;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($output, $this->transformer->transform($input));
|
||||
}
|
||||
|
||||
public function testTransform_empty()
|
||||
public function testTransformEmpty()
|
||||
{
|
||||
$output = array(
|
||||
'first' => null,
|
||||
@ -102,7 +102,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($output, $this->transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransform_completelyEmpty()
|
||||
public function testReverseTransformCompletelyEmpty()
|
||||
{
|
||||
$input = array(
|
||||
'first' => '',
|
||||
@ -112,7 +112,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($this->transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransform_completelyNull()
|
||||
public function testReverseTransformCompletelyNull()
|
||||
{
|
||||
$input = array(
|
||||
'first' => null,
|
||||
@ -125,7 +125,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransform_partiallyNull()
|
||||
public function testReverseTransformPartiallyNull()
|
||||
{
|
||||
$input = array(
|
||||
'first' => array(
|
||||
|
@ -33,7 +33,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
$this->assertSame($output, $transformer->transform($input));
|
||||
}
|
||||
|
||||
public function testTransform_empty()
|
||||
public function testTransformEmpty()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
|
||||
@ -49,7 +49,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
$this->assertSame($output, $transformer->transform(null));
|
||||
}
|
||||
|
||||
public function testTransform_empty_withFields()
|
||||
public function testTransformEmptyWithFields()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer(null, null, array('year', 'minute', 'second'));
|
||||
|
||||
@ -62,7 +62,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
$this->assertSame($output, $transformer->transform(null));
|
||||
}
|
||||
|
||||
public function testTransform_withFields()
|
||||
public function testTransformWithFields()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer('UTC', 'UTC', array('year', 'month', 'minute', 'second'));
|
||||
|
||||
@ -78,7 +78,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
$this->assertSame($output, $transformer->transform($input));
|
||||
}
|
||||
|
||||
public function testTransform_withPadding()
|
||||
public function testTransformWithPadding()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer('UTC', 'UTC', null, true);
|
||||
|
||||
@ -96,7 +96,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
$this->assertSame($output, $transformer->transform($input));
|
||||
}
|
||||
|
||||
public function testTransform_differentTimezones()
|
||||
public function testTransformDifferentTimezones()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong');
|
||||
|
||||
@ -161,7 +161,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransform_completelyEmpty()
|
||||
public function testReverseTransformCompletelyEmpty()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
|
||||
@ -177,7 +177,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
$this->assertNull($transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransform_completelyEmpty_subsetOfFields()
|
||||
public function testReverseTransformCompletelyEmptySubsetOfFields()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer(null, null, array('year', 'month', 'day'));
|
||||
|
||||
@ -193,7 +193,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransform_partiallyEmpty_year()
|
||||
public function testReverseTransformPartiallyEmptyYear()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
$transformer->reverseTransform(array(
|
||||
@ -208,7 +208,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransform_partiallyEmpty_month()
|
||||
public function testReverseTransformPartiallyEmptyMonth()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
$transformer->reverseTransform(array(
|
||||
@ -223,7 +223,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransform_partiallyEmpty_day()
|
||||
public function testReverseTransformPartiallyEmptyDay()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
$transformer->reverseTransform(array(
|
||||
@ -238,7 +238,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransform_partiallyEmpty_hour()
|
||||
public function testReverseTransformPartiallyEmptyHour()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
$transformer->reverseTransform(array(
|
||||
@ -253,7 +253,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransform_partiallyEmpty_minute()
|
||||
public function testReverseTransformPartiallyEmptyMinute()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
$transformer->reverseTransform(array(
|
||||
@ -268,7 +268,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransform_partiallyEmpty_second()
|
||||
public function testReverseTransformPartiallyEmptySecond()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
$transformer->reverseTransform(array(
|
||||
@ -280,14 +280,14 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
));
|
||||
}
|
||||
|
||||
public function testReverseTransform_null()
|
||||
public function testReverseTransformNull()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
|
||||
$this->assertNull($transformer->reverseTransform(null));
|
||||
}
|
||||
|
||||
public function testReverseTransform_differentTimezones()
|
||||
public function testReverseTransformDifferentTimezones()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong');
|
||||
|
||||
|
@ -121,14 +121,14 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
$this->assertEquals('Feb 3, 2010 4:05 AM', $transformer->transform($this->dateTime));
|
||||
}
|
||||
|
||||
public function testTransform_empty()
|
||||
public function testTransformEmpty()
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer();
|
||||
|
||||
$this->assertSame('', $transformer->transform(null));
|
||||
}
|
||||
|
||||
public function testTransform_differentTimezones()
|
||||
public function testTransformWithDifferentTimezones()
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong');
|
||||
|
||||
@ -140,7 +140,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
$this->assertEquals($dateTime->format('d.m.Y H:i'), $transformer->transform($input));
|
||||
}
|
||||
|
||||
public function testTransform_differentPatterns()
|
||||
public function testTransformWithDifferentPatterns()
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss');
|
||||
|
||||
@ -206,7 +206,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
$this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010 04:05 AM'));
|
||||
}
|
||||
|
||||
public function testReverseTransform_differentTimezones()
|
||||
public function testReverseTransformWithDifferentTimezones()
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong');
|
||||
|
||||
@ -216,14 +216,14 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
$this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('03.02.2010 04:05'));
|
||||
}
|
||||
|
||||
public function testReverseTransform_differentPatterns()
|
||||
public function testReverseTransformWithDifferentPatterns()
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss');
|
||||
|
||||
$this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('02*2010*03 04|05|06'));
|
||||
}
|
||||
|
||||
public function testReverseTransform_empty()
|
||||
public function testReverseTransformEmpty()
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer();
|
||||
|
||||
|
@ -79,14 +79,14 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
||||
$this->assertEquals($output, $transformer->transform($input));
|
||||
}
|
||||
|
||||
public function testTransform_empty()
|
||||
public function testTransformEmpty()
|
||||
{
|
||||
$transformer = new DateTimeToStringTransformer();
|
||||
|
||||
$this->assertSame('', $transformer->transform(null));
|
||||
}
|
||||
|
||||
public function testTransform_differentTimezones()
|
||||
public function testTransformWithDifferentTimezones()
|
||||
{
|
||||
$transformer = new DateTimeToStringTransformer('Asia/Hong_Kong', 'America/New_York', 'Y-m-d H:i:s');
|
||||
|
||||
@ -134,14 +134,14 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
||||
$this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransform_empty()
|
||||
public function testReverseTransformEmpty()
|
||||
{
|
||||
$reverseTransformer = new DateTimeToStringTransformer();
|
||||
|
||||
$this->assertNull($reverseTransformer->reverseTransform(''));
|
||||
}
|
||||
|
||||
public function testReverseTransform_differentTimezones()
|
||||
public function testReverseTransformWithDifferentTimezones()
|
||||
{
|
||||
$reverseTransformer = new DateTimeToStringTransformer('America/New_York', 'Asia/Hong_Kong', 'Y-m-d H:i:s');
|
||||
|
||||
|
@ -25,14 +25,14 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase
|
||||
$this->assertEquals($output, $transformer->transform($input));
|
||||
}
|
||||
|
||||
public function testTransform_empty()
|
||||
public function testTransformEmpty()
|
||||
{
|
||||
$transformer = new DateTimeToTimestampTransformer();
|
||||
|
||||
$this->assertNull($transformer->transform(null));
|
||||
}
|
||||
|
||||
public function testTransform_differentTimezones()
|
||||
public function testTransformWithDifferentTimezones()
|
||||
{
|
||||
$transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York');
|
||||
|
||||
@ -75,14 +75,14 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase
|
||||
$this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransform_empty()
|
||||
public function testReverseTransformEmpty()
|
||||
{
|
||||
$reverseTransformer = new DateTimeToTimestampTransformer();
|
||||
|
||||
$this->assertNull($reverseTransformer->reverseTransform(null));
|
||||
}
|
||||
|
||||
public function testReverseTransform_differentTimezones()
|
||||
public function testReverseTransformWithDifferentTimezones()
|
||||
{
|
||||
$reverseTransformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York');
|
||||
|
||||
|
@ -32,7 +32,7 @@ class IntegerToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
$this->assertEquals(12345, $transformer->reverseTransform('12345,912'));
|
||||
}
|
||||
|
||||
public function testReverseTransform_empty()
|
||||
public function testReverseTransformEmpty()
|
||||
{
|
||||
$transformer = new IntegerToLocalizedStringTransformer();
|
||||
|
||||
|
@ -38,7 +38,7 @@ class MoneyToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
$transformer->transform('abcd');
|
||||
}
|
||||
|
||||
public function testTransform_empty()
|
||||
public function testTransformEmpty()
|
||||
{
|
||||
$transformer = new MoneyToLocalizedStringTransformer();
|
||||
|
||||
@ -61,7 +61,7 @@ class MoneyToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
$transformer->reverseTransform(12345);
|
||||
}
|
||||
|
||||
public function testReverseTransform_empty()
|
||||
public function testReverseTransformEmpty()
|
||||
{
|
||||
$transformer = new MoneyToLocalizedStringTransformer();
|
||||
|
||||
|
@ -32,7 +32,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
$this->assertEquals('12345,912', $transformer->transform(12345.9123));
|
||||
}
|
||||
|
||||
public function testTransform_empty()
|
||||
public function testTransformEmpty()
|
||||
{
|
||||
$transformer = new NumberToLocalizedStringTransformer();
|
||||
|
||||
@ -75,7 +75,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
$this->assertEquals(12345.912, $transformer->reverseTransform('12345,912'));
|
||||
}
|
||||
|
||||
public function testReverseTransform_empty()
|
||||
public function testReverseTransformEmpty()
|
||||
{
|
||||
$transformer = new NumberToLocalizedStringTransformer();
|
||||
|
||||
@ -129,7 +129,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot_noGroupSep()
|
||||
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep()
|
||||
{
|
||||
if ($this->isLowerThanIcuVersion('4.7')) {
|
||||
$this->markTestSkipped('Please upgrade ICU version to 4.7+');
|
||||
@ -185,7 +185,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma_noGroupSep()
|
||||
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep()
|
||||
{
|
||||
if ($this->isLowerThanIcuVersion('4.7')) {
|
||||
$this->markTestSkipped('Please upgrade ICU version to 4.7+');
|
||||
|
@ -32,7 +32,7 @@ class PercentToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
$this->assertEquals('200', $transformer->transform(2));
|
||||
}
|
||||
|
||||
public function testTransform_empty()
|
||||
public function testTransformEmpty()
|
||||
{
|
||||
$transformer = new PercentToLocalizedStringTransformer();
|
||||
|
||||
@ -66,7 +66,7 @@ class PercentToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
$this->assertEquals(2, $transformer->reverseTransform('200'));
|
||||
}
|
||||
|
||||
public function testReverseTransform_empty()
|
||||
public function testReverseTransformEmpty()
|
||||
{
|
||||
$transformer = new PercentToLocalizedStringTransformer();
|
||||
|
||||
|
@ -38,7 +38,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($output, $this->transformer->transform('Foo'));
|
||||
}
|
||||
|
||||
public function testTransform_empty()
|
||||
public function testTransformEmpty()
|
||||
{
|
||||
$output = array(
|
||||
'a' => null,
|
||||
@ -60,7 +60,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame('Foo', $this->transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransform_completelyEmpty()
|
||||
public function testReverseTransformCompletelyEmpty()
|
||||
{
|
||||
$input = array(
|
||||
'a' => '',
|
||||
@ -71,7 +71,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($this->transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransform_completelyNull()
|
||||
public function testReverseTransformCompletelyNull()
|
||||
{
|
||||
$input = array(
|
||||
'a' => null,
|
||||
@ -85,7 +85,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransform_partiallyNull()
|
||||
public function testReverseTransformPartiallyNull()
|
||||
{
|
||||
$input = array(
|
||||
'a' => 'Foo',
|
||||
@ -99,7 +99,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransform_differences()
|
||||
public function testReverseTransformDifferences()
|
||||
{
|
||||
$input = array(
|
||||
'a' => 'Foo',
|
||||
|
@ -15,7 +15,7 @@ use Symfony\Component\Form\FormError;
|
||||
|
||||
class DateTimeTypeTest extends LocalizedTestCase
|
||||
{
|
||||
public function testSubmit_dateTime()
|
||||
public function testSubmitDateTime()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -42,7 +42,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
}
|
||||
|
||||
public function testSubmit_string()
|
||||
public function testSubmitString()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -67,7 +67,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('2010-06-02 03:04:00', $form->getData());
|
||||
}
|
||||
|
||||
public function testSubmit_timestamp()
|
||||
public function testSubmitTimestamp()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -94,7 +94,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals($dateTime->format('U'), $form->getData());
|
||||
}
|
||||
|
||||
public function testSubmit_withoutMinutes()
|
||||
public function testSubmitWithoutMinutes()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'data_timezone' => 'UTC',
|
||||
@ -123,7 +123,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertDateTimeEquals(new \DateTime('2010-06-02 03:00:00 UTC'), $form->getData());
|
||||
}
|
||||
|
||||
public function testSubmit_withSeconds()
|
||||
public function testSubmitWithSeconds()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -154,7 +154,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertDateTimeEquals(new \DateTime('2010-06-02 03:04:05 UTC'), $form->getData());
|
||||
}
|
||||
|
||||
public function testSubmit_differentTimezones()
|
||||
public function testSubmitDifferentTimezones()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'model_timezone' => 'America/New_York',
|
||||
@ -185,7 +185,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals($dateTime->format('Y-m-d H:i:s'), $form->getData());
|
||||
}
|
||||
|
||||
public function testSubmit_differentTimezonesDateTime()
|
||||
public function testSubmitDifferentTimezonesDateTime()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'model_timezone' => 'America/New_York',
|
||||
@ -204,7 +204,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('2010-06-02T03:04:00-10:00', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_stringSingleText()
|
||||
public function testSubmitStringSingleText()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -219,7 +219,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('2010-06-02T03:04:00Z', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_stringSingleText_withSeconds()
|
||||
public function testSubmitStringSingleTextWithSeconds()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -235,7 +235,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('2010-06-02T03:04:05Z', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_differentPattern()
|
||||
public function testSubmitDifferentPattern()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'date_format' => 'MM*yyyy*dd',
|
||||
@ -343,7 +343,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertSame('Empty second', $view['time']['second']->vars['empty_value']);
|
||||
}
|
||||
|
||||
public function testPassEmptyValueAsPartialArray_addEmptyIfNotRequired()
|
||||
public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'required' => false,
|
||||
@ -365,7 +365,7 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertSame('Empty second', $view['time']['second']->vars['empty_value']);
|
||||
}
|
||||
|
||||
public function testPassEmptyValueAsPartialArray_addNullIfRequired()
|
||||
public function testPassEmptyValueAsPartialArrayAddNullIfRequired()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'required' => true,
|
||||
|
@ -313,7 +313,7 @@ class DateTypeTest extends LocalizedTestCase
|
||||
));
|
||||
}
|
||||
|
||||
public function testSetData_differentTimezones()
|
||||
public function testSetDataWithDifferentTimezones()
|
||||
{
|
||||
$form = $this->factory->create('date', null, array(
|
||||
'format' => \IntlDateFormatter::MEDIUM,
|
||||
@ -328,7 +328,7 @@ class DateTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('01.06.2010', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSetData_differentTimezonesDateTime()
|
||||
public function testSetDataWithDifferentTimezonesDateTime()
|
||||
{
|
||||
$form = $this->factory->create('date', null, array(
|
||||
'format' => \IntlDateFormatter::MEDIUM,
|
||||
@ -636,7 +636,7 @@ class DateTypeTest extends LocalizedTestCase
|
||||
$this->assertSame('Empty day', $view['day']->vars['empty_value']);
|
||||
}
|
||||
|
||||
public function testPassEmptyValueAsPartialArray_addEmptyIfNotRequired()
|
||||
public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired()
|
||||
{
|
||||
$form = $this->factory->create('date', null, array(
|
||||
'required' => false,
|
||||
@ -652,7 +652,7 @@ class DateTypeTest extends LocalizedTestCase
|
||||
$this->assertSame('Empty day', $view['day']->vars['empty_value']);
|
||||
}
|
||||
|
||||
public function testPassEmptyValueAsPartialArray_addNullIfRequired()
|
||||
public function testPassEmptyValueAsPartialArrayAddNullIfRequired()
|
||||
{
|
||||
$form = $this->factory->create('date', null, array(
|
||||
'required' => true,
|
||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Form\FormError;
|
||||
|
||||
class TimeTypeTest extends LocalizedTestCase
|
||||
{
|
||||
public function testSubmit_dateTime()
|
||||
public function testSubmitDateTime()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -37,7 +37,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals($input, $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_string()
|
||||
public function testSubmitString()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -56,7 +56,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals($input, $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_timestamp()
|
||||
public function testSubmitTimestamp()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -77,7 +77,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals($input, $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_array()
|
||||
public function testSubmitArray()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -96,7 +96,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals($input, $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_datetimeSingleText()
|
||||
public function testSubmitDatetimeSingleText()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -111,7 +111,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('03:04', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_datetimeSingleTextWithoutMinutes()
|
||||
public function testSubmitDatetimeSingleTextWithoutMinutes()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'data_timezone' => 'UTC',
|
||||
@ -127,7 +127,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('03', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_arraySingleText()
|
||||
public function testSubmitArraySingleText()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -147,7 +147,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('03:04', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_arraySingleTextWithoutMinutes()
|
||||
public function testSubmitArraySingleTextWithoutMinutes()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'data_timezone' => 'UTC',
|
||||
@ -167,7 +167,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('03', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_arraySingleTextWithSeconds()
|
||||
public function testSubmitArraySingleTextWithSeconds()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -189,7 +189,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('03:04:05', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_stringSingleText()
|
||||
public function testSubmitStringSingleText()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -204,7 +204,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('03:04', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSubmit_stringSingleTextWithoutMinutes()
|
||||
public function testSubmitStringSingleTextWithoutMinutes()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'data_timezone' => 'UTC',
|
||||
@ -220,7 +220,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('03', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSetData_withoutMinutes()
|
||||
public function testSetDataWithoutMinutes()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'data_timezone' => 'UTC',
|
||||
@ -234,7 +234,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals(array('hour' => 3), $form->getClientData());
|
||||
}
|
||||
|
||||
public function testSetData_withSeconds()
|
||||
public function testSetDataWithSeconds()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'UTC',
|
||||
@ -248,7 +248,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals(array('hour' => 3, 'minute' => 4, 'second' => 5), $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSetData_differentTimezones()
|
||||
public function testSetDataDifferentTimezones()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'America/New_York',
|
||||
@ -274,7 +274,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals($displayedData, $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSetData_differentTimezonesDateTime()
|
||||
public function testSetDataDifferentTimezonesDateTime()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'model_timezone' => 'America/New_York',
|
||||
@ -315,7 +315,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
), $view['hour']->vars['choices']);
|
||||
}
|
||||
|
||||
public function testIsMinuteWithinRange_returnsTrueIfWithin()
|
||||
public function testIsMinuteWithinRangeReturnsTrueIfWithin()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'minutes' => array(6, 7),
|
||||
@ -329,7 +329,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
), $view['minute']->vars['choices']);
|
||||
}
|
||||
|
||||
public function testIsSecondWithinRange_returnsTrueIfWithin()
|
||||
public function testIsSecondWithinRangeReturnsTrueIfWithin()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'seconds' => array(6, 7),
|
||||
@ -344,7 +344,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
), $view['second']->vars['choices']);
|
||||
}
|
||||
|
||||
public function testIsPartiallyFilled_returnsFalseIfCompletelyEmpty()
|
||||
public function testIsPartiallyFilledReturnsFalseIfCompletelyEmpty()
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||
|
||||
@ -360,7 +360,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertFalse($form->isPartiallyFilled());
|
||||
}
|
||||
|
||||
public function testIsPartiallyFilled_returnsFalseIfCompletelyEmpty_withSeconds()
|
||||
public function testIsPartiallyFilledReturnsFalseIfCompletelyEmptyWithSeconds()
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||
|
||||
@ -378,7 +378,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertFalse($form->isPartiallyFilled());
|
||||
}
|
||||
|
||||
public function testIsPartiallyFilled_returnsFalseIfCompletelyFilled()
|
||||
public function testIsPartiallyFilledReturnsFalseIfCompletelyFilled()
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||
|
||||
@ -394,7 +394,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertFalse($form->isPartiallyFilled());
|
||||
}
|
||||
|
||||
public function testIsPartiallyFilled_returnsFalseIfCompletelyFilled_withSeconds()
|
||||
public function testIsPartiallyFilledReturnsFalseIfCompletelyFilledWithSeconds()
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||
|
||||
@ -412,7 +412,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertFalse($form->isPartiallyFilled());
|
||||
}
|
||||
|
||||
public function testIsPartiallyFilled_returnsTrueIfChoiceAndHourEmpty()
|
||||
public function testIsPartiallyFilledReturnsTrueIfChoiceAndHourEmpty()
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||
|
||||
@ -430,7 +430,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertTrue($form->isPartiallyFilled());
|
||||
}
|
||||
|
||||
public function testIsPartiallyFilled_returnsTrueIfChoiceAndMinuteEmpty()
|
||||
public function testIsPartiallyFilledReturnsTrueIfChoiceAndMinuteEmpty()
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||
|
||||
@ -448,7 +448,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertTrue($form->isPartiallyFilled());
|
||||
}
|
||||
|
||||
public function testIsPartiallyFilled_returnsTrueIfChoiceAndSecondsEmpty()
|
||||
public function testIsPartiallyFilledReturnsTrueIfChoiceAndSecondsEmpty()
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||
|
||||
@ -540,7 +540,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertSame('Empty second', $view['second']->vars['empty_value']);
|
||||
}
|
||||
|
||||
public function testPassEmptyValueAsPartialArray_addEmptyIfNotRequired()
|
||||
public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'required' => false,
|
||||
@ -557,7 +557,7 @@ class TimeTypeTest extends LocalizedTestCase
|
||||
$this->assertSame('Empty second', $view['second']->vars['empty_value']);
|
||||
}
|
||||
|
||||
public function testPassEmptyValueAsPartialArray_addNullIfRequired()
|
||||
public function testPassEmptyValueAsPartialArrayAddNullIfRequired()
|
||||
{
|
||||
$form = $this->factory->create('time', null, array(
|
||||
'required' => true,
|
||||
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -23,7 +23,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
|
||||
*/
|
||||
class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test__Construct()
|
||||
public function testConstruct()
|
||||
{
|
||||
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
|
||||
|
||||
@ -42,7 +42,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @dataProvider savePathDataProvider
|
||||
*/
|
||||
public function test__ConstructSavePath($savePath, $expectedSavePath, $path)
|
||||
public function testConstructSavePath($savePath, $expectedSavePath, $path)
|
||||
{
|
||||
$handler = new NativeFileSessionHandler($savePath);
|
||||
$this->assertEquals($expectedSavePath, ini_get('session.save_path'));
|
||||
@ -65,7 +65,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function test__ConstructException()
|
||||
public function testConstructException()
|
||||
{
|
||||
$handler = new NativeFileSessionHandler('something;invalid;with;too-many-args');
|
||||
}
|
||||
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -69,7 +69,7 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
// set handling to false otherwise it wont be able to handle further more
|
||||
$handling = false;
|
||||
|
||||
// re-throw the exception as this is a catch-all
|
||||
// re-throw the exception from within HttpKernel as this is a catch-all
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface
|
||||
return array();
|
||||
}
|
||||
|
||||
$profileList = explode("\n", $indexContent);
|
||||
$profileList = array_reverse(explode("\n", $indexContent));
|
||||
$result = array();
|
||||
|
||||
foreach ($profileList as $item) {
|
||||
@ -100,14 +100,6 @@ class RedisProfilerStorage implements ProfilerStorageInterface
|
||||
--$limit;
|
||||
}
|
||||
|
||||
usort($result, function($a, $b) {
|
||||
if ($a['time'] === $b['time']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $a['time'] > $b['time'] ? -1 : 1;
|
||||
});
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
2
src/Symfony/Component/Locale/.gitattributes
vendored
2
src/Symfony/Component/Locale/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -189,7 +189,7 @@ class StubIntlDateFormatter
|
||||
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value ';
|
||||
} elseif (version_compare(\PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceof \DateTime) {
|
||||
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object';
|
||||
if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=') && !is_int($timestamp)) {
|
||||
if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=') && !is_int($timestamp)) {
|
||||
$argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp);
|
||||
}
|
||||
}
|
||||
@ -350,7 +350,7 @@ class StubIntlDateFormatter
|
||||
}
|
||||
|
||||
// In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
|
||||
if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) {
|
||||
if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
|
||||
return date_default_timezone_get();
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@ class StubIntlDateFormatter
|
||||
{
|
||||
if (null === $timeZoneId) {
|
||||
// In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method
|
||||
if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) {
|
||||
if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
|
||||
$timeZoneId = date_default_timezone_get();
|
||||
} else {
|
||||
// TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will
|
||||
|
@ -43,7 +43,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
$formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
|
||||
|
||||
// In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId());
|
||||
} else {
|
||||
$this->assertNull($formatter->getTimeZoneId());
|
||||
@ -56,7 +56,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
$formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
|
||||
|
||||
// In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId());
|
||||
} else {
|
||||
$this->assertNull($formatter->getTimeZoneId());
|
||||
@ -367,7 +367,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
public function formatErrorProvider()
|
||||
{
|
||||
// With PHP 5.5 IntlDateFormatter accepts empty values ('0')
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
return array(
|
||||
array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR')
|
||||
);
|
||||
@ -435,7 +435,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
);
|
||||
|
||||
// As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC
|
||||
if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
// When time zone not exists, uses UTC by default
|
||||
$data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00');
|
||||
$data[] = array(0, 'UTC+04:30', '1970-01-01 00:00:00');
|
||||
@ -452,7 +452,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
{
|
||||
$formatter = $this->createStubFormatter('zzzz');
|
||||
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$formatter->setTimeZone('Pacific/Fiji');
|
||||
} else {
|
||||
$formatter->setTimeZoneId('Pacific/Fiji');
|
||||
@ -466,7 +466,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
$this->skipIfIntlExtensionIsNotLoaded();
|
||||
$formatter = $this->createIntlFormatter('zzzz');
|
||||
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$formatter->setTimeZone('Pacific/Fiji');
|
||||
} else {
|
||||
$formatter->setTimeZoneId('Pacific/Fiji');
|
||||
@ -480,7 +480,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
{
|
||||
$formatter = $this->createStubFormatter('zzzz');
|
||||
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$formatter->setTimeZone('GMT+03:00');
|
||||
} else {
|
||||
$formatter->setTimeZoneId('GMT+03:00');
|
||||
@ -494,7 +494,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
$this->skipIfIntlExtensionIsNotLoaded();
|
||||
$formatter = $this->createIntlFormatter('zzzz');
|
||||
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$formatter->setTimeZone('GMT+03:00');
|
||||
} else {
|
||||
$formatter->setTimeZoneId('GMT+03:00');
|
||||
@ -530,7 +530,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
|
||||
public function testFormatWithDefaultTimezoneStubShouldUseTheTzEnvironmentVariableWhenAvailable()
|
||||
{
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$this->markTestSkipped('StubIntlDateFormatter in PHP 5.5 no longer depends on TZ environment.');
|
||||
}
|
||||
|
||||
@ -553,7 +553,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
|
||||
public function testFormatWithDefaultTimezoneStubShouldUseDefaultDateTimeZoneVariable()
|
||||
{
|
||||
if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$this->markTestSkipped('Only in PHP 5.5 StubIntlDateFormatter depends on default timezone (`date_default_timezone_get()`).');
|
||||
}
|
||||
|
||||
@ -583,7 +583,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
*/
|
||||
public function testFormatWithDefaultTimezoneIntlShouldUseTheTzEnvironmentVariableWhenAvailable()
|
||||
{
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.');
|
||||
}
|
||||
|
||||
@ -612,7 +612,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
*/
|
||||
public function testFormatWithDefaultTimezoneIntlShouldUseDefaultDateTimeZoneVariable()
|
||||
{
|
||||
if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).');
|
||||
}
|
||||
|
||||
@ -1128,7 +1128,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
{
|
||||
$formatter = $this->createStubFormatter();
|
||||
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$formatter->setTimeZone($timeZoneId);
|
||||
} else {
|
||||
$formatter->setTimeZoneId($timeZoneId);
|
||||
@ -1145,7 +1145,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
$this->skipIfIntlExtensionIsNotLoaded();
|
||||
$formatter = $this->createIntlFormatter();
|
||||
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$formatter->setTimeZone($timeZoneId);
|
||||
} else {
|
||||
$formatter->setTimeZoneId($timeZoneId);
|
||||
@ -1164,7 +1164,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
);
|
||||
|
||||
// When time zone not exists, uses UTC by default
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$data[] = array('GMT-0300', 'UTC');
|
||||
$data[] = array('Foo/Bar', 'UTC');
|
||||
$data[] = array('GMT+00:AA', 'UTC');
|
||||
@ -1186,7 +1186,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
{
|
||||
$formatter = $this->createStubFormatter();
|
||||
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$formatter->setTimeZone('GMT+00:30');
|
||||
} else {
|
||||
$formatter->setTimeZoneId('GMT+00:30');
|
||||
@ -1198,7 +1198,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
$this->skipIfIntlExtensionIsNotLoaded();
|
||||
$formatter = $this->createIntlFormatter();
|
||||
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$formatter->setTimeZone('GMT+00:30');
|
||||
} else {
|
||||
$formatter->setTimeZoneId('GMT+00:30');
|
||||
@ -1225,7 +1225,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
||||
|
||||
protected function createDateTime($timestamp = null)
|
||||
{
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) {
|
||||
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
|
||||
$timeZone = date_default_timezone_get();
|
||||
} else {
|
||||
$timeZone = getenv('TZ') ?: 'UTC';
|
||||
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
2
src/Symfony/Component/Process/.gitattributes
vendored
2
src/Symfony/Component/Process/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -30,8 +30,10 @@ class ProcessFailedException extends RuntimeException
|
||||
|
||||
parent::__construct(
|
||||
sprintf(
|
||||
'The command "%s" failed.'."\n\nOutput:\n================\n".$process->getOutput()."\n\nError Output:\n================\n".$process->getErrorOutput(),
|
||||
$process->getCommandLine()
|
||||
'The command "%s" failed.'."\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
|
||||
$process->getCommandLine(),
|
||||
$process->getOutput(),
|
||||
$process->getErrorOutput()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -19,22 +19,23 @@ namespace Symfony\Component\Process;
|
||||
*/
|
||||
class ExecutableFinder
|
||||
{
|
||||
private static $isWindows;
|
||||
|
||||
private $suffixes = array('.exe', '.bat', '.cmd', '.com');
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (null === self::$isWindows) {
|
||||
self::$isWindows = 0 === stripos(PHP_OS, 'win');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces default suffixes of executable.
|
||||
*
|
||||
* @param array $suffixes
|
||||
*/
|
||||
public function setSuffixes(array $suffixes)
|
||||
{
|
||||
$this->suffixes = $suffixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new possible suffix to check for executable.
|
||||
*
|
||||
* @param string $suffix
|
||||
*/
|
||||
public function addSuffix($suffix)
|
||||
{
|
||||
$this->suffixes[] = $suffix;
|
||||
@ -78,7 +79,7 @@ class ExecutableFinder
|
||||
}
|
||||
foreach ($suffixes as $suffix) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && (self::$isWindows || is_executable($file))) {
|
||||
if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && (defined('PHP_WINDOWS_VERSION_BUILD') || is_executable($file))) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,6 @@ class PhpProcess extends Process
|
||||
$this->setCommandLine($php);
|
||||
}
|
||||
|
||||
return parent::start($callback);
|
||||
parent::start($callback);
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class Process
|
||||
}
|
||||
|
||||
$this->commandline = $commandline;
|
||||
$this->cwd = null === $cwd ? getcwd() : $cwd;
|
||||
$this->cwd = $cwd;
|
||||
if (null !== $env) {
|
||||
$this->env = array();
|
||||
foreach ($env as $key => $value) {
|
||||
@ -176,7 +176,7 @@ class Process
|
||||
* The STDOUT and STDERR are also available after the process is finished
|
||||
* via the getOutput() and getErrorOutput() methods.
|
||||
*
|
||||
* @param callable $callback A PHP callback to run whenever there is some
|
||||
* @param callback|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
*
|
||||
* @return integer The exit status code
|
||||
@ -207,7 +207,7 @@ class Process
|
||||
* with true as a second parameter then the callback will get all data occurred
|
||||
* in (and since) the start call.
|
||||
*
|
||||
* @param callable $callback A PHP callback to run whenever there is some
|
||||
* @param callback|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
*
|
||||
* @throws RuntimeException When process can't be launch or is stopped
|
||||
@ -364,11 +364,12 @@ class Process
|
||||
* from the output in real-time while writing the standard input to the process.
|
||||
* It allows to have feedback from the independent process during execution.
|
||||
*
|
||||
* @param callable $callback A valid PHP callback
|
||||
* @param callback|null $callback A valid PHP callback
|
||||
*
|
||||
* @return int The exitcode of the process
|
||||
* @return integer The exitcode of the process
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws \RuntimeException When process timed out
|
||||
* @throws \RuntimeException When process stopped after receiving signal
|
||||
*/
|
||||
public function wait($callback = null)
|
||||
{
|
||||
@ -538,8 +539,6 @@ class Process
|
||||
*
|
||||
* @return string A string representation for the exit status code
|
||||
*
|
||||
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
|
||||
*
|
||||
* @see http://tldp.org/LDP/abs/html/exitcodes.html
|
||||
* @see http://en.wikipedia.org/wiki/Unix_signal
|
||||
*/
|
||||
@ -555,8 +554,6 @@ class Process
|
||||
*
|
||||
* @return Boolean true if the process ended successfully, false otherwise
|
||||
*
|
||||
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isSuccessful()
|
||||
@ -695,7 +692,7 @@ class Process
|
||||
/**
|
||||
* Stops the process.
|
||||
*
|
||||
* @param integer $timeout The timeout in seconds
|
||||
* @param integer|float $timeout The timeout in seconds
|
||||
*
|
||||
* @return integer The exit-code of the process
|
||||
*
|
||||
@ -823,6 +820,13 @@ class Process
|
||||
*/
|
||||
public function getWorkingDirectory()
|
||||
{
|
||||
// This is for BC only
|
||||
if (null === $this->cwd) {
|
||||
// getcwd() will return false if any one of the parent directories does not have
|
||||
// the readable or search mode set, even if the current directory does
|
||||
return getcwd() ?: null;
|
||||
}
|
||||
|
||||
return $this->cwd;
|
||||
}
|
||||
|
||||
@ -972,9 +976,9 @@ class Process
|
||||
* The callbacks adds all occurred output to the specific buffer and calls
|
||||
* the user callback (if present) with the received output.
|
||||
*
|
||||
* @param callable $callback The user defined PHP callback
|
||||
* @param callback|null $callback The user defined PHP callback
|
||||
*
|
||||
* @return mixed A PHP callable
|
||||
* @return callback A PHP callable
|
||||
*/
|
||||
protected function buildCallback($callback)
|
||||
{
|
||||
@ -1014,6 +1018,9 @@ class Process
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current error output of the process (STDERR).
|
||||
*/
|
||||
protected function updateErrorOutput()
|
||||
{
|
||||
if (isset($this->pipes[self::STDERR]) && is_resource($this->pipes[self::STDERR])) {
|
||||
@ -1021,6 +1028,9 @@ class Process
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current output of the process (STDOUT).
|
||||
*/
|
||||
protected function updateOutput()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD') && isset($this->fileHandles[self::STDOUT]) && is_resource($this->fileHandles[self::STDOUT])) {
|
||||
|
@ -18,8 +18,6 @@ use Symfony\Component\Process\Process;
|
||||
*/
|
||||
abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array());
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
|
||||
*/
|
||||
@ -367,4 +365,16 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $commandline
|
||||
* @param null $cwd
|
||||
* @param array $env
|
||||
* @param null $stdin
|
||||
* @param integer $timeout
|
||||
* @param array $options
|
||||
*
|
||||
* @return Process
|
||||
*/
|
||||
abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array());
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* tests find() with the env var PHP_PATH
|
||||
*/
|
||||
public function testFindWithPHP_PATH()
|
||||
public function testFindWithPhpPath()
|
||||
{
|
||||
if (defined('PHP_BINARY')) {
|
||||
$this->markTestSkipped('The PHP binary is easily available as of PHP 5.4');
|
||||
|
@ -13,15 +13,6 @@ namespace Symfony\Component\Process\Tests;
|
||||
|
||||
class SigchildDisabledProcessTest extends AbstractProcessTest
|
||||
{
|
||||
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
$process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
$process->setEnhanceSigchildCompatibility(false);
|
||||
|
||||
return $process;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
@ -96,4 +87,15 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
||||
{
|
||||
parent::testIsNotSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
$process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
$process->setEnhanceSigchildCompatibility(false);
|
||||
|
||||
return $process;
|
||||
}
|
||||
}
|
||||
|
@ -13,15 +13,6 @@ namespace Symfony\Component\Process\Tests;
|
||||
|
||||
class SigchildEnabledProcessTest extends AbstractProcessTest
|
||||
{
|
||||
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
$process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
$process->setEnhanceSigchildCompatibility(true);
|
||||
|
||||
return $process;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
@ -62,4 +53,14 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
||||
$this->assertInternalType('string', $process->getExitCodeText());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
$process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
$process->setEnhanceSigchildCompatibility(true);
|
||||
|
||||
return $process;
|
||||
}
|
||||
}
|
||||
|
@ -15,20 +15,14 @@ use Symfony\Component\Process\Process;
|
||||
|
||||
class SimpleProcessTest extends AbstractProcessTest
|
||||
{
|
||||
private $enabledSigchild = false;
|
||||
|
||||
protected function skipIfPHPSigchild()
|
||||
public function setUp()
|
||||
{
|
||||
ob_start();
|
||||
phpinfo(INFO_GENERAL);
|
||||
|
||||
if (false !== strpos(ob_get_clean(), '--enable-sigchild')) {
|
||||
$this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
|
||||
}
|
||||
}
|
||||
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
return new Process($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
$this->enabledSigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
|
||||
}
|
||||
|
||||
public function testGetExitCode()
|
||||
@ -84,4 +78,19 @@ class SimpleProcessTest extends AbstractProcessTest
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testIsNotSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
return new Process($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
}
|
||||
|
||||
private function skipIfPHPSigchild()
|
||||
{
|
||||
if ($this->enabledSigchild) {
|
||||
$this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
src/Symfony/Component/Routing/.gitattributes
vendored
2
src/Symfony/Component/Routing/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -47,7 +47,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->validator = null;
|
||||
}
|
||||
|
||||
public function testValidate_defaultGroup()
|
||||
public function testValidateDefaultGroup()
|
||||
{
|
||||
$entity = new Entity();
|
||||
$metadata = new ClassMetadata(get_class($entity));
|
||||
@ -71,7 +71,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($violations, $this->validator->validate($entity));
|
||||
}
|
||||
|
||||
public function testValidate_oneGroup()
|
||||
public function testValidateOneGroup()
|
||||
{
|
||||
$entity = new Entity();
|
||||
$metadata = new ClassMetadata(get_class($entity));
|
||||
@ -95,7 +95,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($violations, $this->validator->validate($entity, 'Custom'));
|
||||
}
|
||||
|
||||
public function testValidate_multipleGroups()
|
||||
public function testValidateMultipleGroups()
|
||||
{
|
||||
$entity = new Entity();
|
||||
$metadata = new ClassMetadata(get_class($entity));
|
||||
@ -131,7 +131,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($violations, $result);
|
||||
}
|
||||
|
||||
public function testValidate_groupSequenceProvider()
|
||||
public function testValidateGroupSequenceProvider()
|
||||
{
|
||||
$entity = new GroupSequenceProviderEntity();
|
||||
$metadata = new ClassMetadata(get_class($entity));
|
||||
|
2
src/Symfony/Component/Yaml/.gitattributes
vendored
2
src/Symfony/Component/Yaml/.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
/Tests export-ignore
|
||||
phpunit.xml.dist export-ignore
|
@ -40,17 +40,19 @@ class Dumper
|
||||
*
|
||||
* @param mixed $input The PHP value
|
||||
* @param integer $inline The level where you switch to inline YAML
|
||||
* @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
||||
* @param Boolean $objectSupport true if object support is enabled, false otherwise
|
||||
* @param integer $indent The level of indentation (used internally)
|
||||
*
|
||||
* @return string The YAML representation of the PHP value
|
||||
*/
|
||||
public function dump($input, $inline = 0, $indent = 0)
|
||||
public function dump($input, $inline = 0, $exceptionOnInvalidType = false, $objectSupport = false, $indent = 0)
|
||||
{
|
||||
$output = '';
|
||||
$prefix = $indent ? str_repeat(' ', $indent) : '';
|
||||
|
||||
if ($inline <= 0 || !is_array($input) || empty($input)) {
|
||||
$output .= $prefix.Inline::dump($input);
|
||||
$output .= $prefix.Inline::dump($input, $exceptionOnInvalidType, $objectSupport);
|
||||
} else {
|
||||
$isAHash = array_keys($input) !== range(0, count($input) - 1);
|
||||
|
||||
@ -59,9 +61,9 @@ class Dumper
|
||||
|
||||
$output .= sprintf('%s%s%s%s',
|
||||
$prefix,
|
||||
$isAHash ? Inline::dump($key).':' : '-',
|
||||
$isAHash ? Inline::dump($key, $exceptionOnInvalidType, $objectSupport).':' : '-',
|
||||
$willBeInlined ? ' ' : "\n",
|
||||
$this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation)
|
||||
$this->dump($value, $inline - 1, $exceptionOnInvalidType, $objectSupport, $willBeInlined ? 0 : $indent + $this->indentation)
|
||||
).($willBeInlined ? "\n" : '');
|
||||
}
|
||||
}
|
||||
|
@ -22,17 +22,25 @@ class Inline
|
||||
{
|
||||
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')';
|
||||
|
||||
private static $exceptionOnInvalidType = false;
|
||||
private static $objectSupport = false;
|
||||
|
||||
/**
|
||||
* Converts a YAML string to a PHP array.
|
||||
*
|
||||
* @param string $value A YAML string
|
||||
* @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
||||
* @param Boolean $objectSupport true if object support is enabled, false otherwise
|
||||
*
|
||||
* @return array A PHP array representing the YAML string
|
||||
*
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static function parse($value)
|
||||
public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false)
|
||||
{
|
||||
self::$exceptionOnInvalidType = $exceptionOnInvalidType;
|
||||
self::$objectSupport = $objectSupport;
|
||||
|
||||
$value = trim($value);
|
||||
|
||||
if (0 == strlen($value)) {
|
||||
@ -72,20 +80,34 @@ class Inline
|
||||
* Dumps a given PHP variable to a YAML string.
|
||||
*
|
||||
* @param mixed $value The PHP variable to convert
|
||||
* @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
||||
* @param Boolean $objectSupport true if object support is enabled, false otherwise
|
||||
*
|
||||
* @return string The YAML string representing the PHP array
|
||||
*
|
||||
* @throws DumpException When trying to dump PHP resource
|
||||
*/
|
||||
public static function dump($value)
|
||||
public static function dump($value, $exceptionOnInvalidType = false, $objectSupport = false)
|
||||
{
|
||||
switch (true) {
|
||||
case is_resource($value):
|
||||
if ($exceptionOnInvalidType) {
|
||||
throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
|
||||
}
|
||||
|
||||
return 'null';
|
||||
case is_object($value):
|
||||
if ($objectSupport) {
|
||||
return '!!php/object:'.serialize($value);
|
||||
}
|
||||
|
||||
if ($exceptionOnInvalidType) {
|
||||
throw new DumpException('Object support when dumping a YAML file has been disabled.');
|
||||
}
|
||||
|
||||
return 'null';
|
||||
case is_array($value):
|
||||
return self::dumpArray($value);
|
||||
return self::dumpArray($value, $exceptionOnInvalidType, $objectSupport);
|
||||
case null === $value:
|
||||
return 'null';
|
||||
case true === $value:
|
||||
@ -124,10 +146,12 @@ class Inline
|
||||
* Dumps a PHP array to a YAML string.
|
||||
*
|
||||
* @param array $value The PHP array to dump
|
||||
* @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
||||
* @param Boolean $objectSupport true if object support is enabled, false otherwise
|
||||
*
|
||||
* @return string The YAML string representing the PHP array
|
||||
*/
|
||||
private static function dumpArray($value)
|
||||
private static function dumpArray($value, $exceptionOnInvalidType, $objectSupport)
|
||||
{
|
||||
// array
|
||||
$keys = array_keys($value);
|
||||
@ -136,7 +160,7 @@ class Inline
|
||||
) {
|
||||
$output = array();
|
||||
foreach ($value as $val) {
|
||||
$output[] = self::dump($val);
|
||||
$output[] = self::dump($val, $exceptionOnInvalidType, $objectSupport);
|
||||
}
|
||||
|
||||
return sprintf('[%s]', implode(', ', $output));
|
||||
@ -145,7 +169,7 @@ class Inline
|
||||
// mapping
|
||||
$output = array();
|
||||
foreach ($value as $key => $val) {
|
||||
$output[] = sprintf('%s: %s', self::dump($key), self::dump($val));
|
||||
$output[] = sprintf('%s: %s', self::dump($key, $exceptionOnInvalidType, $objectSupport), self::dump($val, $exceptionOnInvalidType, $objectSupport));
|
||||
}
|
||||
|
||||
return sprintf('{ %s }', implode(', ', $output));
|
||||
@ -375,7 +399,15 @@ class Inline
|
||||
case 0 === strpos($scalar, '! '):
|
||||
return intval(self::parseScalar(substr($scalar, 2)));
|
||||
case 0 === strpos($scalar, '!!php/object:'):
|
||||
if (self::$objectSupport) {
|
||||
return unserialize(substr($scalar, 13));
|
||||
}
|
||||
|
||||
if (self::$exceptionOnInvalidType) {
|
||||
throw new ParseException('Object support when parsing a YAML file has been disabled.');
|
||||
}
|
||||
|
||||
return null;
|
||||
case ctype_digit($scalar):
|
||||
$raw = $scalar;
|
||||
$cast = intval($scalar);
|
||||
|
@ -39,12 +39,14 @@ class Parser
|
||||
* Parses a YAML string to a PHP value.
|
||||
*
|
||||
* @param string $value A YAML string
|
||||
* @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
||||
* @param Boolean $objectSupport true if object support is enabled, false otherwise
|
||||
*
|
||||
* @return mixed A PHP value
|
||||
*
|
||||
* @throws ParseException If the YAML is not valid
|
||||
*/
|
||||
public function parse($value)
|
||||
public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false)
|
||||
{
|
||||
$this->currentLineNb = -1;
|
||||
$this->currentLine = '';
|
||||
@ -88,7 +90,7 @@ class Parser
|
||||
$c = $this->getRealCurrentLineNb() + 1;
|
||||
$parser = new Parser($c);
|
||||
$parser->refs =& $this->refs;
|
||||
$data[] = $parser->parse($this->getNextEmbedBlock());
|
||||
$data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport);
|
||||
} else {
|
||||
if (isset($values['leadspaces'])
|
||||
&& ' ' == $values['leadspaces']
|
||||
@ -104,9 +106,9 @@ class Parser
|
||||
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2);
|
||||
}
|
||||
|
||||
$data[] = $parser->parse($block);
|
||||
$data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport);
|
||||
} else {
|
||||
$data[] = $this->parseValue($values['value']);
|
||||
$data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport);
|
||||
}
|
||||
}
|
||||
} elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
|
||||
@ -115,6 +117,8 @@ class Parser
|
||||
}
|
||||
$context = 'mapping';
|
||||
|
||||
// force correct settings
|
||||
Inline::parse(null, $exceptionOnInvalidType, $objectSupport);
|
||||
try {
|
||||
$key = Inline::parseScalar($values['key']);
|
||||
} catch (ParseException $e) {
|
||||
@ -139,7 +143,7 @@ class Parser
|
||||
$c = $this->getRealCurrentLineNb() + 1;
|
||||
$parser = new Parser($c);
|
||||
$parser->refs =& $this->refs;
|
||||
$parsed = $parser->parse($value);
|
||||
$parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport);
|
||||
|
||||
$merged = array();
|
||||
if (!is_array($parsed)) {
|
||||
@ -176,20 +180,20 @@ class Parser
|
||||
$c = $this->getRealCurrentLineNb() + 1;
|
||||
$parser = new Parser($c);
|
||||
$parser->refs =& $this->refs;
|
||||
$data[$key] = $parser->parse($this->getNextEmbedBlock());
|
||||
$data[$key] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport);
|
||||
}
|
||||
} else {
|
||||
if ($isInPlace) {
|
||||
$data = $this->refs[$isInPlace];
|
||||
} else {
|
||||
$data[$key] = $this->parseValue($values['value']);
|
||||
$data[$key] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 1-liner followed by newline
|
||||
if (2 == count($this->lines) && empty($this->lines[1])) {
|
||||
try {
|
||||
$value = Inline::parse($this->lines[0]);
|
||||
$value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport);
|
||||
} catch (ParseException $e) {
|
||||
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
|
||||
$e->setSnippet($this->currentLine);
|
||||
@ -366,7 +370,7 @@ class Parser
|
||||
*
|
||||
* @throws ParseException When reference does not exist
|
||||
*/
|
||||
private function parseValue($value)
|
||||
private function parseValue($value, $exceptionOnInvalidType, $objectSupport)
|
||||
{
|
||||
if (0 === strpos($value, '*')) {
|
||||
if (false !== $pos = strpos($value, '#')) {
|
||||
@ -389,7 +393,7 @@ class Parser
|
||||
}
|
||||
|
||||
try {
|
||||
return Inline::parse($value);
|
||||
return Inline::parse($value, $exceptionOnInvalidType, $objectSupport);
|
||||
} catch (ParseException $e) {
|
||||
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
|
||||
$e->setSnippet($this->currentLine);
|
||||
|
@ -152,11 +152,26 @@ EOF;
|
||||
$this->assertEquals($expected, $this->dumper->dump($array, 10), '->dump() takes an inline level argument');
|
||||
}
|
||||
|
||||
public function testObjectsSupport()
|
||||
public function testObjectSupportEnabled()
|
||||
{
|
||||
$a = array('foo' => new A(), 'bar' => 1);
|
||||
$dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, false, true);
|
||||
|
||||
$this->assertEquals('{ foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $this->dumper->dump($a), '->dump() is able to dump objects');
|
||||
$this->assertEquals('{ foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $dump, '->dump() is able to dump objects');
|
||||
}
|
||||
|
||||
public function testObjectSupportDisabledButNoExceptions()
|
||||
{
|
||||
$dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1));
|
||||
|
||||
$this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\DumpException
|
||||
*/
|
||||
public function testObjectSupportDisabledWithExceptions()
|
||||
{
|
||||
$this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
|
||||
class ParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -106,14 +105,31 @@ EOF;
|
||||
$this->assertEquals('foo', $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testObjectsSupport()
|
||||
public function testObjectSupportEnabled()
|
||||
{
|
||||
$b = array('foo' => new B(), 'bar' => 1);
|
||||
$this->assertEquals($this->parser->parse(<<<EOF
|
||||
$input = <<<EOF
|
||||
foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
EOF
|
||||
), $b, '->parse() is able to dump objects');
|
||||
EOF;
|
||||
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');
|
||||
}
|
||||
|
||||
public function testObjectSupportDisabledButNoExceptions()
|
||||
{
|
||||
$input = <<<EOF
|
||||
foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
EOF;
|
||||
|
||||
$this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testObjectsSupportDisabledWithExceptions()
|
||||
{
|
||||
$this->parser->parse('foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}', true, false);
|
||||
}
|
||||
|
||||
public function testNonUtf8Exception()
|
||||
|
@ -22,13 +22,53 @@ use Symfony\Component\Yaml\Exception\ParseException;
|
||||
*/
|
||||
class Yaml
|
||||
{
|
||||
/**
|
||||
* Be warned that PHP support will be removed in Symfony 2.3.
|
||||
*
|
||||
* @deprecated Deprecated since version 2.0, to be removed in 2.3.
|
||||
*/
|
||||
public static $enablePhpParsing = false;
|
||||
|
||||
/**
|
||||
* Enables PHP support when parsing YAML files.
|
||||
*
|
||||
* Be warned that PHP support will be removed in Symfony 2.3.
|
||||
*
|
||||
* @deprecated Deprecated since version 2.0, to be removed in 2.3.
|
||||
*/
|
||||
public static function enablePhpParsing()
|
||||
{
|
||||
self::$enablePhpParsing = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PHP support flag when parsing YAML files.
|
||||
*
|
||||
* Be warned that PHP support will be removed in Symfony 2.3.
|
||||
*
|
||||
* @param Boolean $boolean true if PHP parsing support is enabled, false otherwise
|
||||
*
|
||||
* @deprecated Deprecated since version 2.0, to be removed in 2.3.
|
||||
*/
|
||||
public static function setPhpParsing($boolean)
|
||||
{
|
||||
self::$enablePhpParsing = (Boolean) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if PHP support is enabled when parsing YAML files.
|
||||
*
|
||||
* Be warned that PHP support will be removed in Symfony 2.3.
|
||||
*
|
||||
* @return Boolean true if PHP parsing support is enabled, false otherwise
|
||||
*
|
||||
* @deprecated Deprecated since version 2.0, to be removed in 2.3.
|
||||
*/
|
||||
public static function supportsPhpParsing()
|
||||
{
|
||||
return self::$enablePhpParsing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses YAML into a PHP array.
|
||||
*
|
||||
@ -53,7 +93,7 @@ class Yaml
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public static function parse($input)
|
||||
public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false)
|
||||
{
|
||||
// if input is a file, process it
|
||||
$file = '';
|
||||
@ -83,7 +123,7 @@ class Yaml
|
||||
$yaml = new Parser();
|
||||
|
||||
try {
|
||||
return $yaml->parse($input);
|
||||
return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport);
|
||||
} catch (ParseException $e) {
|
||||
if ($file) {
|
||||
$e->setParsedFile($file);
|
||||
@ -102,16 +142,18 @@ class Yaml
|
||||
* @param array $array PHP array
|
||||
* @param integer $inline The level where you switch to inline YAML
|
||||
* @param integer $indent The amount of spaces to use for indentation of nested nodes.
|
||||
* @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
||||
* @param Boolean $objectSupport true if object support is enabled, false otherwise
|
||||
*
|
||||
* @return string A YAML string representing the original PHP array
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public static function dump($array, $inline = 2, $indent = 4)
|
||||
public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false)
|
||||
{
|
||||
$yaml = new Dumper();
|
||||
$yaml->setIndentation($indent);
|
||||
|
||||
return $yaml->dump($array, $inline);
|
||||
return $yaml->dump($array, $inline, $exceptionOnInvalidType, $objectSupport);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user