Skip to content

Commit 12ac8a1

Browse files
authored
Merge pull request #5568 from magento-tsg-csl3/2.3-develop-pr43
[TSG-CSL3] For 2.3 (pr43)
2 parents 84dc9ff + b2951aa commit 12ac8a1

File tree

8 files changed

+57
-89
lines changed

8 files changed

+57
-89
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Image/Placeholder.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Image;
99

1010
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
11+
use Magento\Framework\App\Area;
1112
use Magento\Framework\View\Asset\Repository as AssetRepository;
13+
use Magento\Framework\View\DesignInterface;
1214

1315
/**
1416
* Image Placeholder provider
@@ -25,16 +27,24 @@ class Placeholder
2527
*/
2628
private $assetRepository;
2729

30+
/**
31+
* @var DesignInterface
32+
*/
33+
private $themeDesign;
34+
2835
/**
2936
* @param PlaceholderFactory $placeholderFactory
3037
* @param AssetRepository $assetRepository
38+
* @param DesignInterface $themeDesign
3139
*/
3240
public function __construct(
3341
PlaceholderFactory $placeholderFactory,
34-
AssetRepository $assetRepository
42+
AssetRepository $assetRepository,
43+
DesignInterface $themeDesign
3544
) {
3645
$this->placeholderFactory = $placeholderFactory;
3746
$this->assetRepository = $assetRepository;
47+
$this->themeDesign = $themeDesign;
3848
}
3949

4050
/**
@@ -52,8 +62,14 @@ public function getPlaceholder(string $imageType): string
5262
return $imageAsset->getUrl();
5363
}
5464

55-
return $this->assetRepository->getUrl(
56-
"Magento_Catalog::images/product/placeholder/{$imageType}.jpg"
65+
$params = [
66+
'area' => Area::AREA_FRONTEND,
67+
'themeId' => $this->themeDesign->getConfigurationDesignTheme(Area::AREA_FRONTEND),
68+
];
69+
70+
return $this->assetRepository->getUrlWithParams(
71+
"Magento_Catalog::images/product/placeholder/{$imageType}.jpg",
72+
$params
5773
);
5874
}
5975
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Image/Placeholder/Theme.php

Lines changed: 0 additions & 71 deletions
This file was deleted.

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,33 @@ public function testProductSmallImageUrlWithExistingImage()
3838
self::assertTrue($this->checkImageExists($response['products']['items'][0]['small_image']['url']));
3939
}
4040

41+
/**
42+
* Test for get product image placeholder
43+
*
44+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
45+
*/
46+
public function testProductSmallImageUrlPlaceholder()
47+
{
48+
$productSku = 'simple';
49+
$query = <<<QUERY
50+
{
51+
products(filter: {sku: {eq: "{$productSku}"}}) {
52+
items {
53+
small_image {
54+
url
55+
}
56+
}
57+
}
58+
}
59+
QUERY;
60+
$response = $this->graphQlQuery($query);
61+
$responseImage = $response['products']['items'][0]['small_image'];
62+
63+
self::assertArrayHasKey('url', $responseImage);
64+
self::assertContains('placeholder/small_image.jpg', $responseImage['url']);
65+
self::assertTrue($this->checkImageExists($responseImage['url']));
66+
}
67+
4168
/**
4269
* @magentoApiDataFixture Magento/Catalog/_files/product_with_multiple_images.php
4370
*/

dev/tests/integration/testsuite/Magento/Developer/Model/Logger/Handler/DebugTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function testDebugInDeveloperMode()
139139
{
140140
$message = 'test message';
141141
$this->reinitDebugHandler(State::MODE_DEVELOPER);
142-
142+
$this->deploymentConfig->resetData();
143143
$this->removeDebugLog();
144144
$this->logger->debug($message);
145145
$this->assertFileExists($this->getDebuggerLogPath());

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public function get($key = null, $defaultValue = null)
8686
*/
8787
public function isAvailable()
8888
{
89-
$this->data = null;
9089
$this->load();
9190
return isset($this->flatData[ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE]);
9291
}
@@ -141,7 +140,7 @@ public function isDbAvailable()
141140
*/
142141
private function load()
143142
{
144-
if (null === $this->data) {
143+
if (empty($this->data)) {
145144
$this->data = $this->reader->load();
146145
if ($this->overrideData) {
147146
$this->data = array_replace($this->data, $this->overrideData);
@@ -173,10 +172,12 @@ private function flattenParams(array $params, $path = null)
173172
$newPath = $key;
174173
}
175174
if (isset($cache[$newPath])) {
175+
//phpcs:ignore Magento2.Exceptions.DirectThrow
176176
throw new \Exception("Key collision {$newPath} is already defined.");
177177
}
178178
$cache[$newPath] = $param;
179179
if (is_array($param)) {
180+
//phpcs:ignore Magento2.Performance.ForeachArrayMerge
180181
$cache = array_merge($cache, $this->flattenParams($param, $newPath));
181182
}
182183
}

lib/internal/Magento/Framework/Locale/Resolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class Resolver implements ResolverInterface
1616
{
1717
/**
18-
* Default locale
18+
* Resolver default locale
1919
*/
2020
const DEFAULT_LOCALE = 'en_US';
2121

@@ -79,7 +79,7 @@ public function __construct(
7979
$this->scopeConfig = $scopeConfig;
8080
$this->defaultLocalePath = $defaultLocalePath;
8181
$this->scopeType = $scopeType;
82-
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->create(DeploymentConfig::class);
82+
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->get(DeploymentConfig::class);
8383
$this->setLocale($locale);
8484
}
8585

lib/internal/Magento/Framework/Module/ModuleList.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(DeploymentConfig $config, ModuleList\Loader $loader)
5959
}
6060

6161
/**
62-
* {@inheritdoc}
62+
* @inheritdoc
6363
*
6464
* Note that this triggers loading definitions of all existing modules in the system.
6565
* Use this method only when you actually need modules' declared meta-information.
@@ -84,7 +84,8 @@ public function getAll()
8484
}
8585

8686
/**
87-
* {@inheritdoc}
87+
* @inheritdoc
88+
*
8889
* @see has()
8990
*/
9091
public function getOne($name)
@@ -94,7 +95,7 @@ public function getOne($name)
9495
}
9596

9697
/**
97-
* {@inheritdoc}
98+
* @inheritdoc
9899
*/
99100
public function getNames()
100101
{
@@ -107,7 +108,7 @@ public function getNames()
107108
}
108109

109110
/**
110-
* {@inheritdoc}
111+
* @inheritdoc
111112
*/
112113
public function has($name)
113114
{
@@ -139,7 +140,6 @@ public function isModuleInfoAvailable()
139140
*/
140141
private function loadConfigData()
141142
{
142-
$this->config->resetData();
143143
if (null === $this->configData && null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) {
144144
$this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES);
145145
}

lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ protected function setUp()
4747

4848
public function testGetAll()
4949
{
50-
$this->config->expects($this->exactly(2))->method('resetData');
5150
$this->setLoadAllExpectation();
5251
$this->setLoadConfigExpectation();
5352
$expected = ['foo' => self::$allFixture['foo']];
@@ -65,7 +64,6 @@ public function testGetAllNoData()
6564

6665
public function testGetOne()
6766
{
68-
$this->config->expects($this->exactly(2))->method('resetData');
6967
$this->setLoadAllExpectation();
7068
$this->setLoadConfigExpectation();
7169
$this->assertSame(['key' => 'value'], $this->model->getOne('foo'));
@@ -74,7 +72,6 @@ public function testGetOne()
7472

7573
public function testGetNames()
7674
{
77-
$this->config->expects($this->exactly(2))->method('resetData');
7875
$this->setLoadAllExpectation(false);
7976
$this->setLoadConfigExpectation();
8077
$this->assertSame(['foo'], $this->model->getNames());
@@ -83,7 +80,6 @@ public function testGetNames()
8380

8481
public function testHas()
8582
{
86-
$this->config->expects($this->exactly(2))->method('resetData');
8783
$this->setLoadAllExpectation(false);
8884
$this->setLoadConfigExpectation();
8985
$this->assertTrue($this->model->has('foo'));
@@ -92,7 +88,6 @@ public function testHas()
9288

9389
public function testIsModuleInfoAvailable()
9490
{
95-
$this->config->expects($this->once())->method('resetData');
9691
$this->setLoadConfigExpectation(true);
9792
$this->assertTrue($this->model->isModuleInfoAvailable());
9893
}

0 commit comments

Comments
 (0)