Skip to content

Commit c5c0686

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into BUGS
2 parents ee46122 + 0aff845 commit c5c0686

File tree

49 files changed

+1895
-39
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1895
-39
lines changed

app/code/Magento/Catalog/Model/Product/Gallery/UpdateHandler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ protected function processDeletedImages($product, array &$images)
2929
if (!empty($image['removed'])) {
3030
if (!empty($image['value_id']) && !isset($picturesInOtherStores[$image['file']])) {
3131
$recordsToDelete[] = $image['value_id'];
32-
$filesToDelete[] = ltrim($image['file'], '/');
32+
// only delete physical files if they are not used by any other products
33+
if (!$this->resourceModel->countImageUses($image['file']) > 1) {
34+
$filesToDelete[] = ltrim($image['file'], '/');
35+
}
3336
}
3437
}
3538
}

app/code/Magento/Catalog/Model/Product/Pricing/Renderer/SalableResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ class SalableResolver implements SalableResolverInterface
1919
*/
2020
public function isSalable(\Magento\Framework\Pricing\SaleableInterface $salableItem)
2121
{
22-
return $salableItem->getCanShowPrice() !== false && $salableItem->isSalable();
22+
return $salableItem->getCanShowPrice() !== false;
2323
}
2424
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Gallery.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,4 +449,21 @@ public function getProductImages($product, $storeIds)
449449

450450
return $this->getConnection()->fetchAll($select);
451451
}
452+
453+
/**
454+
* Counts uses of this image.
455+
*
456+
* @param string $image
457+
* @return int
458+
*/
459+
public function countImageUses($image)
460+
{
461+
$select = $this->getConnection()->select()
462+
->from([$this->getMainTableAlias() => $this->getMainTable()])
463+
->where(
464+
'value = ?',
465+
$image
466+
);
467+
return count($this->getConnection()->fetchAll($select));
468+
}
452469
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Pricing/Renderer/SalableResolverTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected function setUp()
2222
{
2323
$this->product = $this->getMock(
2424
\Magento\Catalog\Model\Product::class,
25-
['__wakeup', 'getCanShowPrice', 'isSalable'],
25+
['__wakeup', 'getCanShowPrice'],
2626
[],
2727
'',
2828
false
@@ -40,8 +40,6 @@ public function testSalableItem()
4040
->method('getCanShowPrice')
4141
->willReturn(true);
4242

43-
$this->product->expects($this->any())->method('isSalable')->willReturn(true);
44-
4543
$result = $this->object->isSalable($this->product);
4644
$this->assertTrue($result);
4745
}
@@ -50,9 +48,7 @@ public function testNotSalableItem()
5048
{
5149
$this->product->expects($this->any())
5250
->method('getCanShowPrice')
53-
->willReturn(true);
54-
55-
$this->product->expects($this->any())->method('isSalable')->willReturn(false);
51+
->willReturn(false);
5652

5753
$result = $this->object->isSalable($this->product);
5854
$this->assertFalse($result);

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/GalleryTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,4 +443,33 @@ public function testDeleteGalleryValueInStore()
443443

444444
$this->resource->deleteGalleryValueInStore($valueId, $entityId, $storeId);
445445
}
446+
447+
public function testCountImageUses()
448+
{
449+
$results = [
450+
[
451+
'value_id' => '1',
452+
'attribute_id' => 90,
453+
'value' => '/d/o/download_7.jpg',
454+
'media_type' => 'image',
455+
'disabled' => '0',
456+
],
457+
];
458+
459+
$this->connection->expects($this->once())->method('select')->will($this->returnValue($this->select));
460+
$this->select->expects($this->at(0))->method('from')->with(
461+
[
462+
'main' => 'table',
463+
],
464+
'*'
465+
)->willReturnSelf();
466+
$this->select->expects($this->at(1))->method('where')->with(
467+
'value = ?',
468+
1
469+
)->willReturnSelf();
470+
$this->connection->expects($this->once())->method('fetchAll')
471+
->with($this->select)
472+
->willReturn($results);
473+
$this->assertEquals($this->resource->countImageUses(1), count($results));
474+
}
446475
}

app/code/Magento/Widget/Model/ResourceModel/Widget/Instance/Options/ThemeId.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class ThemeId implements \Magento\Framework\Option\ArrayInterface
2222
protected $_resourceModel;
2323

2424
/**
25-
* @param \Magento\Theme\Model\ResourceModel\Theme\Collection $widgetResourceModel
25+
* @param \Magento\Theme\Model\ResourceModel\Theme\CollectionFactory $widgetResourceModel
2626
*/
27-
public function __construct(\Magento\Theme\Model\ResourceModel\Theme\Collection $widgetResourceModel)
27+
public function __construct(\Magento\Theme\Model\ResourceModel\Theme\CollectionFactory $widgetResourceModel)
2828
{
29-
$this->_resourceModel = $widgetResourceModel;
29+
$this->_resourceModel = $widgetResourceModel->create();
3030
}
3131

3232
/**

dev/tests/functional/.htaccess.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
##############################################
2-
## Allow access to command.php and website.php
3-
<FilesMatch "command.php|website.php|export.php|pathChecker.php|deleteMagentoGeneratedCode.php">
2+
## Allow access to command.php, website.php, export.php, pathChecker.php, deleteMagentoGeneratedCode.php and log.php
3+
<FilesMatch "command.php|website.php|export.php|pathChecker.php|deleteMagentoGeneratedCode.php|log.php">
44
order allow,deny
55
allow from all
66
</FilesMatch>

dev/tests/functional/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"magento/mtf": "1.0.0-rc52",
3+
"magento/mtf": "1.0.0-rc53",
44
"php": "~5.6.5|7.0.2|~7.0.6",
55
"phpunit/phpunit": "~4.8.0|~5.5.0",
66
"phpunit/phpunit-selenium": ">=1.2"

dev/tests/functional/etc/di.xml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<preference for="Magento\Mtf\Console\CommandListInterface" type="Magento\Mtf\Console\CommandList" />
910
<preference for="Magento\Mtf\Util\Command\File\ExportInterface" type="\Magento\Mtf\Util\Command\File\Export" />
1011
<preference for="Magento\Mtf\Util\Command\File\Export\ReaderInterface" type="\Magento\Mtf\Util\Command\File\Export\Reader" />
1112

@@ -19,6 +20,84 @@
1920

2021
<type name="Magento\Mtf\Util\Protocol\CurlTransport\WebapiDecorator" shared="true" />
2122

23+
<type name="Magento\Mtf\Console\CommandList">
24+
<arguments>
25+
<argument name="commands" xsi:type="array">
26+
<item name="check-magento-storefront" xsi:type="object">Magento\Mtf\Troubleshooting\StorefrontAnalyzer</item>
27+
<item name="check-phpunit-config-file" xsi:type="object">Magento\Mtf\Troubleshooting\PhpUnitAnalyzer</item>
28+
<item name="check-magento-admin" xsi:type="object">Magento\Mtf\Troubleshooting\AdminAnalyzer</item>
29+
<item name="apply-magento-configuration" xsi:type="object">Magento\Mtf\Troubleshooting\Configuration</item>
30+
<item name="check-selenium-session-connection" xsi:type="object">Magento\Mtf\Troubleshooting\SeleniumSessionAnalyzer</item>
31+
<item name="generate-static-classes" xsi:type="object">Magento\Mtf\Troubleshooting\StaticClassesGenerator</item>
32+
<item name="check-config-valid" xsi:type="object">Magento\Mtf\Troubleshooting\ConfigAnalyzer</item>
33+
<item name="check-htaccess" xsi:type="object">Magento\Mtf\Troubleshooting\HtaccessAnalyzer</item>
34+
<item name="check-all" xsi:type="object">Magento\Mtf\Troubleshooting\GlobalAnalyzer</item>
35+
</argument>
36+
</arguments>
37+
</type>
38+
39+
<type name="Magento\Mtf\Troubleshooting\GlobalAnalyzer">
40+
<arguments>
41+
<argument name="commandList" xsi:type="array">
42+
<item name="0" xsi:type="object">Magento\Mtf\Troubleshooting\PhpUnitAnalyzer</item>
43+
<item name="1" xsi:type="object">Magento\Mtf\Troubleshooting\StorefrontAnalyzer</item>
44+
<item name="2" xsi:type="object">Magento\Mtf\Troubleshooting\ConfigAnalyzer</item>
45+
<item name="3" xsi:type="object">Magento\Mtf\Troubleshooting\AdminAnalyzer</item>
46+
<item name="4" xsi:type="object">Magento\Mtf\Troubleshooting\Configuration</item>
47+
<item name="5" xsi:type="object">Magento\Mtf\Troubleshooting\HtaccessAnalyzer</item>
48+
<item name="6" xsi:type="object">Magento\Mtf\Troubleshooting\StaticClassesGenerator</item>
49+
<item name="7" xsi:type="object">Magento\Mtf\Troubleshooting\SeleniumSessionAnalyzer</item>
50+
</argument>
51+
</arguments>
52+
</type>
53+
54+
<type name="Magento\Mtf\Troubleshooting\ConfigAnalyzer">
55+
<arguments>
56+
<argument name="configXml" xsi:type="object">Magento\Mtf\Util\Troubleshooting\GlobalConfig</argument>
57+
<argument name="configXmlDist" xsi:type="object">Magento\Mtf\Util\Troubleshooting\GlobalConfigDist</argument>
58+
</arguments>
59+
</type>
60+
61+
<virtualType name="Magento\Mtf\Util\Troubleshooting\Config" type="Magento\Mtf\Config\Reader\Filesystem">
62+
<arguments>
63+
<argument name="fileResolver" xsi:type="object">Magento\Mtf\Config\FileResolver\Primary</argument>
64+
<argument name="converter" xsi:type="object">Magento\Mtf\Config\Converter</argument>
65+
<argument name="schemaLocator" xsi:type="object">Magento\Mtf\Config\SchemaLocator\Config</argument>
66+
<argument name="idAttributes" xsi:type="array">
67+
<item name="/config" xsi:type="string">scope</item>
68+
<item name="/config/server/item" xsi:type="string">name</item>
69+
</argument>
70+
<argument name="fileName" xsi:type="string">config.xml</argument>
71+
<argument name="defaultScope" xsi:type="string">etc</argument>
72+
</arguments>
73+
</virtualType>
74+
75+
<virtualType name="Magento\Mtf\Util\Troubleshooting\GlobalConfig" type="Magento\Mtf\Config\Data">
76+
<arguments>
77+
<argument name="reader" xsi:type="object">Magento\Mtf\Util\Troubleshooting\Config</argument>
78+
</arguments>
79+
</virtualType>
80+
81+
<virtualType name="Magento\Mtf\Util\Troubleshooting\ConfigDist" type="Magento\Mtf\Config\Reader\Filesystem">
82+
<arguments>
83+
<argument name="fileResolver" xsi:type="object">Magento\Mtf\Config\FileResolver\ScopeConfig</argument>
84+
<argument name="converter" xsi:type="object">Magento\Mtf\Config\Converter</argument>
85+
<argument name="schemaLocator" xsi:type="object">Magento\Mtf\Config\SchemaLocator\Config</argument>
86+
<argument name="idAttributes" xsi:type="array">
87+
<item name="/config" xsi:type="string">scope</item>
88+
<item name="/config/server/item" xsi:type="string">name</item>
89+
</argument>
90+
<argument name="fileName" xsi:type="string">config.xml.dist</argument>
91+
<argument name="defaultScope" xsi:type="string">etc</argument>
92+
</arguments>
93+
</virtualType>
94+
95+
<virtualType name="Magento\Mtf\Util\Troubleshooting\GlobalConfigDist" type="Magento\Mtf\Config\Data">
96+
<arguments>
97+
<argument name="reader" xsi:type="object">Magento\Mtf\Util\Troubleshooting\ConfigDist</argument>
98+
</arguments>
99+
</virtualType>
100+
22101
<type name="Magento\Mtf\Util\Command\File\Export\Reader">
23102
<arguments>
24103
<argument name="template" xsi:type="string">\w*?\.csv</argument>

dev/tests/functional/lib/Magento/Mtf/App/State/State1.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,51 @@
66

77
namespace Magento\Mtf\App\State;
88

9+
use Magento\Mtf\ObjectManager;
10+
use Magento\Mtf\Util\Protocol\CurlInterface;
11+
use Magento\Mtf\Util\Protocol\CurlTransport;
12+
913
/**
1014
* Example Application State class.
1115
*/
1216
class State1 extends AbstractState
1317
{
18+
/**
19+
* Object Manager.
20+
*
21+
* @var ObjectManager
22+
*/
23+
protected $objectManager;
24+
1425
/**
1526
* Data for configuration state.
1627
*
1728
* @var string
1829
*/
1930
protected $config ='admin_session_lifetime_1_hour, wysiwyg_disabled, admin_account_sharing_enable, log_to_file';
2031

32+
/**
33+
* HTTP CURL Adapter.
34+
*
35+
* @var CurlTransport
36+
*/
37+
private $curlTransport;
38+
39+
/**
40+
* @param ObjectManager $objectManager
41+
* @param CurlTransport $curlTransport
42+
* @param array $arguments
43+
*/
44+
public function __construct(
45+
ObjectManager $objectManager,
46+
CurlTransport $curlTransport,
47+
array $arguments
48+
) {
49+
parent::__construct($objectManager, $arguments);
50+
$this->objectManager = $objectManager;
51+
$this->curlTransport = $curlTransport;
52+
}
53+
2154
/**
2255
* Apply set up configuration profile.
2356
*
@@ -26,7 +59,9 @@ class State1 extends AbstractState
2659
public function apply()
2760
{
2861
parent::apply();
29-
if (file_exists(dirname(dirname(dirname(MTF_BP))) . '/app/etc/config.php')) {
62+
$this->curlTransport->write($_ENV['app_frontend_url'], [], CurlInterface::GET);
63+
$response = $this->curlTransport->read();
64+
if (strpos($response, 'Home Page') !== false) {
3065
$this->objectManager->create(
3166
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
3267
['configData' => $this->config]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Mtf\Config\FileResolver;
8+
9+
use Magento\Mtf\Util\Iterator\File;
10+
11+
/**
12+
* Provides MTF configuration file from specified scope.
13+
*/
14+
class ScopeConfig extends Primary
15+
{
16+
/**
17+
* Retrieve the configuration file with given name that relate to MTF global configuration.
18+
*
19+
* @param string $filename
20+
* @param string $scope
21+
* @return File|array
22+
*/
23+
public function get($filename, $scope)
24+
{
25+
return new File([MTF_BP . DIRECTORY_SEPARATOR . $scope . DIRECTORY_SEPARATOR . $filename]);
26+
}
27+
}

0 commit comments

Comments
 (0)