Skip to content

Commit 8cba032

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-99413: Update symfony/console dependency
1 parent eabf8f4 commit 8cba032

File tree

6 files changed

+66
-40
lines changed

6 files changed

+66
-40
lines changed

app/code/Magento/Indexer/Console/Command/IndexerStatusCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Symfony\Component\Console\Output\OutputInterface;
1010
use Magento\Framework\Indexer;
1111
use Magento\Framework\Mview;
12+
use Symfony\Component\Console\Helper\Table as TableHelper;
1213

1314
/**
1415
* Command for displaying status of indexers.
@@ -32,7 +33,8 @@ protected function configure()
3233
*/
3334
protected function execute(InputInterface $input, OutputInterface $output)
3435
{
35-
$table = $this->getHelperSet()->get('table');
36+
/** @var TableHelper $table */
37+
$table = $this->getObjectManager()->create(TableHelper::class, ['output' => $output]);
3638
$table->setHeaders(['Title', 'Status', 'Update On', 'Schedule Status', 'Schedule Updated']);
3739

3840
$rows = [];
@@ -63,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6365
});
6466

6567
$table->addRows($rows);
66-
$table->render($output);
68+
$table->render();
6769
}
6870

6971
/**

app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
use Magento\Framework\Indexer\StateInterface;
99
use Magento\Indexer\Console\Command\IndexerStatusCommand;
10+
use Symfony\Component\Console\Helper\Table;
1011
use Symfony\Component\Console\Tester\CommandTester;
11-
use Symfony\Component\Console\Helper\HelperSet;
12-
use Symfony\Component\Console\Helper\TableHelper;
1312

1413
class IndexerStatusCommandTest extends AbstractIndexerCommandCommonSetup
1514
{
@@ -92,14 +91,11 @@ public function testExecuteAll(array $indexers)
9291

9392
$this->initIndexerCollectionByItems($indexerMocks);
9493
$this->command = new IndexerStatusCommand($this->objectManagerFactory);
95-
9694
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
97-
98-
$this->command->setHelperSet(
99-
$objectManager->getObject(
100-
HelperSet::class,
101-
['helpers' => [$objectManager->getObject(TableHelper::class)]]
102-
)
95+
$this->objectManager->method('create')->willReturnCallback(
96+
function ($class, $arguments) use ($objectManager) {
97+
return $objectManager->getObject(Table::class, $arguments);
98+
}
10399
);
104100

105101
$commandTester = new CommandTester($this->command);

app/code/Magento/Store/Console/Command/StoreListCommand.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
*/
77
namespace Magento\Store\Console\Command;
88

9+
use Magento\Framework\App\ObjectManager;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Output\OutputInterface;
1112
use Symfony\Component\Console\Command\Command;
13+
use Symfony\Component\Console\Helper\Table as TableHelper;
14+
use Symfony\Component\Console\Helper\TableFactory as TableHelperFactory;
1215

1316
/**
1417
* Class StoreListCommand
@@ -23,11 +26,19 @@ class StoreListCommand extends Command
2326
private $storeManager;
2427

2528
/**
29+
* @var TableHelperFactory
30+
*/
31+
private $tableHelperFactory;
32+
33+
/**
34+
* @inheritDoc
2635
*/
2736
public function __construct(
28-
\Magento\Store\Model\StoreManagerInterface $storeManager
37+
\Magento\Store\Model\StoreManagerInterface $storeManager,
38+
TableHelperFactory $tableHelperFactory = null
2939
) {
3040
$this->storeManager = $storeManager;
41+
$this->tableHelperFactory = $tableHelperFactory ?? ObjectManager::getInstance()->get(TableHelperFactory::class);
3142
parent::__construct();
3243
}
3344

@@ -48,7 +59,8 @@ protected function configure()
4859
protected function execute(InputInterface $input, OutputInterface $output)
4960
{
5061
try {
51-
$table = $this->getHelperSet()->get('table');
62+
/** @var TableHelper $table */
63+
$table = $this->tableHelperFactory->create(['output' => $output]);
5264
$table->setHeaders(['ID', 'Website ID', 'Group ID', 'Name', 'Code', 'Sort Order', 'Is Active']);
5365

5466
foreach ($this->storeManager->getStores(true, true) as $store) {
@@ -63,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6375
]);
6476
}
6577

66-
$table->render($output);
78+
$table->render();
6779

6880
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
6981
} catch (\Exception $e) {

app/code/Magento/Store/Console/Command/WebsiteListCommand.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
*/
77
namespace Magento\Store\Console\Command;
88

9+
use Magento\Framework\App\ObjectManager;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Output\OutputInterface;
1112
use Symfony\Component\Console\Command\Command;
13+
use Symfony\Component\Console\Helper\Table as TableHelper;
14+
use Symfony\Component\Console\Helper\TableFactory as TableHelperFactory;
1215

1316
/**
1417
* Class WebsiteListCommand
@@ -23,11 +26,19 @@ class WebsiteListCommand extends Command
2326
private $manager;
2427

2528
/**
29+
* @var TableHelperFactory
30+
*/
31+
private $tableHelperFactory;
32+
33+
/**
34+
* @inheritDoc
2635
*/
2736
public function __construct(
28-
\Magento\Store\Api\WebsiteRepositoryInterface $websiteManagement
37+
\Magento\Store\Api\WebsiteRepositoryInterface $websiteManagement,
38+
TableHelperFactory $tableHelperFactory = null
2939
) {
3040
$this->manager = $websiteManagement;
41+
$this->tableHelperFactory = $tableHelperFactory ?? ObjectManager::getInstance()->get(TableHelperFactory::class);
3142
parent::__construct();
3243
}
3344

@@ -48,7 +59,7 @@ protected function configure()
4859
protected function execute(InputInterface $input, OutputInterface $output)
4960
{
5061
try {
51-
$table = $this->getHelperSet()->get('table');
62+
$table = $this->tableHelperFactory->create(['output' => $output]);
5263
$table->setHeaders(['ID', 'Default Group Id', 'Name', 'Code', 'Sort Order', 'Is Default']);
5364

5465
foreach ($this->manager->getList() as $website) {

app/code/Magento/Store/Test/Unit/Console/Command/StoreListCommandTest.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
namespace Magento\Store\Test\Unit\Console\Command;
77

88
use Magento\Store\Console\Command\StoreListCommand;
9+
use Symfony\Component\Console\Helper\Table;
10+
use Symfony\Component\Console\Helper\TableFactory;
911
use Symfony\Component\Console\Tester\CommandTester;
10-
use Symfony\Component\Console\Helper\HelperSet;
11-
use Symfony\Component\Console\Helper\TableHelper;
1212
use Magento\Store\Model\Store;
1313
use Magento\Framework\Console\Cli;
1414

@@ -38,19 +38,21 @@ protected function setUp()
3838

3939
$this->storeManagerMock = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class);
4040

41+
$tableHelperFactory = $this->getMockBuilder(TableFactory::class)->disableOriginalConstructor()->getMock();
42+
$tableHelperFactory->method('create')
43+
->willReturnCallback(
44+
function ($arguments) {
45+
return $this->objectManager->getObject(Table::class, $arguments);
46+
}
47+
);
48+
4149
$this->command = $this->objectManager->getObject(
4250
StoreListCommand::class,
43-
['storeManager' => $this->storeManagerMock]
44-
);
45-
46-
/** @var HelperSet $helperSet */
47-
$helperSet = $this->objectManager->getObject(
48-
HelperSet::class,
49-
['helpers' => [$this->objectManager->getObject(TableHelper::class)]]
51+
[
52+
'storeManager' => $this->storeManagerMock,
53+
'tableHelperFactory' => $tableHelperFactory
54+
]
5055
);
51-
52-
//Inject table helper for output
53-
$this->command->setHelperSet($helperSet);
5456
}
5557

5658
public function testExecuteExceptionNoVerbosity()

app/code/Magento/Store/Test/Unit/Console/Command/WebsiteListCommandTest.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
namespace Magento\Store\Test\Unit\Console\Command;
77

88
use Magento\Store\Console\Command\WebsiteListCommand;
9+
use Symfony\Component\Console\Helper\Table;
10+
use Symfony\Component\Console\Helper\TableFactory;
911
use Symfony\Component\Console\Tester\CommandTester;
10-
use Symfony\Component\Console\Helper\HelperSet;
11-
use Symfony\Component\Console\Helper\TableHelper;
1212
use Magento\Store\Model\Website;
1313
use Magento\Framework\Console\Cli;
1414
use Magento\Store\Api\WebsiteRepositoryInterface;
@@ -39,19 +39,22 @@ protected function setUp()
3939

4040
$this->websiteRepositoryMock = $this->getMockForAbstractClass(WebsiteRepositoryInterface::class);
4141

42+
$tableHelperFactory = $this->getMockBuilder(TableFactory::class)->disableOriginalConstructor()->getMock();
43+
$tableHelperFactory->method('create')
44+
->willReturnCallback(
45+
function ($arguments) {
46+
return $this->objectManager->getObject(Table::class, $arguments);
47+
}
48+
);
49+
50+
4251
$this->command = $this->objectManager->getObject(
4352
WebsiteListCommand::class,
44-
['websiteManagement' => $this->websiteRepositoryMock]
53+
[
54+
'websiteManagement' => $this->websiteRepositoryMock,
55+
'tableHelperFactory' => $tableHelperFactory
56+
]
4557
);
46-
47-
/** @var HelperSet $helperSet */
48-
$helperSet = $this->objectManager->getObject(
49-
HelperSet::class,
50-
['helpers' => [$this->objectManager->getObject(TableHelper::class)]]
51-
);
52-
53-
//Inject table helper for output
54-
$this->command->setHelperSet($helperSet);
5558
}
5659

5760
public function testExecuteExceptionNoVerbosity()

0 commit comments

Comments
 (0)