Skip to content

Commit b901dce

Browse files
MAGETWO-58185: [PR] Bug fixes delivery
3 parents c614b9c + f76cb3b + a8a3777 commit b901dce

File tree

21 files changed

+467
-178
lines changed

21 files changed

+467
-178
lines changed

app/code/Magento/Catalog/Console/Command/ImagesResizeCommand.php

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,15 @@
55
*/
66
namespace Magento\Catalog\Console\Command;
77

8-
use Magento\Catalog\Model\Product;
9-
use Magento\Catalog\Model\Product\Image\Cache as ImageCache;
10-
use Magento\Catalog\Model\Product\Image\CacheFactory as ImageCacheFactory;
11-
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
12-
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
13-
use Magento\Framework\App\State as AppState;
14-
use Magento\Framework\Exception\NoSuchEntityException;
15-
use Symfony\Component\Console\Command\Command;
16-
use Symfony\Component\Console\Input\InputInterface;
17-
use Symfony\Component\Console\Output\OutputInterface;
18-
19-
class ImagesResizeCommand extends Command
8+
class ImagesResizeCommand extends \Symfony\Component\Console\Command\Command
209
{
2110
/**
22-
* @var AppState
11+
* @var \Magento\Framework\App\State
2312
*/
2413
protected $appState;
2514

2615
/**
27-
* @var ProductCollectionFactory
16+
* @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory
2817
*/
2918
protected $productCollectionFactory;
3019

@@ -34,21 +23,21 @@ class ImagesResizeCommand extends Command
3423
protected $productRepository;
3524

3625
/**
37-
* @var ImageCacheFactory
26+
* @var \Magento\Catalog\Model\Product\Image\CacheFactory
3827
*/
3928
protected $imageCacheFactory;
4029

4130
/**
42-
* @param AppState $appState
43-
* @param ProductCollectionFactory $productCollectionFactory
31+
* @param \Magento\Framework\App\State $appState
32+
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
4433
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
45-
* @param ImageCacheFactory $imageCacheFactory
34+
* @param \Magento\Catalog\Model\Product\Image\CacheFactory $imageCacheFactory
4635
*/
4736
public function __construct(
48-
AppState $appState,
49-
ProductCollectionFactory $productCollectionFactory,
37+
\Magento\Framework\App\State $appState,
38+
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
5039
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
51-
ImageCacheFactory $imageCacheFactory
40+
\Magento\Catalog\Model\Product\Image\CacheFactory $imageCacheFactory
5241
) {
5342
$this->appState = $appState;
5443
$this->productCollectionFactory = $productCollectionFactory;
@@ -69,11 +58,13 @@ protected function configure()
6958
/**
7059
* {@inheritdoc}
7160
*/
72-
protected function execute(InputInterface $input, OutputInterface $output)
73-
{
74-
$this->appState->setAreaCode('catalog');
61+
protected function execute(
62+
\Symfony\Component\Console\Input\InputInterface $input,
63+
\Symfony\Component\Console\Output\OutputInterface $output
64+
) {
65+
$this->appState->setAreaCode(\Magento\Framework\App\Area::AREA_GLOBAL);
7566

76-
/** @var ProductCollection $productCollection */
67+
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
7768
$productCollection = $this->productCollectionFactory->create();
7869
$productIds = $productCollection->getAllIds();
7970
if (!count($productIds)) {
@@ -85,13 +76,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
8576
try {
8677
foreach ($productIds as $productId) {
8778
try {
88-
/** @var Product $product */
79+
/** @var \Magento\Catalog\Model\Product $product */
8980
$product = $this->productRepository->getById($productId);
90-
} catch (NoSuchEntityException $e) {
81+
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
9182
continue;
9283
}
9384

94-
/** @var ImageCache $imageCache */
85+
/** @var \Magento\Catalog\Model\Product\Image\Cache $imageCache */
9586
$imageCache = $this->imageCacheFactory->create();
9687
$imageCache->generate($product);
9788

app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function configure()
7878
protected function execute(InputInterface $input, OutputInterface $output)
7979
{
8080
$output->setDecorated(true);
81-
$this->appState->setAreaCode('catalog');
81+
$this->appState->setAreaCode(\Magento\Framework\App\Area::AREA_GLOBAL);
8282
$connection = $this->attributeResource->getConnection();
8383
$attributeTables = $this->getAttributeTables();
8484

app/code/Magento/Catalog/Test/Unit/Console/Command/ImagesResizeCommandTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\App\State as AppState;
1515
use Magento\Framework\Exception\NoSuchEntityException;
1616
use Symfony\Component\Console\Tester\CommandTester;
17+
use \Magento\Framework\App\Area;
1718

1819
/**
1920
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -79,7 +80,7 @@ public function testExecuteNoProducts()
7980
{
8081
$this->appState->expects($this->once())
8182
->method('setAreaCode')
82-
->with('catalog')
83+
->with(Area::AREA_GLOBAL)
8384
->willReturnSelf();
8485

8586
$this->productCollection->expects($this->once())
@@ -101,7 +102,7 @@ public function testExecute()
101102

102103
$this->appState->expects($this->once())
103104
->method('setAreaCode')
104-
->with('catalog')
105+
->with(Area::AREA_GLOBAL)
105106
->willReturnSelf();
106107

107108
$this->productCollection->expects($this->once())
@@ -142,7 +143,7 @@ public function testExecuteWithException()
142143

143144
$this->appState->expects($this->once())
144145
->method('setAreaCode')
145-
->with('catalog')
146+
->with(Area::AREA_GLOBAL)
146147
->willReturnSelf();
147148

148149
$this->productCollection->expects($this->once())

app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ public function dataProviderAfterAddressSaveNewGroup()
587587
'country_id' => 1,
588588
'country_code' => 'US',
589589
'group_id' => 1,
590-
'area_code' => Area::AREA_ADMIN,
590+
'area_code' => Area::AREA_ADMINHTML,
591591
'is_vat_valid' => false,
592592
'request_sucess' => false,
593593
'valid_message' => '',

app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/PreviewTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,13 @@ public function testToHtml($requestParamMap)
8484
->setConstructorArgs([
8585
$scopeConfig
8686
])
87-
->setMethods(null)
87+
->setMethods(['emulateAreaCode'])
8888
->disableOriginalConstructor()
8989
->getMock();
90+
$appState->expects($this->any())
91+
->method('emulateAreaCode')
92+
->with(\Magento\Email\Model\AbstractTemplate::DEFAULT_DESIGN_AREA, [$template, 'getProcessedTemplate'])
93+
->willReturn($template->getProcessedTemplate());
9094

9195
$context = $this->getMock(
9296
\Magento\Backend\Block\Template\Context::class,

app/code/Magento/Store/Model/App/Emulation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ protected function _restoreInitialDesign(array $initialDesign)
235235
*/
236236
protected function _restoreInitialLocale(
237237
$initialLocaleCode,
238-
$initialArea = \Magento\Framework\App\Area::AREA_ADMIN
238+
$initialArea = \Magento\Framework\App\Area::AREA_ADMINHTML
239239
) {
240240
$this->_localeResolver->setLocale($initialLocaleCode);
241241
$this->_translate->setLocale($initialLocaleCode);

dev/tests/functional/utils/generate.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
$magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER);
1010
$magentoObjectManager = $magentoObjectManagerFactory->create($_SERVER);
1111

12-
// Generate repositories
13-
$magentoObjectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend');
14-
1512
// Generate factories for old end-to-end tests
1613
$magentoObjectManager->create(\Magento\Mtf\Util\Generate\Factory::class)->launch();
1714

dev/tests/integration/testsuite/Magento/Framework/View/Element/TemplateTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Framework\View\Element;
77

8+
use \Magento\Framework\App\Area;
9+
810
class TemplateTest extends \PHPUnit_Framework_TestCase
911
{
1012
/**
@@ -52,16 +54,12 @@ public function testGetArea()
5254
$this->assertEquals('frontend', $this->_block->getArea());
5355
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
5456
\Magento\Framework\App\State::class
55-
)->setAreaCode(
56-
'some_area'
57-
);
58-
$this->assertEquals('some_area', $this->_block->getArea());
57+
)->setAreaCode(Area::AREA_ADMINHTML);
58+
$this->assertEquals(Area::AREA_ADMINHTML, $this->_block->getArea());
5959
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
6060
\Magento\Framework\App\State::class
61-
)->setAreaCode(
62-
'another_area'
63-
);
64-
$this->assertEquals('another_area', $this->_block->getArea());
61+
)->setAreaCode(Area::AREA_GLOBAL);
62+
$this->assertEquals(Area::AREA_GLOBAL, $this->_block->getArea());
6563
}
6664

6765
/**
@@ -71,7 +69,7 @@ public function testGetArea()
7169
public function testToHtml()
7270
{
7371
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\App\State::class)
74-
->setAreaCode('any area');
72+
->setAreaCode(Area::AREA_GLOBAL);
7573
$this->assertEmpty($this->_block->toHtml());
7674
$this->_block->setTemplate(uniqid('invalid_filename.phtml'));
7775
$this->assertEmpty($this->_block->toHtml());

dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public function testSetGetArea()
8585
{
8686
$this->assertEquals(\Magento\Framework\View\DesignInterface::DEFAULT_AREA, $this->_model->getArea());
8787
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\App\State::class)
88-
->setAreaCode('test');
89-
$this->assertEquals('test', $this->_model->getArea());
88+
->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
89+
$this->assertEquals(\Magento\Framework\App\Area::AREA_ADMINHTML, $this->_model->getArea());
9090
}
9191

9292
public function testSetDesignTheme()

lib/internal/Magento/Framework/App/Area.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ class Area implements \Magento\Framework\App\AreaInterface
1717
{
1818
const AREA_GLOBAL = 'global';
1919
const AREA_FRONTEND = 'frontend';
20-
const AREA_ADMIN = 'admin';
2120
const AREA_ADMINHTML = 'adminhtml';
2221
const AREA_DOC = 'doc';
2322
const AREA_CRONTAB = 'crontab';
2423
const AREA_WEBAPI_REST = 'webapi_rest';
2524
const AREA_WEBAPI_SOAP = 'webapi_soap';
2625

26+
/**
27+
* @deprecated
28+
*/
29+
const AREA_ADMIN = 'admin';
30+
2731
/**
2832
* Area parameter.
2933
*/

0 commit comments

Comments
 (0)