Skip to content

Commit

Permalink
[WebProfilerBundle] deprecated import/export commands
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 7, 2015
1 parent 0edcc2e commit 17e00b9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
7 changes: 5 additions & 2 deletions UPGRADE-2.8.md
Expand Up @@ -325,8 +325,11 @@ DependencyInjection
</services>
```

Web Development Toolbar
-----------------------
WebProfiler
-----------

The `profiler:import` and `profiler:export` commands have been deprecated and
will be removed in 3.0.

The web development toolbar has been completely redesigned. This update has
introduced some changes in the HTML markup of the toolbar items.
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========

2.8.0
-----

* deprecated profiler:import and profiler:export commands

2.7.0
-----

Expand Down
Expand Up @@ -20,6 +20,8 @@
/**
* Exports a profile.
*
* @deprecated since version 2.8, to be removed in 3.0.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ExportCommand extends Command
Expand Down Expand Up @@ -49,7 +51,7 @@ protected function configure()
{
$this
->setName('profiler:export')
->setDescription('Exports a profile')
->setDescription('[DEPRECATED] Exports a profile')
->setDefinition(array(
new InputArgument('token', InputArgument::REQUIRED, 'The profile token'),
))
Expand All @@ -64,6 +66,10 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$formatter = $this->getHelper('formatter');

$output->writeln($formatter->formatSection('warning', 'The profiler:export command is deprecated since version 2.8 and will be removed in 3.0', 'comment'));

$token = $input->getArgument('token');

if (!$profile = $this->profiler->loadProfile($token)) {
Expand Down
Expand Up @@ -20,6 +20,8 @@
/**
* Imports a profile.
*
* @deprecated since version 2.8, to be removed in 3.0.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ImportCommand extends Command
Expand Down Expand Up @@ -49,7 +51,7 @@ protected function configure()
{
$this
->setName('profiler:import')
->setDescription('Imports a profile')
->setDescription('[DEPRECATED] Imports a profile')
->setDefinition(array(
new InputArgument('filename', InputArgument::OPTIONAL, 'The profile path'),
))
Expand All @@ -68,6 +70,10 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$formatter = $this->getHelper('formatter');

$output->writeln($formatter->formatSection('warning', 'The profiler:import command is deprecated since version 2.8 and will be removed in 3.0', 'comment'));

$data = '';
if ($input->getArgument('filename')) {
$data = file_get_contents($input->getArgument('filename'));
Expand Down
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bundle\WebProfilerBundle\Tests\Command;

use Symfony\Bundle\WebProfilerBundle\Command\ExportCommand;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\Profiler\Profile;

Expand All @@ -28,7 +29,14 @@ public function testExecuteWithUnknownToken()
->getMock()
;

$helperSet = new HelperSet();
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
$helper->expects($this->any())->method('formatSection');
$helperSet->set($helper, 'formatter');

$command = new ExportCommand($profiler);
$command->setHelperSet($helperSet);

$commandTester = new CommandTester($command);
$commandTester->execute(array('token' => 'TOKEN'));
}
Expand All @@ -44,7 +52,14 @@ public function testExecuteWithToken()
$profile = new Profile('TOKEN');
$profiler->expects($this->once())->method('loadProfile')->with('TOKEN')->will($this->returnValue($profile));

$helperSet = new HelperSet();
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
$helper->expects($this->any())->method('formatSection');
$helperSet->set($helper, 'formatter');

$command = new ExportCommand($profiler);
$command->setHelperSet($helperSet);

$commandTester = new CommandTester($command);
$commandTester->execute(array('token' => 'TOKEN'));
$this->assertEquals($profiler->export($profile), $commandTester->getDisplay());
Expand Down

0 comments on commit 17e00b9

Please sign in to comment.