[HtppKernel] deprecated Profiler::import/export

This commit is contained in:
Fabien Potencier 2015-09-07 17:53:56 +02:00
parent 17e00b9b8e
commit 943fec97d3
4 changed files with 27 additions and 0 deletions

View File

@ -16,6 +16,9 @@ use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\Profiler\Profile;
/**
* @group legacy
*/
class ExportCommandTest extends \PHPUnit_Framework_TestCase
{
/**

View File

@ -12,9 +12,13 @@
namespace Symfony\Bundle\WebProfilerBundle\Tests\Command;
use Symfony\Bundle\WebProfilerBundle\Command\ImportCommand;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\Profiler\Profile;
/**
* @group legacy
*/
class ImportCommandTest extends \PHPUnit_Framework_TestCase
{
public function testExecute()
@ -27,7 +31,14 @@ class ImportCommandTest extends \PHPUnit_Framework_TestCase
$profiler->expects($this->once())->method('import')->will($this->returnValue(new Profile('TOKEN')));
$helperSet = new HelperSet();
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
$helper->expects($this->any())->method('formatSection');
$helperSet->set($helper, 'formatter');
$command = new ImportCommand($profiler);
$command->setHelperSet($helperSet);
$commandTester = new CommandTester($command);
$commandTester->execute(array('filename' => __DIR__.'/../Fixtures/profile.data'));
$this->assertRegExp('/Profile "TOKEN" has been successfully imported\./', $commandTester->getDisplay());

View File

@ -1,6 +1,11 @@
CHANGELOG
=========
2.8.0
-----
* deprecated `Profiler::import` and `Profiler::export`
2.7.0
-----

View File

@ -137,9 +137,13 @@ class Profiler
* @param Profile $profile A Profile instance
*
* @return string The exported data
*
* @deprecated since Symfony 2.8, to be removed in 3.0.
*/
public function export(Profile $profile)
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
return base64_encode(serialize($profile));
}
@ -149,9 +153,13 @@ class Profiler
* @param string $data A data string as exported by the export() method
*
* @return Profile A Profile instance
*
* @deprecated since Symfony 2.8, to be removed in 3.0.
*/
public function import($data)
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
$profile = unserialize(base64_decode($data));
if ($this->storage->read($profile->getToken())) {