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:
Fabien Potencier 2013-01-17 16:25:59 +01:00
commit 1f762c7723
73 changed files with 406 additions and 310 deletions

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -351,7 +351,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertSame(array('1', '3'), $field->getClientData()); $this->assertSame(array('1', '3'), $field->getClientData());
} }
public function testSubmitMultipleNonExpandedSingleIdentifier_existingData() public function testSubmitMultipleNonExpandedSingleIdentifierForExistingData()
{ {
$entity1 = new SingleIdentEntity(1, 'Foo'); $entity1 = new SingleIdentEntity(1, 'Foo');
$entity2 = new SingleIdentEntity(2, 'Bar'); $entity2 = new SingleIdentEntity(2, 'Bar');
@ -408,7 +408,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertSame(array('0', '2'), $field->getClientData()); $this->assertSame(array('0', '2'), $field->getClientData());
} }
public function testSubmitMultipleNonExpandedCompositeIdentifier_existingData() public function testSubmitMultipleNonExpandedCompositeIdentifierExistingData()
{ {
$entity1 = new CompositeIdentEntity(10, 20, 'Foo'); $entity1 = new CompositeIdentEntity(10, 20, 'Foo');
$entity2 = new CompositeIdentEntity(30, 40, 'Bar'); $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']); $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'); $entity1 = new SingleIdentEntity(1, 'Foo');
$entity2 = new SingleIdentEntity(2, 'Bar'); $entity2 = new SingleIdentEntity(2, 'Bar');
@ -605,7 +605,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertNull($field->getData()); $this->assertNull($field->getData());
} }
public function testDisallowChoicesThatAreNotIncluded_choicesCompositeIdentifier() public function testDisallowChoicesThatAreNotIncludedChoicesCompositeIdentifier()
{ {
$entity1 = new CompositeIdentEntity(10, 20, 'Foo'); $entity1 = new CompositeIdentEntity(10, 20, 'Foo');
$entity2 = new CompositeIdentEntity(30, 40, 'Bar'); $entity2 = new CompositeIdentEntity(30, 40, 'Bar');

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -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; static $dumper;
@ -39,20 +39,20 @@ class YamlExtension extends \Twig_Extension
$dumper = new YamlDumper(); $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)) { if (is_resource($value)) {
return '%Resource%'; return '%Resource%';
} }
if (is_array($value) || is_object($value)) { 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);
} }
/** /**

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -215,12 +215,14 @@ class ArgvInput extends Input
$option = $this->definition->getOption($name); $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 // if option accepts an optional or mandatory argument
// let's see if there is one provided // let's see if there is one provided
$next = array_shift($this->parsed); $next = array_shift($this->parsed);
if ('-' !== $next[0]) { if (isset($next[0]) && '-' !== $next[0]) {
$value = $next; $value = $next;
} elseif (empty($next)) {
$value = '';
} else { } else {
array_unshift($this->parsed, $next); array_unshift($this->parsed, $next);
} }

View File

@ -8,4 +8,4 @@ class Foo4Command extends Command
{ {
$this->setName('foo3:bar:toh'); $this->setName('foo3:bar:toh');
} }
} }

View File

@ -71,6 +71,18 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); $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)'); $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 = 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')))); $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'); $this->assertEquals(array('foo' => null, 'bar' => true), $input->getOptions(), '->parse() parses short options with an optional value which is not present');

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -48,7 +48,7 @@ class GenericEventTest extends \PHPUnit_Framework_TestCase
parent::tearDown(); parent::tearDown();
} }
public function test__construct() public function testConstruct()
{ {
$this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event'))); $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event')));
} }

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -268,7 +268,11 @@ class DateType extends AbstractType
$pattern = $formatter->getPattern(); $pattern = $formatter->getPattern();
$timezone = $formatter->getTimezoneId(); $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)) { if (preg_match($regex, $pattern, $matches)) {
$formatter->setPattern($matches[0]); $formatter->setPattern($matches[0]);
@ -282,7 +286,11 @@ class DateType extends AbstractType
$formatter->setPattern($pattern); $formatter->setPattern($pattern);
} }
$formatter->setTimezoneId($timezone); if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
$formatter->setTimeZone($timezone);
} else {
$formatter->setTimeZoneId($timezone);
}
return $timestamps; return $timestamps;
} }

View File

@ -57,7 +57,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase
$this->assertSame($output, $this->transformer->transform($input)); $this->assertSame($output, $this->transformer->transform($input));
} }
public function testTransform_empty() public function testTransformEmpty()
{ {
$output = array( $output = array(
'first' => null, 'first' => null,
@ -102,7 +102,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase
$this->assertSame($output, $this->transformer->reverseTransform($input)); $this->assertSame($output, $this->transformer->reverseTransform($input));
} }
public function testReverseTransform_completelyEmpty() public function testReverseTransformCompletelyEmpty()
{ {
$input = array( $input = array(
'first' => '', 'first' => '',
@ -112,7 +112,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase
$this->assertNull($this->transformer->reverseTransform($input)); $this->assertNull($this->transformer->reverseTransform($input));
} }
public function testReverseTransform_completelyNull() public function testReverseTransformCompletelyNull()
{ {
$input = array( $input = array(
'first' => null, 'first' => null,
@ -125,7 +125,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testReverseTransform_partiallyNull() public function testReverseTransformPartiallyNull()
{ {
$input = array( $input = array(
'first' => array( 'first' => array(

View File

@ -33,7 +33,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
$this->assertSame($output, $transformer->transform($input)); $this->assertSame($output, $transformer->transform($input));
} }
public function testTransform_empty() public function testTransformEmpty()
{ {
$transformer = new DateTimeToArrayTransformer(); $transformer = new DateTimeToArrayTransformer();
@ -49,7 +49,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
$this->assertSame($output, $transformer->transform(null)); $this->assertSame($output, $transformer->transform(null));
} }
public function testTransform_empty_withFields() public function testTransformEmptyWithFields()
{ {
$transformer = new DateTimeToArrayTransformer(null, null, array('year', 'minute', 'second')); $transformer = new DateTimeToArrayTransformer(null, null, array('year', 'minute', 'second'));
@ -62,7 +62,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
$this->assertSame($output, $transformer->transform(null)); $this->assertSame($output, $transformer->transform(null));
} }
public function testTransform_withFields() public function testTransformWithFields()
{ {
$transformer = new DateTimeToArrayTransformer('UTC', 'UTC', array('year', 'month', 'minute', 'second')); $transformer = new DateTimeToArrayTransformer('UTC', 'UTC', array('year', 'month', 'minute', 'second'));
@ -78,7 +78,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
$this->assertSame($output, $transformer->transform($input)); $this->assertSame($output, $transformer->transform($input));
} }
public function testTransform_withPadding() public function testTransformWithPadding()
{ {
$transformer = new DateTimeToArrayTransformer('UTC', 'UTC', null, true); $transformer = new DateTimeToArrayTransformer('UTC', 'UTC', null, true);
@ -96,7 +96,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
$this->assertSame($output, $transformer->transform($input)); $this->assertSame($output, $transformer->transform($input));
} }
public function testTransform_differentTimezones() public function testTransformDifferentTimezones()
{ {
$transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong'); $transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong');
@ -161,7 +161,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input)); $this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
} }
public function testReverseTransform_completelyEmpty() public function testReverseTransformCompletelyEmpty()
{ {
$transformer = new DateTimeToArrayTransformer(); $transformer = new DateTimeToArrayTransformer();
@ -177,7 +177,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
$this->assertNull($transformer->reverseTransform($input)); $this->assertNull($transformer->reverseTransform($input));
} }
public function testReverseTransform_completelyEmpty_subsetOfFields() public function testReverseTransformCompletelyEmptySubsetOfFields()
{ {
$transformer = new DateTimeToArrayTransformer(null, null, array('year', 'month', 'day')); $transformer = new DateTimeToArrayTransformer(null, null, array('year', 'month', 'day'));
@ -193,7 +193,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testReverseTransform_partiallyEmpty_year() public function testReverseTransformPartiallyEmptyYear()
{ {
$transformer = new DateTimeToArrayTransformer(); $transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform(array( $transformer->reverseTransform(array(
@ -208,7 +208,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testReverseTransform_partiallyEmpty_month() public function testReverseTransformPartiallyEmptyMonth()
{ {
$transformer = new DateTimeToArrayTransformer(); $transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform(array( $transformer->reverseTransform(array(
@ -223,7 +223,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testReverseTransform_partiallyEmpty_day() public function testReverseTransformPartiallyEmptyDay()
{ {
$transformer = new DateTimeToArrayTransformer(); $transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform(array( $transformer->reverseTransform(array(
@ -238,7 +238,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testReverseTransform_partiallyEmpty_hour() public function testReverseTransformPartiallyEmptyHour()
{ {
$transformer = new DateTimeToArrayTransformer(); $transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform(array( $transformer->reverseTransform(array(
@ -253,7 +253,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testReverseTransform_partiallyEmpty_minute() public function testReverseTransformPartiallyEmptyMinute()
{ {
$transformer = new DateTimeToArrayTransformer(); $transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform(array( $transformer->reverseTransform(array(
@ -268,7 +268,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testReverseTransform_partiallyEmpty_second() public function testReverseTransformPartiallyEmptySecond()
{ {
$transformer = new DateTimeToArrayTransformer(); $transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform(array( $transformer->reverseTransform(array(
@ -280,14 +280,14 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
)); ));
} }
public function testReverseTransform_null() public function testReverseTransformNull()
{ {
$transformer = new DateTimeToArrayTransformer(); $transformer = new DateTimeToArrayTransformer();
$this->assertNull($transformer->reverseTransform(null)); $this->assertNull($transformer->reverseTransform(null));
} }
public function testReverseTransform_differentTimezones() public function testReverseTransformDifferentTimezones()
{ {
$transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong'); $transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong');

View File

@ -121,14 +121,14 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
$this->assertEquals('Feb 3, 2010 4:05 AM', $transformer->transform($this->dateTime)); $this->assertEquals('Feb 3, 2010 4:05 AM', $transformer->transform($this->dateTime));
} }
public function testTransform_empty() public function testTransformEmpty()
{ {
$transformer = new DateTimeToLocalizedStringTransformer(); $transformer = new DateTimeToLocalizedStringTransformer();
$this->assertSame('', $transformer->transform(null)); $this->assertSame('', $transformer->transform(null));
} }
public function testTransform_differentTimezones() public function testTransformWithDifferentTimezones()
{ {
$transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong'); $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)); $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'); $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')); $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'); $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')); $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'); $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')); $this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('02*2010*03 04|05|06'));
} }
public function testReverseTransform_empty() public function testReverseTransformEmpty()
{ {
$transformer = new DateTimeToLocalizedStringTransformer(); $transformer = new DateTimeToLocalizedStringTransformer();

View File

@ -79,14 +79,14 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
$this->assertEquals($output, $transformer->transform($input)); $this->assertEquals($output, $transformer->transform($input));
} }
public function testTransform_empty() public function testTransformEmpty()
{ {
$transformer = new DateTimeToStringTransformer(); $transformer = new DateTimeToStringTransformer();
$this->assertSame('', $transformer->transform(null)); $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'); $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)); $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
} }
public function testReverseTransform_empty() public function testReverseTransformEmpty()
{ {
$reverseTransformer = new DateTimeToStringTransformer(); $reverseTransformer = new DateTimeToStringTransformer();
$this->assertNull($reverseTransformer->reverseTransform('')); $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'); $reverseTransformer = new DateTimeToStringTransformer('America/New_York', 'Asia/Hong_Kong', 'Y-m-d H:i:s');

View File

@ -25,14 +25,14 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase
$this->assertEquals($output, $transformer->transform($input)); $this->assertEquals($output, $transformer->transform($input));
} }
public function testTransform_empty() public function testTransformEmpty()
{ {
$transformer = new DateTimeToTimestampTransformer(); $transformer = new DateTimeToTimestampTransformer();
$this->assertNull($transformer->transform(null)); $this->assertNull($transformer->transform(null));
} }
public function testTransform_differentTimezones() public function testTransformWithDifferentTimezones()
{ {
$transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York'); $transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York');
@ -75,14 +75,14 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase
$this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
} }
public function testReverseTransform_empty() public function testReverseTransformEmpty()
{ {
$reverseTransformer = new DateTimeToTimestampTransformer(); $reverseTransformer = new DateTimeToTimestampTransformer();
$this->assertNull($reverseTransformer->reverseTransform(null)); $this->assertNull($reverseTransformer->reverseTransform(null));
} }
public function testReverseTransform_differentTimezones() public function testReverseTransformWithDifferentTimezones()
{ {
$reverseTransformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York'); $reverseTransformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York');

View File

@ -32,7 +32,7 @@ class IntegerToLocalizedStringTransformerTest extends LocalizedTestCase
$this->assertEquals(12345, $transformer->reverseTransform('12345,912')); $this->assertEquals(12345, $transformer->reverseTransform('12345,912'));
} }
public function testReverseTransform_empty() public function testReverseTransformEmpty()
{ {
$transformer = new IntegerToLocalizedStringTransformer(); $transformer = new IntegerToLocalizedStringTransformer();

View File

@ -38,7 +38,7 @@ class MoneyToLocalizedStringTransformerTest extends LocalizedTestCase
$transformer->transform('abcd'); $transformer->transform('abcd');
} }
public function testTransform_empty() public function testTransformEmpty()
{ {
$transformer = new MoneyToLocalizedStringTransformer(); $transformer = new MoneyToLocalizedStringTransformer();
@ -61,7 +61,7 @@ class MoneyToLocalizedStringTransformerTest extends LocalizedTestCase
$transformer->reverseTransform(12345); $transformer->reverseTransform(12345);
} }
public function testReverseTransform_empty() public function testReverseTransformEmpty()
{ {
$transformer = new MoneyToLocalizedStringTransformer(); $transformer = new MoneyToLocalizedStringTransformer();

View File

@ -32,7 +32,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
$this->assertEquals('12345,912', $transformer->transform(12345.9123)); $this->assertEquals('12345,912', $transformer->transform(12345.9123));
} }
public function testTransform_empty() public function testTransformEmpty()
{ {
$transformer = new NumberToLocalizedStringTransformer(); $transformer = new NumberToLocalizedStringTransformer();
@ -75,7 +75,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
$this->assertEquals(12345.912, $transformer->reverseTransform('12345,912')); $this->assertEquals(12345.912, $transformer->reverseTransform('12345,912'));
} }
public function testReverseTransform_empty() public function testReverseTransformEmpty()
{ {
$transformer = new NumberToLocalizedStringTransformer(); $transformer = new NumberToLocalizedStringTransformer();
@ -129,7 +129,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot_noGroupSep() public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep()
{ {
if ($this->isLowerThanIcuVersion('4.7')) { if ($this->isLowerThanIcuVersion('4.7')) {
$this->markTestSkipped('Please upgrade ICU version to 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 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma_noGroupSep() public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep()
{ {
if ($this->isLowerThanIcuVersion('4.7')) { if ($this->isLowerThanIcuVersion('4.7')) {
$this->markTestSkipped('Please upgrade ICU version to 4.7+'); $this->markTestSkipped('Please upgrade ICU version to 4.7+');

View File

@ -32,7 +32,7 @@ class PercentToLocalizedStringTransformerTest extends LocalizedTestCase
$this->assertEquals('200', $transformer->transform(2)); $this->assertEquals('200', $transformer->transform(2));
} }
public function testTransform_empty() public function testTransformEmpty()
{ {
$transformer = new PercentToLocalizedStringTransformer(); $transformer = new PercentToLocalizedStringTransformer();
@ -66,7 +66,7 @@ class PercentToLocalizedStringTransformerTest extends LocalizedTestCase
$this->assertEquals(2, $transformer->reverseTransform('200')); $this->assertEquals(2, $transformer->reverseTransform('200'));
} }
public function testReverseTransform_empty() public function testReverseTransformEmpty()
{ {
$transformer = new PercentToLocalizedStringTransformer(); $transformer = new PercentToLocalizedStringTransformer();

View File

@ -38,7 +38,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
$this->assertSame($output, $this->transformer->transform('Foo')); $this->assertSame($output, $this->transformer->transform('Foo'));
} }
public function testTransform_empty() public function testTransformEmpty()
{ {
$output = array( $output = array(
'a' => null, 'a' => null,
@ -60,7 +60,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
$this->assertSame('Foo', $this->transformer->reverseTransform($input)); $this->assertSame('Foo', $this->transformer->reverseTransform($input));
} }
public function testReverseTransform_completelyEmpty() public function testReverseTransformCompletelyEmpty()
{ {
$input = array( $input = array(
'a' => '', 'a' => '',
@ -71,7 +71,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
$this->assertNull($this->transformer->reverseTransform($input)); $this->assertNull($this->transformer->reverseTransform($input));
} }
public function testReverseTransform_completelyNull() public function testReverseTransformCompletelyNull()
{ {
$input = array( $input = array(
'a' => null, 'a' => null,
@ -85,7 +85,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testReverseTransform_partiallyNull() public function testReverseTransformPartiallyNull()
{ {
$input = array( $input = array(
'a' => 'Foo', 'a' => 'Foo',
@ -99,7 +99,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/ */
public function testReverseTransform_differences() public function testReverseTransformDifferences()
{ {
$input = array( $input = array(
'a' => 'Foo', 'a' => 'Foo',

View File

@ -15,7 +15,7 @@ use Symfony\Component\Form\FormError;
class DateTimeTypeTest extends LocalizedTestCase class DateTimeTypeTest extends LocalizedTestCase
{ {
public function testSubmit_dateTime() public function testSubmitDateTime()
{ {
$form = $this->factory->create('datetime', null, array( $form = $this->factory->create('datetime', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -42,7 +42,7 @@ class DateTimeTypeTest extends LocalizedTestCase
$this->assertDateTimeEquals($dateTime, $form->getData()); $this->assertDateTimeEquals($dateTime, $form->getData());
} }
public function testSubmit_string() public function testSubmitString()
{ {
$form = $this->factory->create('datetime', null, array( $form = $this->factory->create('datetime', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -67,7 +67,7 @@ class DateTimeTypeTest extends LocalizedTestCase
$this->assertEquals('2010-06-02 03:04:00', $form->getData()); $this->assertEquals('2010-06-02 03:04:00', $form->getData());
} }
public function testSubmit_timestamp() public function testSubmitTimestamp()
{ {
$form = $this->factory->create('datetime', null, array( $form = $this->factory->create('datetime', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -94,7 +94,7 @@ class DateTimeTypeTest extends LocalizedTestCase
$this->assertEquals($dateTime->format('U'), $form->getData()); $this->assertEquals($dateTime->format('U'), $form->getData());
} }
public function testSubmit_withoutMinutes() public function testSubmitWithoutMinutes()
{ {
$form = $this->factory->create('datetime', null, array( $form = $this->factory->create('datetime', null, array(
'data_timezone' => 'UTC', 'data_timezone' => 'UTC',
@ -123,7 +123,7 @@ class DateTimeTypeTest extends LocalizedTestCase
$this->assertDateTimeEquals(new \DateTime('2010-06-02 03:00:00 UTC'), $form->getData()); $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( $form = $this->factory->create('datetime', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -154,7 +154,7 @@ class DateTimeTypeTest extends LocalizedTestCase
$this->assertDateTimeEquals(new \DateTime('2010-06-02 03:04:05 UTC'), $form->getData()); $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( $form = $this->factory->create('datetime', null, array(
'model_timezone' => 'America/New_York', '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()); $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( $form = $this->factory->create('datetime', null, array(
'model_timezone' => 'America/New_York', 'model_timezone' => 'America/New_York',
@ -204,7 +204,7 @@ class DateTimeTypeTest extends LocalizedTestCase
$this->assertEquals('2010-06-02T03:04:00-10:00', $form->getViewData()); $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( $form = $this->factory->create('datetime', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -219,7 +219,7 @@ class DateTimeTypeTest extends LocalizedTestCase
$this->assertEquals('2010-06-02T03:04:00Z', $form->getViewData()); $this->assertEquals('2010-06-02T03:04:00Z', $form->getViewData());
} }
public function testSubmit_stringSingleText_withSeconds() public function testSubmitStringSingleTextWithSeconds()
{ {
$form = $this->factory->create('datetime', null, array( $form = $this->factory->create('datetime', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -235,7 +235,7 @@ class DateTimeTypeTest extends LocalizedTestCase
$this->assertEquals('2010-06-02T03:04:05Z', $form->getViewData()); $this->assertEquals('2010-06-02T03:04:05Z', $form->getViewData());
} }
public function testSubmit_differentPattern() public function testSubmitDifferentPattern()
{ {
$form = $this->factory->create('datetime', null, array( $form = $this->factory->create('datetime', null, array(
'date_format' => 'MM*yyyy*dd', 'date_format' => 'MM*yyyy*dd',
@ -343,7 +343,7 @@ class DateTimeTypeTest extends LocalizedTestCase
$this->assertSame('Empty second', $view['time']['second']->vars['empty_value']); $this->assertSame('Empty second', $view['time']['second']->vars['empty_value']);
} }
public function testPassEmptyValueAsPartialArray_addEmptyIfNotRequired() public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired()
{ {
$form = $this->factory->create('datetime', null, array( $form = $this->factory->create('datetime', null, array(
'required' => false, 'required' => false,
@ -365,7 +365,7 @@ class DateTimeTypeTest extends LocalizedTestCase
$this->assertSame('Empty second', $view['time']['second']->vars['empty_value']); $this->assertSame('Empty second', $view['time']['second']->vars['empty_value']);
} }
public function testPassEmptyValueAsPartialArray_addNullIfRequired() public function testPassEmptyValueAsPartialArrayAddNullIfRequired()
{ {
$form = $this->factory->create('datetime', null, array( $form = $this->factory->create('datetime', null, array(
'required' => true, 'required' => true,

View File

@ -313,7 +313,7 @@ class DateTypeTest extends LocalizedTestCase
)); ));
} }
public function testSetData_differentTimezones() public function testSetDataWithDifferentTimezones()
{ {
$form = $this->factory->create('date', null, array( $form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM, 'format' => \IntlDateFormatter::MEDIUM,
@ -328,7 +328,7 @@ class DateTypeTest extends LocalizedTestCase
$this->assertEquals('01.06.2010', $form->getViewData()); $this->assertEquals('01.06.2010', $form->getViewData());
} }
public function testSetData_differentTimezonesDateTime() public function testSetDataWithDifferentTimezonesDateTime()
{ {
$form = $this->factory->create('date', null, array( $form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM, 'format' => \IntlDateFormatter::MEDIUM,
@ -636,7 +636,7 @@ class DateTypeTest extends LocalizedTestCase
$this->assertSame('Empty day', $view['day']->vars['empty_value']); $this->assertSame('Empty day', $view['day']->vars['empty_value']);
} }
public function testPassEmptyValueAsPartialArray_addEmptyIfNotRequired() public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired()
{ {
$form = $this->factory->create('date', null, array( $form = $this->factory->create('date', null, array(
'required' => false, 'required' => false,
@ -652,7 +652,7 @@ class DateTypeTest extends LocalizedTestCase
$this->assertSame('Empty day', $view['day']->vars['empty_value']); $this->assertSame('Empty day', $view['day']->vars['empty_value']);
} }
public function testPassEmptyValueAsPartialArray_addNullIfRequired() public function testPassEmptyValueAsPartialArrayAddNullIfRequired()
{ {
$form = $this->factory->create('date', null, array( $form = $this->factory->create('date', null, array(
'required' => true, 'required' => true,

View File

@ -16,7 +16,7 @@ use Symfony\Component\Form\FormError;
class TimeTypeTest extends LocalizedTestCase class TimeTypeTest extends LocalizedTestCase
{ {
public function testSubmit_dateTime() public function testSubmitDateTime()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -37,7 +37,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals($input, $form->getViewData()); $this->assertEquals($input, $form->getViewData());
} }
public function testSubmit_string() public function testSubmitString()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -56,7 +56,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals($input, $form->getViewData()); $this->assertEquals($input, $form->getViewData());
} }
public function testSubmit_timestamp() public function testSubmitTimestamp()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -77,7 +77,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals($input, $form->getViewData()); $this->assertEquals($input, $form->getViewData());
} }
public function testSubmit_array() public function testSubmitArray()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -96,7 +96,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals($input, $form->getViewData()); $this->assertEquals($input, $form->getViewData());
} }
public function testSubmit_datetimeSingleText() public function testSubmitDatetimeSingleText()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -111,7 +111,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals('03:04', $form->getViewData()); $this->assertEquals('03:04', $form->getViewData());
} }
public function testSubmit_datetimeSingleTextWithoutMinutes() public function testSubmitDatetimeSingleTextWithoutMinutes()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'data_timezone' => 'UTC', 'data_timezone' => 'UTC',
@ -127,7 +127,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals('03', $form->getViewData()); $this->assertEquals('03', $form->getViewData());
} }
public function testSubmit_arraySingleText() public function testSubmitArraySingleText()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -147,7 +147,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals('03:04', $form->getViewData()); $this->assertEquals('03:04', $form->getViewData());
} }
public function testSubmit_arraySingleTextWithoutMinutes() public function testSubmitArraySingleTextWithoutMinutes()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'data_timezone' => 'UTC', 'data_timezone' => 'UTC',
@ -167,7 +167,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals('03', $form->getViewData()); $this->assertEquals('03', $form->getViewData());
} }
public function testSubmit_arraySingleTextWithSeconds() public function testSubmitArraySingleTextWithSeconds()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -189,7 +189,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals('03:04:05', $form->getViewData()); $this->assertEquals('03:04:05', $form->getViewData());
} }
public function testSubmit_stringSingleText() public function testSubmitStringSingleText()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -204,7 +204,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals('03:04', $form->getViewData()); $this->assertEquals('03:04', $form->getViewData());
} }
public function testSubmit_stringSingleTextWithoutMinutes() public function testSubmitStringSingleTextWithoutMinutes()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'data_timezone' => 'UTC', 'data_timezone' => 'UTC',
@ -220,7 +220,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals('03', $form->getViewData()); $this->assertEquals('03', $form->getViewData());
} }
public function testSetData_withoutMinutes() public function testSetDataWithoutMinutes()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'data_timezone' => 'UTC', 'data_timezone' => 'UTC',
@ -234,7 +234,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals(array('hour' => 3), $form->getClientData()); $this->assertEquals(array('hour' => 3), $form->getClientData());
} }
public function testSetData_withSeconds() public function testSetDataWithSeconds()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'model_timezone' => 'UTC', 'model_timezone' => 'UTC',
@ -248,7 +248,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals(array('hour' => 3, 'minute' => 4, 'second' => 5), $form->getViewData()); $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( $form = $this->factory->create('time', null, array(
'model_timezone' => 'America/New_York', 'model_timezone' => 'America/New_York',
@ -274,7 +274,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals($displayedData, $form->getViewData()); $this->assertEquals($displayedData, $form->getViewData());
} }
public function testSetData_differentTimezonesDateTime() public function testSetDataDifferentTimezonesDateTime()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'model_timezone' => 'America/New_York', 'model_timezone' => 'America/New_York',
@ -315,7 +315,7 @@ class TimeTypeTest extends LocalizedTestCase
), $view['hour']->vars['choices']); ), $view['hour']->vars['choices']);
} }
public function testIsMinuteWithinRange_returnsTrueIfWithin() public function testIsMinuteWithinRangeReturnsTrueIfWithin()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'minutes' => array(6, 7), 'minutes' => array(6, 7),
@ -329,7 +329,7 @@ class TimeTypeTest extends LocalizedTestCase
), $view['minute']->vars['choices']); ), $view['minute']->vars['choices']);
} }
public function testIsSecondWithinRange_returnsTrueIfWithin() public function testIsSecondWithinRangeReturnsTrueIfWithin()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'seconds' => array(6, 7), 'seconds' => array(6, 7),
@ -344,7 +344,7 @@ class TimeTypeTest extends LocalizedTestCase
), $view['second']->vars['choices']); ), $view['second']->vars['choices']);
} }
public function testIsPartiallyFilled_returnsFalseIfCompletelyEmpty() public function testIsPartiallyFilledReturnsFalseIfCompletelyEmpty()
{ {
$this->markTestIncomplete('Needs to be reimplemented using validators'); $this->markTestIncomplete('Needs to be reimplemented using validators');
@ -360,7 +360,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertFalse($form->isPartiallyFilled()); $this->assertFalse($form->isPartiallyFilled());
} }
public function testIsPartiallyFilled_returnsFalseIfCompletelyEmpty_withSeconds() public function testIsPartiallyFilledReturnsFalseIfCompletelyEmptyWithSeconds()
{ {
$this->markTestIncomplete('Needs to be reimplemented using validators'); $this->markTestIncomplete('Needs to be reimplemented using validators');
@ -378,7 +378,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertFalse($form->isPartiallyFilled()); $this->assertFalse($form->isPartiallyFilled());
} }
public function testIsPartiallyFilled_returnsFalseIfCompletelyFilled() public function testIsPartiallyFilledReturnsFalseIfCompletelyFilled()
{ {
$this->markTestIncomplete('Needs to be reimplemented using validators'); $this->markTestIncomplete('Needs to be reimplemented using validators');
@ -394,7 +394,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertFalse($form->isPartiallyFilled()); $this->assertFalse($form->isPartiallyFilled());
} }
public function testIsPartiallyFilled_returnsFalseIfCompletelyFilled_withSeconds() public function testIsPartiallyFilledReturnsFalseIfCompletelyFilledWithSeconds()
{ {
$this->markTestIncomplete('Needs to be reimplemented using validators'); $this->markTestIncomplete('Needs to be reimplemented using validators');
@ -412,7 +412,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertFalse($form->isPartiallyFilled()); $this->assertFalse($form->isPartiallyFilled());
} }
public function testIsPartiallyFilled_returnsTrueIfChoiceAndHourEmpty() public function testIsPartiallyFilledReturnsTrueIfChoiceAndHourEmpty()
{ {
$this->markTestIncomplete('Needs to be reimplemented using validators'); $this->markTestIncomplete('Needs to be reimplemented using validators');
@ -430,7 +430,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertTrue($form->isPartiallyFilled()); $this->assertTrue($form->isPartiallyFilled());
} }
public function testIsPartiallyFilled_returnsTrueIfChoiceAndMinuteEmpty() public function testIsPartiallyFilledReturnsTrueIfChoiceAndMinuteEmpty()
{ {
$this->markTestIncomplete('Needs to be reimplemented using validators'); $this->markTestIncomplete('Needs to be reimplemented using validators');
@ -448,7 +448,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertTrue($form->isPartiallyFilled()); $this->assertTrue($form->isPartiallyFilled());
} }
public function testIsPartiallyFilled_returnsTrueIfChoiceAndSecondsEmpty() public function testIsPartiallyFilledReturnsTrueIfChoiceAndSecondsEmpty()
{ {
$this->markTestIncomplete('Needs to be reimplemented using validators'); $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']); $this->assertSame('Empty second', $view['second']->vars['empty_value']);
} }
public function testPassEmptyValueAsPartialArray_addEmptyIfNotRequired() public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'required' => false, 'required' => false,
@ -557,7 +557,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertSame('Empty second', $view['second']->vars['empty_value']); $this->assertSame('Empty second', $view['second']->vars['empty_value']);
} }
public function testPassEmptyValueAsPartialArray_addNullIfRequired() public function testPassEmptyValueAsPartialArrayAddNullIfRequired()
{ {
$form = $this->factory->create('time', null, array( $form = $this->factory->create('time', null, array(
'required' => true, 'required' => true,

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -23,7 +23,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
*/ */
class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase 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())); $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
@ -42,7 +42,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase
/** /**
* @dataProvider savePathDataProvider * @dataProvider savePathDataProvider
*/ */
public function test__ConstructSavePath($savePath, $expectedSavePath, $path) public function testConstructSavePath($savePath, $expectedSavePath, $path)
{ {
$handler = new NativeFileSessionHandler($savePath); $handler = new NativeFileSessionHandler($savePath);
$this->assertEquals($expectedSavePath, ini_get('session.save_path')); $this->assertEquals($expectedSavePath, ini_get('session.save_path'));
@ -65,7 +65,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase
/** /**
* @expectedException \InvalidArgumentException * @expectedException \InvalidArgumentException
*/ */
public function test__ConstructException() public function testConstructException()
{ {
$handler = new NativeFileSessionHandler('something;invalid;with;too-many-args'); $handler = new NativeFileSessionHandler('something;invalid;with;too-many-args');
} }

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -69,7 +69,7 @@ class ExceptionListener implements EventSubscriberInterface
// set handling to false otherwise it wont be able to handle further more // set handling to false otherwise it wont be able to handle further more
$handling = false; $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; return;
} }

View File

@ -61,7 +61,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface
return array(); return array();
} }
$profileList = explode("\n", $indexContent); $profileList = array_reverse(explode("\n", $indexContent));
$result = array(); $result = array();
foreach ($profileList as $item) { foreach ($profileList as $item) {
@ -100,14 +100,6 @@ class RedisProfilerStorage implements ProfilerStorageInterface
--$limit; --$limit;
} }
usort($result, function($a, $b) {
if ($a['time'] === $b['time']) {
return 0;
}
return $a['time'] > $b['time'] ? -1 : 1;
});
return $result; return $result;
} }

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -189,7 +189,7 @@ class StubIntlDateFormatter
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value '; $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) { } 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'; $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); $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 // 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(); return date_default_timezone_get();
} }
@ -512,7 +512,7 @@ class StubIntlDateFormatter
{ {
if (null === $timeZoneId) { if (null === $timeZoneId) {
// In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method // 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(); $timeZoneId = date_default_timezone_get();
} else { } else {
// TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will

View File

@ -43,7 +43,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
$formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT); $formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
// In PHP 5.5 default timezone depends on `date_default_timezone_get()` method // 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()); $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId());
} else { } else {
$this->assertNull($formatter->getTimeZoneId()); $this->assertNull($formatter->getTimeZoneId());
@ -56,7 +56,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
$formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT); $formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
// In PHP 5.5 default timezone depends on `date_default_timezone_get()` method // 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()); $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId());
} else { } else {
$this->assertNull($formatter->getTimeZoneId()); $this->assertNull($formatter->getTimeZoneId());
@ -367,7 +367,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
public function formatErrorProvider() public function formatErrorProvider()
{ {
// With PHP 5.5 IntlDateFormatter accepts empty values ('0') // With PHP 5.5 IntlDateFormatter accepts empty values ('0')
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
return array( 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') 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 // 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 // When time zone not exists, uses UTC by default
$data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00'); $data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00');
$data[] = array(0, 'UTC+04:30', '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'); $formatter = $this->createStubFormatter('zzzz');
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
$formatter->setTimeZone('Pacific/Fiji'); $formatter->setTimeZone('Pacific/Fiji');
} else { } else {
$formatter->setTimeZoneId('Pacific/Fiji'); $formatter->setTimeZoneId('Pacific/Fiji');
@ -466,7 +466,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
$this->skipIfIntlExtensionIsNotLoaded(); $this->skipIfIntlExtensionIsNotLoaded();
$formatter = $this->createIntlFormatter('zzzz'); $formatter = $this->createIntlFormatter('zzzz');
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
$formatter->setTimeZone('Pacific/Fiji'); $formatter->setTimeZone('Pacific/Fiji');
} else { } else {
$formatter->setTimeZoneId('Pacific/Fiji'); $formatter->setTimeZoneId('Pacific/Fiji');
@ -480,7 +480,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
{ {
$formatter = $this->createStubFormatter('zzzz'); $formatter = $this->createStubFormatter('zzzz');
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
$formatter->setTimeZone('GMT+03:00'); $formatter->setTimeZone('GMT+03:00');
} else { } else {
$formatter->setTimeZoneId('GMT+03:00'); $formatter->setTimeZoneId('GMT+03:00');
@ -494,7 +494,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
$this->skipIfIntlExtensionIsNotLoaded(); $this->skipIfIntlExtensionIsNotLoaded();
$formatter = $this->createIntlFormatter('zzzz'); $formatter = $this->createIntlFormatter('zzzz');
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
$formatter->setTimeZone('GMT+03:00'); $formatter->setTimeZone('GMT+03:00');
} else { } else {
$formatter->setTimeZoneId('GMT+03:00'); $formatter->setTimeZoneId('GMT+03:00');
@ -530,7 +530,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
public function testFormatWithDefaultTimezoneStubShouldUseTheTzEnvironmentVariableWhenAvailable() 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.'); $this->markTestSkipped('StubIntlDateFormatter in PHP 5.5 no longer depends on TZ environment.');
} }
@ -553,7 +553,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
public function testFormatWithDefaultTimezoneStubShouldUseDefaultDateTimeZoneVariable() 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()`).'); $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() 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.'); $this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.');
} }
@ -612,7 +612,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
*/ */
public function testFormatWithDefaultTimezoneIntlShouldUseDefaultDateTimeZoneVariable() 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()`).'); $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(); $formatter = $this->createStubFormatter();
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
$formatter->setTimeZone($timeZoneId); $formatter->setTimeZone($timeZoneId);
} else { } else {
$formatter->setTimeZoneId($timeZoneId); $formatter->setTimeZoneId($timeZoneId);
@ -1145,7 +1145,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
$this->skipIfIntlExtensionIsNotLoaded(); $this->skipIfIntlExtensionIsNotLoaded();
$formatter = $this->createIntlFormatter(); $formatter = $this->createIntlFormatter();
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
$formatter->setTimeZone($timeZoneId); $formatter->setTimeZone($timeZoneId);
} else { } else {
$formatter->setTimeZoneId($timeZoneId); $formatter->setTimeZoneId($timeZoneId);
@ -1164,7 +1164,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
); );
// When time zone not exists, uses UTC by default // 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('GMT-0300', 'UTC');
$data[] = array('Foo/Bar', 'UTC'); $data[] = array('Foo/Bar', 'UTC');
$data[] = array('GMT+00:AA', 'UTC'); $data[] = array('GMT+00:AA', 'UTC');
@ -1186,7 +1186,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
{ {
$formatter = $this->createStubFormatter(); $formatter = $this->createStubFormatter();
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
$formatter->setTimeZone('GMT+00:30'); $formatter->setTimeZone('GMT+00:30');
} else { } else {
$formatter->setTimeZoneId('GMT+00:30'); $formatter->setTimeZoneId('GMT+00:30');
@ -1198,7 +1198,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
$this->skipIfIntlExtensionIsNotLoaded(); $this->skipIfIntlExtensionIsNotLoaded();
$formatter = $this->createIntlFormatter(); $formatter = $this->createIntlFormatter();
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
$formatter->setTimeZone('GMT+00:30'); $formatter->setTimeZone('GMT+00:30');
} else { } else {
$formatter->setTimeZoneId('GMT+00:30'); $formatter->setTimeZoneId('GMT+00:30');
@ -1225,7 +1225,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
protected function createDateTime($timestamp = null) protected function createDateTime($timestamp = null)
{ {
if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) {
$timeZone = date_default_timezone_get(); $timeZone = date_default_timezone_get();
} else { } else {
$timeZone = getenv('TZ') ?: 'UTC'; $timeZone = getenv('TZ') ?: 'UTC';

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -30,8 +30,10 @@ class ProcessFailedException extends RuntimeException
parent::__construct( parent::__construct(
sprintf( sprintf(
'The command "%s" failed.'."\n\nOutput:\n================\n".$process->getOutput()."\n\nError Output:\n================\n".$process->getErrorOutput(), 'The command "%s" failed.'."\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
$process->getCommandLine() $process->getCommandLine(),
$process->getOutput(),
$process->getErrorOutput()
) )
); );

View File

@ -19,22 +19,23 @@ namespace Symfony\Component\Process;
*/ */
class ExecutableFinder class ExecutableFinder
{ {
private static $isWindows;
private $suffixes = array('.exe', '.bat', '.cmd', '.com'); private $suffixes = array('.exe', '.bat', '.cmd', '.com');
public function __construct() /**
{ * Replaces default suffixes of executable.
if (null === self::$isWindows) { *
self::$isWindows = 0 === stripos(PHP_OS, 'win'); * @param array $suffixes
} */
}
public function setSuffixes(array $suffixes) public function setSuffixes(array $suffixes)
{ {
$this->suffixes = $suffixes; $this->suffixes = $suffixes;
} }
/**
* Adds new possible suffix to check for executable.
*
* @param string $suffix
*/
public function addSuffix($suffix) public function addSuffix($suffix)
{ {
$this->suffixes[] = $suffix; $this->suffixes[] = $suffix;
@ -78,7 +79,7 @@ class ExecutableFinder
} }
foreach ($suffixes as $suffix) { foreach ($suffixes as $suffix) {
foreach ($dirs as $dir) { 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; return $file;
} }
} }

View File

@ -68,6 +68,6 @@ class PhpProcess extends Process
$this->setCommandLine($php); $this->setCommandLine($php);
} }
return parent::start($callback); parent::start($callback);
} }
} }

View File

@ -130,7 +130,7 @@ class Process
} }
$this->commandline = $commandline; $this->commandline = $commandline;
$this->cwd = null === $cwd ? getcwd() : $cwd; $this->cwd = $cwd;
if (null !== $env) { if (null !== $env) {
$this->env = array(); $this->env = array();
foreach ($env as $key => $value) { foreach ($env as $key => $value) {
@ -176,8 +176,8 @@ class Process
* The STDOUT and STDERR are also available after the process is finished * The STDOUT and STDERR are also available after the process is finished
* via the getOutput() and getErrorOutput() methods. * 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 * output available on STDOUT or STDERR
* *
* @return integer The exit status code * @return integer The exit status code
* *
@ -207,8 +207,8 @@ class Process
* with true as a second parameter then the callback will get all data occurred * with true as a second parameter then the callback will get all data occurred
* in (and since) the start call. * 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 * output available on STDOUT or STDERR
* *
* @throws RuntimeException When process can't be launch or is stopped * @throws RuntimeException When process can't be launch or is stopped
* @throws RuntimeException When process is already running * @throws RuntimeException When process is already running
@ -364,11 +364,12 @@ class Process
* from the output in real-time while writing the standard input to the 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. * 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) public function wait($callback = null)
{ {
@ -538,8 +539,6 @@ class Process
* *
* @return string A string representation for the exit status code * @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://tldp.org/LDP/abs/html/exitcodes.html
* @see http://en.wikipedia.org/wiki/Unix_signal * @see http://en.wikipedia.org/wiki/Unix_signal
*/ */
@ -555,8 +554,6 @@ class Process
* *
* @return Boolean true if the process ended successfully, false otherwise * @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 * @api
*/ */
public function isSuccessful() public function isSuccessful()
@ -695,7 +692,7 @@ class Process
/** /**
* Stops the 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 * @return integer The exit-code of the process
* *
@ -823,6 +820,13 @@ class Process
*/ */
public function getWorkingDirectory() 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; return $this->cwd;
} }
@ -972,9 +976,9 @@ class Process
* The callbacks adds all occurred output to the specific buffer and calls * The callbacks adds all occurred output to the specific buffer and calls
* the user callback (if present) with the received output. * 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) protected function buildCallback($callback)
{ {
@ -1014,6 +1018,9 @@ class Process
} }
} }
/**
* Updates the current error output of the process (STDERR).
*/
protected function updateErrorOutput() protected function updateErrorOutput()
{ {
if (isset($this->pipes[self::STDERR]) && is_resource($this->pipes[self::STDERR])) { 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() protected function updateOutput()
{ {
if (defined('PHP_WINDOWS_VERSION_BUILD') && isset($this->fileHandles[self::STDOUT]) && is_resource($this->fileHandles[self::STDOUT])) { if (defined('PHP_WINDOWS_VERSION_BUILD') && isset($this->fileHandles[self::STDOUT]) && is_resource($this->fileHandles[self::STDOUT])) {

View File

@ -18,8 +18,6 @@ use Symfony\Component\Process\Process;
*/ */
abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase 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 * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
*/ */
@ -367,4 +365,16 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
return $defaults; 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());
} }

View File

@ -21,7 +21,7 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
/** /**
* tests find() with the env var PHP_PATH * tests find() with the env var PHP_PATH
*/ */
public function testFindWithPHP_PATH() public function testFindWithPhpPath()
{ {
if (defined('PHP_BINARY')) { if (defined('PHP_BINARY')) {
$this->markTestSkipped('The PHP binary is easily available as of PHP 5.4'); $this->markTestSkipped('The PHP binary is easily available as of PHP 5.4');

View File

@ -13,15 +13,6 @@ namespace Symfony\Component\Process\Tests;
class SigchildDisabledProcessTest extends AbstractProcessTest 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 * @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/ */
@ -96,4 +87,15 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
{ {
parent::testIsNotSuccessful(); 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;
}
} }

View File

@ -13,15 +13,6 @@ namespace Symfony\Component\Process\Tests;
class SigchildEnabledProcessTest extends AbstractProcessTest 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 * @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/ */
@ -62,4 +53,14 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
$this->assertInternalType('string', $process->getExitCodeText()); $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;
}
} }

View File

@ -15,20 +15,14 @@ use Symfony\Component\Process\Process;
class SimpleProcessTest extends AbstractProcessTest class SimpleProcessTest extends AbstractProcessTest
{ {
private $enabledSigchild = false;
protected function skipIfPHPSigchild() public function setUp()
{ {
ob_start(); ob_start();
phpinfo(INFO_GENERAL); phpinfo(INFO_GENERAL);
if (false !== strpos(ob_get_clean(), '--enable-sigchild')) { $this->enabledSigchild = 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);
} }
public function testGetExitCode() public function testGetExitCode()
@ -84,4 +78,19 @@ class SimpleProcessTest extends AbstractProcessTest
$this->skipIfPHPSigchild(); $this->skipIfPHPSigchild();
parent::testIsNotSuccessful(); 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');
}
}
} }

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -47,7 +47,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
$this->validator = null; $this->validator = null;
} }
public function testValidate_defaultGroup() public function testValidateDefaultGroup()
{ {
$entity = new Entity(); $entity = new Entity();
$metadata = new ClassMetadata(get_class($entity)); $metadata = new ClassMetadata(get_class($entity));
@ -71,7 +71,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($violations, $this->validator->validate($entity)); $this->assertEquals($violations, $this->validator->validate($entity));
} }
public function testValidate_oneGroup() public function testValidateOneGroup()
{ {
$entity = new Entity(); $entity = new Entity();
$metadata = new ClassMetadata(get_class($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')); $this->assertEquals($violations, $this->validator->validate($entity, 'Custom'));
} }
public function testValidate_multipleGroups() public function testValidateMultipleGroups()
{ {
$entity = new Entity(); $entity = new Entity();
$metadata = new ClassMetadata(get_class($entity)); $metadata = new ClassMetadata(get_class($entity));
@ -131,7 +131,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($violations, $result); $this->assertEquals($violations, $result);
} }
public function testValidate_groupSequenceProvider() public function testValidateGroupSequenceProvider()
{ {
$entity = new GroupSequenceProviderEntity(); $entity = new GroupSequenceProviderEntity();
$metadata = new ClassMetadata(get_class($entity)); $metadata = new ClassMetadata(get_class($entity));

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -38,19 +38,21 @@ class Dumper
/** /**
* Dumps a PHP value to YAML. * Dumps a PHP value to YAML.
* *
* @param mixed $input The PHP value * @param mixed $input The PHP value
* @param integer $inline The level where you switch to inline YAML * @param integer $inline The level where you switch to inline YAML
* @param integer $indent The level of indentation (used internally) * @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 * @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 = ''; $output = '';
$prefix = $indent ? str_repeat(' ', $indent) : ''; $prefix = $indent ? str_repeat(' ', $indent) : '';
if ($inline <= 0 || !is_array($input) || empty($input)) { if ($inline <= 0 || !is_array($input) || empty($input)) {
$output .= $prefix.Inline::dump($input); $output .= $prefix.Inline::dump($input, $exceptionOnInvalidType, $objectSupport);
} else { } else {
$isAHash = array_keys($input) !== range(0, count($input) - 1); $isAHash = array_keys($input) !== range(0, count($input) - 1);
@ -59,9 +61,9 @@ class Dumper
$output .= sprintf('%s%s%s%s', $output .= sprintf('%s%s%s%s',
$prefix, $prefix,
$isAHash ? Inline::dump($key).':' : '-', $isAHash ? Inline::dump($key, $exceptionOnInvalidType, $objectSupport).':' : '-',
$willBeInlined ? ' ' : "\n", $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" : ''); ).($willBeInlined ? "\n" : '');
} }
} }

View File

@ -22,17 +22,25 @@ class Inline
{ {
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')'; const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')';
private static $exceptionOnInvalidType = false;
private static $objectSupport = false;
/** /**
* Converts a YAML string to a PHP array. * Converts a YAML string to a PHP array.
* *
* @param string $value A YAML string * @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 * @return array A PHP array representing the YAML string
* *
* @throws ParseException * @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); $value = trim($value);
if (0 == strlen($value)) { if (0 == strlen($value)) {
@ -71,21 +79,35 @@ class Inline
/** /**
* Dumps a given PHP variable to a YAML string. * Dumps a given PHP variable to a YAML string.
* *
* @param mixed $value The PHP variable to convert * @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 * @return string The YAML string representing the PHP array
* *
* @throws DumpException When trying to dump PHP resource * @throws DumpException When trying to dump PHP resource
*/ */
public static function dump($value) public static function dump($value, $exceptionOnInvalidType = false, $objectSupport = false)
{ {
switch (true) { switch (true) {
case is_resource($value): case is_resource($value):
throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($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): case is_object($value):
return '!!php/object:'.serialize($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): case is_array($value):
return self::dumpArray($value); return self::dumpArray($value, $exceptionOnInvalidType, $objectSupport);
case null === $value: case null === $value:
return 'null'; return 'null';
case true === $value: case true === $value:
@ -123,11 +145,13 @@ class Inline
/** /**
* Dumps a PHP array to a YAML string. * Dumps a PHP array to a YAML string.
* *
* @param array $value The PHP array to dump * @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 * @return string The YAML string representing the PHP array
*/ */
private static function dumpArray($value) private static function dumpArray($value, $exceptionOnInvalidType, $objectSupport)
{ {
// array // array
$keys = array_keys($value); $keys = array_keys($value);
@ -136,7 +160,7 @@ class Inline
) { ) {
$output = array(); $output = array();
foreach ($value as $val) { foreach ($value as $val) {
$output[] = self::dump($val); $output[] = self::dump($val, $exceptionOnInvalidType, $objectSupport);
} }
return sprintf('[%s]', implode(', ', $output)); return sprintf('[%s]', implode(', ', $output));
@ -145,7 +169,7 @@ class Inline
// mapping // mapping
$output = array(); $output = array();
foreach ($value as $key => $val) { 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)); return sprintf('{ %s }', implode(', ', $output));
@ -375,7 +399,15 @@ class Inline
case 0 === strpos($scalar, '! '): case 0 === strpos($scalar, '! '):
return intval(self::parseScalar(substr($scalar, 2))); return intval(self::parseScalar(substr($scalar, 2)));
case 0 === strpos($scalar, '!!php/object:'): case 0 === strpos($scalar, '!!php/object:'):
return unserialize(substr($scalar, 13)); 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): case ctype_digit($scalar):
$raw = $scalar; $raw = $scalar;
$cast = intval($scalar); $cast = intval($scalar);

View File

@ -38,13 +38,15 @@ class Parser
/** /**
* Parses a YAML string to a PHP value. * Parses a YAML string to a PHP value.
* *
* @param string $value A YAML string * @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 * @return mixed A PHP value
* *
* @throws ParseException If the YAML is not valid * @throws ParseException If the YAML is not valid
*/ */
public function parse($value) public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false)
{ {
$this->currentLineNb = -1; $this->currentLineNb = -1;
$this->currentLine = ''; $this->currentLine = '';
@ -88,7 +90,7 @@ class Parser
$c = $this->getRealCurrentLineNb() + 1; $c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c); $parser = new Parser($c);
$parser->refs =& $this->refs; $parser->refs =& $this->refs;
$data[] = $parser->parse($this->getNextEmbedBlock()); $data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport);
} else { } else {
if (isset($values['leadspaces']) if (isset($values['leadspaces'])
&& ' ' == $values['leadspaces'] && ' ' == $values['leadspaces']
@ -104,9 +106,9 @@ class Parser
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2); $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2);
} }
$data[] = $parser->parse($block); $data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport);
} else { } 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)) { } 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'; $context = 'mapping';
// force correct settings
Inline::parse(null, $exceptionOnInvalidType, $objectSupport);
try { try {
$key = Inline::parseScalar($values['key']); $key = Inline::parseScalar($values['key']);
} catch (ParseException $e) { } catch (ParseException $e) {
@ -139,7 +143,7 @@ class Parser
$c = $this->getRealCurrentLineNb() + 1; $c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c); $parser = new Parser($c);
$parser->refs =& $this->refs; $parser->refs =& $this->refs;
$parsed = $parser->parse($value); $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport);
$merged = array(); $merged = array();
if (!is_array($parsed)) { if (!is_array($parsed)) {
@ -176,20 +180,20 @@ class Parser
$c = $this->getRealCurrentLineNb() + 1; $c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c); $parser = new Parser($c);
$parser->refs =& $this->refs; $parser->refs =& $this->refs;
$data[$key] = $parser->parse($this->getNextEmbedBlock()); $data[$key] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport);
} }
} else { } else {
if ($isInPlace) { if ($isInPlace) {
$data = $this->refs[$isInPlace]; $data = $this->refs[$isInPlace];
} else { } else {
$data[$key] = $this->parseValue($values['value']); $data[$key] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport);
} }
} }
} else { } else {
// 1-liner followed by newline // 1-liner followed by newline
if (2 == count($this->lines) && empty($this->lines[1])) { if (2 == count($this->lines) && empty($this->lines[1])) {
try { try {
$value = Inline::parse($this->lines[0]); $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport);
} catch (ParseException $e) { } catch (ParseException $e) {
$e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setParsedLine($this->getRealCurrentLineNb() + 1);
$e->setSnippet($this->currentLine); $e->setSnippet($this->currentLine);
@ -366,7 +370,7 @@ class Parser
* *
* @throws ParseException When reference does not exist * @throws ParseException When reference does not exist
*/ */
private function parseValue($value) private function parseValue($value, $exceptionOnInvalidType, $objectSupport)
{ {
if (0 === strpos($value, '*')) { if (0 === strpos($value, '*')) {
if (false !== $pos = strpos($value, '#')) { if (false !== $pos = strpos($value, '#')) {
@ -389,7 +393,7 @@ class Parser
} }
try { try {
return Inline::parse($value); return Inline::parse($value, $exceptionOnInvalidType, $objectSupport);
} catch (ParseException $e) { } catch (ParseException $e) {
$e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setParsedLine($this->getRealCurrentLineNb() + 1);
$e->setSnippet($this->currentLine); $e->setSnippet($this->currentLine);

View File

@ -152,11 +152,26 @@ EOF;
$this->assertEquals($expected, $this->dumper->dump($array, 10), '->dump() takes an inline level argument'); $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);
} }
} }

View File

@ -13,7 +13,6 @@ namespace Symfony\Component\Yaml\Tests;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Yaml\Parser; use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Exception\ParseException;
class ParserTest extends \PHPUnit_Framework_TestCase class ParserTest extends \PHPUnit_Framework_TestCase
{ {
@ -106,14 +105,31 @@ EOF;
$this->assertEquals('foo', $this->parser->parse($yaml)); $this->assertEquals('foo', $this->parser->parse($yaml));
} }
public function testObjectsSupport() public function testObjectSupportEnabled()
{ {
$b = array('foo' => new B(), 'bar' => 1); $input = <<<EOF
$this->assertEquals($this->parser->parse(<<<EOF
foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";} foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
bar: 1 bar: 1
EOF EOF;
), $b, '->parse() is able to dump objects'); $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() public function testNonUtf8Exception()

View File

@ -22,13 +22,53 @@ use Symfony\Component\Yaml\Exception\ParseException;
*/ */
class Yaml 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; 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() public static function enablePhpParsing()
{ {
self::$enablePhpParsing = true; 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. * Parses YAML into a PHP array.
* *
@ -53,7 +93,7 @@ class Yaml
* *
* @api * @api
*/ */
public static function parse($input) public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false)
{ {
// if input is a file, process it // if input is a file, process it
$file = ''; $file = '';
@ -83,7 +123,7 @@ class Yaml
$yaml = new Parser(); $yaml = new Parser();
try { try {
return $yaml->parse($input); return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport);
} catch (ParseException $e) { } catch (ParseException $e) {
if ($file) { if ($file) {
$e->setParsedFile($file); $e->setParsedFile($file);
@ -99,19 +139,21 @@ class Yaml
* The dump method, when supplied with an array, will do its best * The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML. * to convert the array into friendly YAML.
* *
* @param array $array PHP array * @param array $array PHP array
* @param integer $inline The level where you switch to inline YAML * @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 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 * @return string A YAML string representing the original PHP array
* *
* @api * @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 = new Dumper();
$yaml->setIndentation($indent); $yaml->setIndentation($indent);
return $yaml->dump($array, $inline); return $yaml->dump($array, $inline, $exceptionOnInvalidType, $objectSupport);
} }
} }