Skip to content

Commit fb61749

Browse files
Merge branch 'develop' into FearlessKiwi-MAGETWO-59948
* develop: (35 commits) MAGETWO-63062: Product image gallery look-ups use incorrect ID MAGETWO-63062: Product image gallery look-ups use incorrect ID MAGETWO-63062: Product image gallery look-ups use incorrect ID MAGETWO-62783: Wrong address template used for order e-mails MAGETWO-62783: Wrong address template used for order e-mails MTA-3971: Add variation for Checkout with Braintree Credit Card with specific allowed credit card types per country MTA-3996: Create util for troubleshooting analysis with functional test execution MTA-3996: Create util for troubleshooting analysis with functional test execution MAGETWO-62783: Wrong address template used for order e-mails MTA-3996: Create util for troubleshooting analysis with functional test execution MTA-3996: Create util for troubleshooting analysis with functional test execution MTA-3996: Create util for troubleshooting analysis with functional test execution MTA-3996: Create util for troubleshooting analysis with functional test execution MAGETWO-62783: Wrong address template used for order e-mails MAGETWO-62783: Wrong address template used for order e-mails MAGETWO-62783: Wrong address template used for order e-mails MTA-3971: Add variation for Checkout with Braintree Credit Card with specific allowed credit card types per country MTA-3971: Add variation for Checkout with Braintree Credit Card with specific allowed credit card types per country MTA-3971: Add variation for Checkout with Braintree Credit Card with specific allowed credit card types per country MTA-3970: Add variation for Checkout with Braintree Credit Card with specific allowed countries ...
2 parents eae530e + af5ee20 commit fb61749

File tree

46 files changed

+2091
-73
lines changed

Some content is hidden

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

46 files changed

+2091
-73
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,16 +2195,22 @@ public function addMediaGalleryData()
21952195
$linkField = $this->getProductEntityMetadata()->getLinkField();
21962196
$items = $this->getItems();
21972197

2198-
$select->where('entity.' . $linkField . ' IN (?)', array_map(function ($item) {
2199-
return $item->getId();
2200-
}, $items));
2201-
2198+
$select->where(
2199+
'entity.' . $linkField . ' IN (?)',
2200+
array_map(
2201+
function ($item) use ($linkField) {
2202+
return $item->getData($linkField);
2203+
},
2204+
$items
2205+
)
2206+
);
22022207
foreach ($this->getConnection()->fetchAll($select) as $row) {
22032208
$mediaGalleries[$row[$linkField]][] = $row;
22042209
}
22052210

22062211
foreach ($items as $item) {
2207-
$mediaEntries = isset($mediaGalleries[$item->getId()]) ? $mediaGalleries[$item->getId()] : [];
2212+
$mediaEntries = isset($mediaGalleries[$item->getData($linkField)]) ?
2213+
$mediaGalleries[$item->getData($linkField)] : [];
22082214
$this->getGalleryReadHandler()->addMediaDataToProduct($item, $mediaEntries);
22092215
}
22102216

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,12 @@ public function testAddProductCategoriesFilter()
224224
public function testAddMediaGalleryData()
225225
{
226226
$attributeId = 42;
227-
$itemId = 4242;
228-
$linkField = 'entity_id';
229-
$mediaGalleriesMock = [[$linkField => $itemId]];
227+
$rowId = 4;
228+
$linkField = 'row_id';
229+
$mediaGalleriesMock = [[$linkField => $rowId]];
230230
$itemMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
231231
->disableOriginalConstructor()
232+
->setMethods(['getData'])
232233
->getMock();
233234
$attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
234235
->disableOriginalConstructor()
@@ -248,13 +249,13 @@ public function testAddMediaGalleryData()
248249
$this->galleryResourceMock->expects($this->once())->method('createBatchBaseSelect')->willReturn($selectMock);
249250
$attributeMock->expects($this->once())->method('getAttributeId')->willReturn($attributeId);
250251
$this->entityMock->expects($this->once())->method('getAttribute')->willReturn($attributeMock);
251-
$itemMock->expects($this->atLeastOnce())->method('getId')->willReturn($itemId);
252-
$selectMock->expects($this->once())->method('where')->with('entity.' . $linkField . ' IN (?)', [$itemId]);
252+
$itemMock->expects($this->atLeastOnce())->method('getData')->willReturn($rowId);
253+
$selectMock->expects($this->once())->method('where')->with('entity.' . $linkField . ' IN (?)', [$rowId]);
253254
$this->metadataPoolMock->expects($this->once())->method('getMetadata')->willReturn($metadataMock);
254255
$metadataMock->expects($this->once())->method('getLinkField')->willReturn($linkField);
255256

256257
$this->connectionMock->expects($this->once())->method('fetchAll')->with($selectMock)->willReturn(
257-
[['entity_id' => $itemId]]
258+
[['row_id' => $rowId]]
258259
);
259260
$this->galleryReadHandlerMock->expects($this->once())->method('addMediaDataToProduct')
260261
->with($itemMock, $mediaGalleriesMock);

app/code/Magento/Sales/Model/Order/Address/Renderer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function __construct(
4848
*/
4949
public function format(Address $address, $type)
5050
{
51+
$this->addressConfig->setStore($address->getOrder()->getStoreId());
5152
$formatType = $this->addressConfig->getFormatByCode($type);
5253
if (!$formatType || !$formatType->getRenderer()) {
5354
return null;
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Test\Unit\Model\Order\Address;
7+
8+
use Magento\Sales\Model\Order\Address\Renderer as OrderAddressRenderer;
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
10+
use Magento\Customer\Model\Address\Config as CustomerAddressConfig;
11+
use Magento\Framework\Event\ManagerInterface as EventManager;
12+
use Magento\Sales\Model\Order\Address as OrderAddress;
13+
use Magento\Sales\Model\Order;
14+
use Magento\Customer\Block\Address\Renderer\RendererInterface as CustomerAddressBlockRenderer;
15+
use Magento\Framework\DataObject;
16+
17+
class RendererTest extends \PHPUnit_Framework_TestCase
18+
{
19+
/**
20+
* @var OrderAddressRenderer
21+
*/
22+
private $orderAddressRenderer;
23+
24+
/**
25+
* @var ObjectManagerHelper
26+
*/
27+
private $objectManagerHelper;
28+
29+
/**
30+
* @var CustomerAddressConfig|\PHPUnit_Framework_MockObject_MockObject
31+
*/
32+
private $customerAddressConfigMock;
33+
34+
/**
35+
* @var EventManager|\PHPUnit_Framework_MockObject_MockObject
36+
*/
37+
private $eventManagerMock;
38+
39+
/**
40+
* @var OrderAddress|\PHPUnit_Framework_MockObject_MockObject
41+
*/
42+
private $orderAddressMock;
43+
44+
/**
45+
* @var Order|\PHPUnit_Framework_MockObject_MockObject
46+
*/
47+
private $orderMock;
48+
49+
/**
50+
* @var CustomerAddressBlockRenderer|\PHPUnit_Framework_MockObject_MockObject
51+
*/
52+
private $customerAddressBlockRendererMock;
53+
54+
protected function setUp()
55+
{
56+
$this->customerAddressConfigMock = $this->getMockBuilder(CustomerAddressConfig::class)
57+
->disableOriginalConstructor()
58+
->getMock();
59+
$this->eventManagerMock = $this->getMockBuilder(EventManager::class)
60+
->getMockForAbstractClass();
61+
$this->orderAddressMock = $this->getMockBuilder(OrderAddress::class)
62+
->disableOriginalConstructor()
63+
->getMock();
64+
$this->orderMock = $this->getMockBuilder(Order::class)
65+
->disableOriginalConstructor()
66+
->getMock();
67+
$this->customerAddressBlockRendererMock = $this->getMockBuilder(CustomerAddressBlockRenderer::class)
68+
->getMockForAbstractClass();
69+
70+
$this->orderAddressMock->expects(static::any())
71+
->method('getOrder')
72+
->willReturn($this->orderMock);
73+
74+
$this->objectManagerHelper = new ObjectManagerHelper($this);
75+
$this->orderAddressRenderer = $this->objectManagerHelper->getObject(
76+
OrderAddressRenderer::class,
77+
[
78+
'addressConfig' => $this->customerAddressConfigMock,
79+
'eventManager' => $this->eventManagerMock
80+
]
81+
);
82+
}
83+
84+
public function testFormat()
85+
{
86+
$type = 'html';
87+
$formatType = new DataObject(['renderer' => $this->customerAddressBlockRendererMock]);
88+
$addressData = ['address', 'data'];
89+
$result = 'result string';
90+
91+
$this->setStoreExpectations(1);
92+
$this->customerAddressConfigMock->expects(static::atLeastOnce())
93+
->method('getFormatByCode')
94+
->with($type)
95+
->willReturn($formatType);
96+
$this->eventManagerMock->expects(static::once())
97+
->method('dispatch')
98+
->with('customer_address_format', ['type' => $formatType, 'address' => $this->orderAddressMock]);
99+
$this->orderAddressMock->expects(static::atLeastOnce())
100+
->method('getData')
101+
->willReturn($addressData);
102+
$this->customerAddressBlockRendererMock->expects(static::once())
103+
->method('renderArray')
104+
->with($addressData, null)
105+
->willReturn($result);
106+
107+
$this->assertEquals($result, $this->orderAddressRenderer->format($this->orderAddressMock, $type));
108+
}
109+
110+
public function testFormatNoRenderer()
111+
{
112+
$type = 'html';
113+
114+
$this->setStoreExpectations(1);
115+
$this->customerAddressConfigMock->expects(static::atLeastOnce())
116+
->method('getFormatByCode')
117+
->with($type)
118+
->willReturn(null);
119+
$this->eventManagerMock->expects(static::never())
120+
->method('dispatch');
121+
122+
$this->assertEquals(null, $this->orderAddressRenderer->format($this->orderAddressMock, $type));
123+
}
124+
125+
/**
126+
* Set expectations for store
127+
*
128+
* @param string|int $storeId
129+
* @return void
130+
*/
131+
private function setStoreExpectations($storeId)
132+
{
133+
$this->orderMock->expects(static::atLeastOnce())
134+
->method('getStoreId')
135+
->willReturn($storeId);
136+
$this->customerAddressConfigMock->expects(static::atLeastOnce())
137+
->method('setStore')
138+
->with($storeId)
139+
->willReturnSelf();
140+
}
141+
}

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]

0 commit comments

Comments
 (0)