Skip to content

Commit 2a8db34

Browse files
author
Dale Sikkema
committed
Merge remote-tracking branch 'mainline/develop' into develop
2 parents c93c09e + 2015f5c commit 2a8db34

File tree

84 files changed

+451
-316
lines changed

Some content is hidden

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

84 files changed

+451
-316
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Setup;
7+
8+
use Magento\Framework\Setup\UpgradeDataInterface;
9+
use Magento\Framework\Setup\ModuleContextInterface;
10+
use Magento\Framework\Setup\ModuleDataSetupInterface;
11+
use Magento\Catalog\Model\Category;
12+
13+
/**
14+
* @codeCoverageIgnore
15+
*/
16+
class UpgradeData implements UpgradeDataInterface
17+
{
18+
/**
19+
* @var Category
20+
*/
21+
protected $category;
22+
23+
/**
24+
* @param Category $category
25+
*/
26+
public function __construct(Category $category)
27+
{
28+
$this->category = $category;
29+
}
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
35+
{
36+
if (version_compare($context->getVersion(), '2.0.0.2') < 0) {
37+
$newBackendModel = 'Magento\Catalog\Model\Attribute\Backend\Startdate';
38+
$connection = $setup->getConnection();
39+
$connection->startSetup();
40+
$connection->update(
41+
$setup->getTable('eav_attribute'),
42+
['backend_model' => $newBackendModel],
43+
['backend_model = ?' => 'Magento\Catalog\Model\Product\Attribute\Backend\Startdate']
44+
);
45+
/** @var \Magento\Catalog\Model\Resource\Eav\Attribute $attribute */
46+
foreach ($this->category->getAttributes() as $attribute) {
47+
if ($attribute->getAttributeCode() == 'custom_design_from') {
48+
$attribute->setBackendModel($newBackendModel);
49+
$attribute->save();
50+
break;
51+
}
52+
}
53+
$connection->endSetup();
54+
}
55+
}
56+
}

app/code/Magento/Catalog/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
9-
<module name="Magento_Catalog" setup_version="2.0.0.1">
9+
<module name="Magento_Catalog" setup_version="2.0.0.2">
1010
<sequence>
1111
<module name="Magento_Eav"/>
1212
<module name="Magento_Cms"/>

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
123123
*/
124124
protected $_attributeTypes = [];
125125

126+
/**
127+
* Product collection
128+
*
129+
* @var \Magento\Catalog\Model\Resource\Product\CollectionFactory
130+
*/
131+
protected $_entityCollectionFactory;
132+
126133
/**
127134
* Product collection
128135
*
@@ -231,7 +238,7 @@ public function __construct(
231238
\Magento\Framework\App\Resource $resource,
232239
\Magento\Store\Model\StoreManagerInterface $storeManager,
233240
\Psr\Log\LoggerInterface $logger,
234-
\Magento\Catalog\Model\Resource\Product\Collection $collection,
241+
\Magento\Catalog\Model\Resource\Product\CollectionFactory $collectionFactory,
235242
\Magento\ImportExport\Model\Export\ConfigInterface $exportConfig,
236243
\Magento\Catalog\Model\Resource\ProductFactory $productFactory,
237244
\Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $attrSetColFactory,
@@ -243,7 +250,7 @@ public function __construct(
243250
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider,
244251
\Magento\CatalogImportExport\Model\Export\RowCustomizerInterface $rowCustomizer
245252
) {
246-
$this->_entityCollection = $collection;
253+
$this->_entityCollectionFactory = $collectionFactory;
247254
$this->_exportConfig = $exportConfig;
248255
$this->_logger = $logger;
249256
$this->_productFactory = $productFactory;
@@ -669,12 +676,13 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows)
669676
}
670677

671678
/**
672-
* Get product collection
673-
*
674-
* @return \Magento\Catalog\Model\Resource\Product\Collection
679+
* {@inheritdoc}
675680
*/
676-
protected function _getEntityCollection()
681+
protected function _getEntityCollection($resetCollection = false)
677682
{
683+
if ($resetCollection || empty($this->_entityCollection)) {
684+
$this->_entityCollection = $this->_entityCollectionFactory->create();
685+
}
678686
return $this->_entityCollection;
679687
}
680688

@@ -735,23 +743,23 @@ protected function paginateCollection($page, $pageSize)
735743
/**
736744
* Export process
737745
*
738-
* @see https://jira.corp.x.com/browse/MAGETWO-7894
739746
* @return string
740747
*/
741748
public function export()
742749
{
743750
//Execution time may be very long
744751
set_time_limit(0);
745752

746-
$this->_prepareEntityCollection($this->_getEntityCollection());
747-
$this->_getEntityCollection()->setOrder('has_options', 'asc');
748-
$this->_getEntityCollection()->setStoreId(Store::DEFAULT_STORE_ID);
749753
$writer = $this->getWriter();
750754
$page = 0;
751755
while (true) {
752756
++$page;
757+
$entityCollection = $this->_getEntityCollection(true);
758+
$entityCollection->setOrder('has_options', 'asc');
759+
$entityCollection->setStoreId(Store::DEFAULT_STORE_ID);
760+
$this->_prepareEntityCollection($entityCollection);
753761
$this->paginateCollection($page, $this->getItemsPerPage());
754-
if ($this->_getEntityCollection()->count() == 0) {
762+
if ($entityCollection->count() == 0) {
755763
break;
756764
}
757765
$exportData = $this->getExportData();
@@ -761,7 +769,7 @@ public function export()
761769
foreach ($exportData as $dataRow) {
762770
$writer->writeRow($dataRow);
763771
}
764-
if ($this->_getEntityCollection()->getCurPage() >= $this->_getEntityCollection()->getLastPageNumber()) {
772+
if ($entityCollection->getCurPage() >= $entityCollection->getLastPageNumber()) {
765773
break;
766774
}
767775
}

app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,10 @@ abstract protected function _getHeaderColumns();
190190
/**
191191
* Get entity collection
192192
*
193+
* @param bool $resetCollection
193194
* @return \Magento\Framework\Data\Collection\Db
194195
*/
195-
abstract protected function _getEntityCollection();
196+
abstract protected function _getEntityCollection($resetCollection = false);
196197

197198
/**
198199
* Get attributes codes which are appropriate for export.

dev/tests/functional/.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
**/var
22
/composer.lock
3-
/config/*
43
/generated
54
/lib/Magento/Mtf/Util/Generate/testcase.xml
65
/vendor
7-
!/config/application.yml.dist
8-
!/config/handler.yml.dist
9-
!/config/isolation.yml.dist
10-
!/config/server.yml.dist
116
phpunit.xml
127
credentials.xml

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-rc25",
3+
"magento/mtf": "1.0.0-rc26",
44
"php": "~5.5.0|~5.6.0",
55
"phpunit/phpunit": "4.1.0",
66
"phpunit/phpunit-selenium": ">=1.2",

dev/tests/functional/phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<env name="testsuite_rule_path" value="Magento/Mtf/TestSuite/InjectableTests" />
3636
<env name="log_directory" value="var/log" />
3737
<env name="events_preset" value="base" />
38-
<env name="module_whitelist" value="Magento_Install,Magento_Core" />
38+
<env name="module_whitelist" value="Magento_Install" />
3939
<env name="basedir" value="var/log" />
4040
<env name="credentials_file_path" value="./credentials.xml.dist" />
4141
</php>

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Messages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public function getSuccessMessages()
7070
$elements = $this->_rootElement->getElements($this->successMessage);
7171

7272
$messages = [];
73-
foreach ($elements as $key => $element) {
74-
$messages[$key] = $element->getText();
73+
foreach ($elements as $element) {
74+
$messages[] = $element->getText();
7575
}
7676

7777
return count($messages) > 1 ? $messages : $messages[0];

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Mtf\Block\BlockFactory;
1010
use Magento\Mtf\Block\Mapper;
1111
use Magento\Mtf\Client\Locator;
12+
use Magento\Mtf\Client\ElementInterface;
1213
use Magento\Mtf\Fixture\FixtureInterface;
1314
use Magento\Mtf\Fixture\InjectableFixture;
1415
use Magento\Mtf\Client\BrowserInterface;
@@ -84,10 +85,10 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
8485
{
8586
$context = ($element === null) ? $this->_rootElement : $element;
8687
foreach ($tabs as $tabName => $tabFields) {
87-
$tabElement = $this->getTabElement($tabName);
88+
$tab = $this->getTab($tabName);
8889
$this->openTab($tabName);
89-
$tabElement->fillFormTab(array_merge($tabFields, $this->unassignedFields), $context);
90-
$this->updateUnassignedFields($tabElement);
90+
$tab->fillFormTab(array_merge($tabFields, $this->unassignedFields), $context);
91+
$this->updateUnassignedFields($tab);
9192
}
9293
if (!empty($this->unassignedFields)) {
9394
$this->fillMissedFields($tabs);
@@ -99,13 +100,13 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
99100
/**
100101
* Update array with fields which aren't assigned to any tab
101102
*
102-
* @param Tab $tabElement
103+
* @param Tab $tab
103104
*/
104-
protected function updateUnassignedFields(Tab $tabElement)
105+
protected function updateUnassignedFields(Tab $tab)
105106
{
106107
$this->unassignedFields = array_diff_key(
107108
$this->unassignedFields,
108-
array_intersect_key($this->unassignedFields, $tabElement->setFields)
109+
array_intersect_key($this->unassignedFields, $tab->setFields)
109110
);
110111
}
111112

@@ -120,10 +121,10 @@ protected function updateUnassignedFields(Tab $tabElement)
120121
protected function fillMissedFields(array $tabs)
121122
{
122123
foreach (array_diff_key($this->tabs, $tabs) as $tabName => $tabData) {
123-
$tabElement = $this->getTabElement($tabName);
124+
$tab = $this->getTab($tabName);
124125
if ($this->openTab($tabName)) {
125-
$tabElement->fillFormTab($this->unassignedFields, $this->_rootElement);
126-
$this->updateUnassignedFields($tabElement);
126+
$tab->fillFormTab($this->unassignedFields, $this->_rootElement);
127+
$this->updateUnassignedFields($tab);
127128
if (empty($this->unassignedFields)) {
128129
break;
129130
}
@@ -154,15 +155,15 @@ public function getData(FixtureInterface $fixture = null, SimpleElement $element
154155
if (null === $fixture) {
155156
foreach ($this->tabs as $tabName => $tab) {
156157
$this->openTab($tabName);
157-
$tabData = $this->getTabElement($tabName)->getDataFormTab();
158+
$tabData = $this->getTab($tabName)->getDataFormTab();
158159
$data = array_merge($data, $tabData);
159160
}
160161
} else {
161162
$isHasData = ($fixture instanceof InjectableFixture) ? $fixture->hasData() : true;
162163
$tabsFields = $isHasData ? $this->getFieldsByTabs($fixture) : [];
163164
foreach ($tabsFields as $tabName => $fields) {
164165
$this->openTab($tabName);
165-
$tabData = $this->getTabElement($tabName)->getDataFormTab($fields, $this->_rootElement);
166+
$tabData = $this->getTab($tabName)->getDataFormTab($fields, $this->_rootElement);
166167
$data = array_merge($data, $tabData);
167168
}
168169
}
@@ -249,41 +250,61 @@ private function getFixtureFieldsByTabsDeprecated(FixtureInterface $fixture)
249250
}
250251

251252
/**
252-
* Get tab element
253+
* Get tab class.
253254
*
254255
* @param string $tabName
255256
* @return Tab
256257
* @throws \Exception
257258
*/
258-
public function getTabElement($tabName)
259+
public function getTab($tabName)
259260
{
260261
$tabClass = $this->tabs[$tabName]['class'];
261-
/** @var Tab $tabElement */
262-
$tabElement = $this->blockFactory->create($tabClass, ['element' => $this->_rootElement]);
263-
if (!$tabElement instanceof Tab) {
262+
/** @var Tab $tab */
263+
$tab = $this->blockFactory->create($tabClass, ['element' => $this->_rootElement]);
264+
if (!$tab instanceof Tab) {
264265
throw new \Exception('Wrong Tab Class.');
265266
}
266-
$tabElement->setWrapper(isset($this->tabs[$tabName]['wrapper']) ? $this->tabs[$tabName]['wrapper'] : '');
267-
$tabElement->setMapping(isset($this->tabs[$tabName]['fields']) ? (array)$this->tabs[$tabName]['fields'] : []);
267+
$tab->setWrapper(isset($this->tabs[$tabName]['wrapper']) ? $this->tabs[$tabName]['wrapper'] : '');
268+
$tab->setMapping(isset($this->tabs[$tabName]['fields']) ? (array)$this->tabs[$tabName]['fields'] : []);
268269

269-
return $tabElement;
270+
return $tab;
270271
}
271272

272273
/**
273-
* Open tab
274+
* Get tab element.
274275
*
275276
* @param string $tabName
276-
* @return FormTabs
277+
* @return ElementInterface
277278
*/
278-
public function openTab($tabName)
279+
protected function getTabElement($tabName)
279280
{
280281
$selector = $this->tabs[$tabName]['selector'];
281282
$strategy = isset($this->tabs[$tabName]['strategy'])
282283
? $this->tabs[$tabName]['strategy']
283284
: Locator::SELECTOR_CSS;
284-
$tab = $this->_rootElement->find($selector, $strategy);
285-
$tab->click();
285+
return $this->_rootElement->find($selector, $strategy);
286+
}
286287

288+
/**
289+
* Open tab.
290+
*
291+
* @param string $tabName
292+
* @return FormTabs
293+
*/
294+
public function openTab($tabName)
295+
{
296+
$this->getTabElement($tabName)->click();
287297
return $this;
288298
}
299+
300+
/**
301+
* Check whether tab is visible.
302+
*
303+
* @param string $tabName
304+
* @return bool
305+
*/
306+
public function isTabVisible($tabName)
307+
{
308+
return $this->getTabElement($tabName)->isVisible();
309+
}
289310
}

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ protected function getTemplateBlock()
206206
* @param array $filters
207207
* @throws \Exception
208208
*/
209-
private function prepareForSearch(array $filters)
209+
protected function prepareForSearch(array $filters)
210210
{
211211
foreach ($filters as $key => $value) {
212212
if (isset($this->filters[$key])) {

0 commit comments

Comments
 (0)