Skip to content

Instantly share code, notes, and snippets.

@nachinius
Created December 15, 2014 00:41
Show Gist options
  • Save nachinius/4f8eaa146a4e22bb172a to your computer and use it in GitHub Desktop.
Save nachinius/4f8eaa146a4e22bb172a to your computer and use it in GitHub Desktop.
<?php
/*
* This file is part of the Symfony package. (c) Fabien Potencier <[email protected]> For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml\Tests;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Dumper;
use Symfony\Component\Yaml\Inline;
class Issue6498ConfirmationTest extends \PHPUnit_Framework_TestCase
{
/**
*
* @var Parser
*/
protected $parser;
/**
*
* @var Dumper
*/
protected $dumper;
protected $path;
protected function setUp()
{
$this->parser = new Parser();
$this->dumper = new Dumper();
$this->path = __DIR__ . '/Fixtures';
}
protected function tearDown()
{
$this->parser = null;
$this->dumper = null;
$this->path = null;
$this->array = null;
}
/**
* Create pairs of PHP variables and their YAML dumping with the Dumper
*/
public function dataSourceAndDumper() {
$source = array(
'foo' => new C(),
'bar' => 1
);
$this->dumper = new Dumper();
$dumped = $this->dumper->dump($source, 0, 0, false, true);
return array(
array('source' => $source, 'dumped' => $dumped)
);
}
/**
* @dataProvider dataSourceAndDumper
*/
public function testConsistencyBetweenDumperAndParser($source, $dumped) {
$parsed = $this->parser->parse($dumped, true, true);
$this->assertEquals($source, $parsed, 'Dumping and Parsing is not restoring the original code');
}
/**
* @dataProvider dataSourceAndDumper
*/
public function testConfirmationIssue6498($source, $dumped)
{
try {
$parsed = $this->parser->parse($dumped, true, true);
} catch (\Exception $e) {
error_log($e->getTraceAsString());
throw $e;
}
$this->assertEquals($source, $parsed, 'Dumping and Parsing is not restoring the original code');
}
}
class C
{
public $a = 'foo';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment