Skip to content

Commit 8dc8631

Browse files
committed
Merge remote-tracking branch 'origin/develop' into MAGETWO-60598
2 parents e70046e + 519a65d commit 8dc8631

File tree

49 files changed

+1003
-298
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

+1003
-298
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ atlassian*
6666
!/vendor/.htaccess
6767
/generated/*
6868
!/generated/.htaccess
69+
.DS_Store

.travis.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,22 @@ env:
2222
- MAGENTO_HOST_NAME="magento2.travis"
2323
matrix:
2424
- TEST_SUITE=unit
25+
- TEST_SUITE=static
26+
- TEST_SUITE=js GRUNT_COMMAND=spec
27+
- TEST_SUITE=js GRUNT_COMMAND=static
2528
- TEST_SUITE=integration INTEGRATION_INDEX=1
2629
- TEST_SUITE=integration INTEGRATION_INDEX=2
2730
- TEST_SUITE=integration INTEGRATION_INDEX=3
28-
- TEST_SUITE=static
29-
- TEST_SUITE=js
3031
- TEST_SUITE=functional ACCEPTANCE_INDEX=1
3132
- TEST_SUITE=functional ACCEPTANCE_INDEX=2
3233
matrix:
3334
exclude:
3435
- php: 7.0
3536
env: TEST_SUITE=static
3637
- php: 7.0
37-
env: TEST_SUITE=js
38+
env: TEST_SUITE=js GRUNT_COMMAND=spec
39+
- php: 7.0
40+
env: TEST_SUITE=js GRUNT_COMMAND=static
3841
- php: 7.0
3942
env: TEST_SUITE=functional ACCEPTANCE_INDEX=1
4043
- php: 7.0
@@ -49,4 +52,11 @@ cache:
4952
before_install: ./dev/travis/before_install.sh
5053
install: composer install --no-interaction --prefer-dist
5154
before_script: ./dev/travis/before_script.sh
52-
script: ./dev/travis/script.sh
55+
script:
56+
# Set arguments for variants of phpunit based tests; '|| true' prevents failing script when leading test fails
57+
- test $TEST_SUITE = "static" && TEST_FILTER='--filter "Magento\\Test\\Php\\LiveCodeTest"' || true
58+
- test $TEST_SUITE = "functional" && TEST_FILTER='dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests.php' || true
59+
60+
# The scripts for grunt/phpunit type tests
61+
- if [ $TEST_SUITE != "js" ]; then phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi
62+
- if [ $TEST_SUITE == "js" ]; then grunt $GRUNT_COMMAND; fi

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ If you are a new GitHub user, we recommend that you create your own [free github
2929
3. Create and test your work.
3030
4. Fork the Magento 2 repository according to [Fork a repository instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow [Create a pull request instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#pull_request).
3131
5. Once your contribution is received, Magento 2 development team will review the contribution and collaborate with you as needed to improve the quality of the contribution.
32+
33+
## Code of Conduct
34+
35+
Please note that this project is released with a Contributor Code of Conduct. We expect you to agree to its terms when participating in this project.
36+
The full text is available in the repository [Wiki](https://github.com/magento/magento2/wiki/Magento-Code-of-Conduct).

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public function execute()
144144
$this->messageManager->addSuccess(__('You duplicated the product.'));
145145
}
146146
} catch (\Magento\Framework\Exception\LocalizedException $e) {
147+
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
147148
$this->messageManager->addError($e->getMessage());
148149
$this->getDataPersistor()->set('catalog_product', $data);
149150
$redirectBack = $productId ? true : 'new';

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveO
634634
} catch (LocalizedException $e) {
635635
throw $e;
636636
} catch (\Exception $e) {
637-
throw new \Magento\Framework\Exception\CouldNotSaveException(__('Unable to save product'));
637+
throw new \Magento\Framework\Exception\CouldNotSaveException(__('Unable to save product'), $e);
638638
}
639639
unset($this->instances[$product->getSku()]);
640640
unset($this->instancesById[$product->getId()]);

app/code/Magento/Catalog/Ui/DataProvider/Product/Attributes/Listing.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ public function __construct(
4141
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
4242
$this->request = $request;
4343
$this->collection = $collectionFactory->create();
44-
$this->collection->setExcludeSetFilter((int)$this->request->getParam('template_id', 0));
4544
}
4645

4746
/**
4847
* {@inheritdoc}
4948
*/
5049
public function getData()
5150
{
51+
$this->collection->setExcludeSetFilter((int)$this->request->getParam('template_id', 0));
52+
$this->collection->getSelect()->setPart('order', []);
53+
5254
$items = [];
5355
foreach ($this->getCollection()->getItems() as $attribute) {
5456
$items[] = $attribute->toArray();

app/code/Magento/Config/Console/Command/ConfigSet/LockProcessor.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Config\App\Config\Type\System;
99
use Magento\Config\Model\PreparedValueFactory;
1010
use Magento\Framework\App\Config\ConfigPathResolver;
11+
use Magento\Framework\App\Config\Value;
1112
use Magento\Framework\App\DeploymentConfig;
1213
use Magento\Framework\Config\File\ConfigFilePool;
1314
use Magento\Framework\Exception\CouldNotSaveException;
@@ -79,19 +80,27 @@ public function process($path, $value, $scope, $scopeCode)
7980
$configPath = $this->configPathResolver->resolve($path, $scope, $scopeCode, System::CONFIG_TYPE);
8081
$backendModel = $this->preparedValueFactory->create($path, $value, $scope, $scopeCode);
8182

82-
/**
83-
* Temporary solution until Magento introduce unified interface
84-
* for storing system configuration into database and configuration files.
85-
*/
86-
$backendModel->validateBeforeSave();
87-
$backendModel->beforeSave();
83+
if ($backendModel instanceof Value) {
84+
/**
85+
* Temporary solution until Magento introduce unified interface
86+
* for storing system configuration into database and configuration files.
87+
*/
88+
$backendModel->validateBeforeSave();
89+
$backendModel->beforeSave();
8890

89-
$this->deploymentConfigWriter->saveConfig(
90-
[ConfigFilePool::APP_ENV => $this->arrayManager->set($configPath, [], $backendModel->getValue())],
91-
false
92-
);
91+
$value = $backendModel->getValue();
9392

94-
$backendModel->afterSave();
93+
$backendModel->afterSave();
94+
95+
/**
96+
* Because FS does not support transactions,
97+
* we'll write value just after all validations are triggered.
98+
*/
99+
$this->deploymentConfigWriter->saveConfig(
100+
[ConfigFilePool::APP_ENV => $this->arrayManager->set($configPath, [], $value)],
101+
false
102+
);
103+
}
95104
} catch (\Exception $exception) {
96105
throw new CouldNotSaveException(__('%1', $exception->getMessage()), $exception);
97106
}

app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockProcessorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,10 @@ public function testCustomException()
206206
->willReturn($this->valueMock);
207207
$this->arrayManagerMock->expects($this->never())
208208
->method('set');
209-
$this->valueMock->expects($this->never())
209+
$this->valueMock->expects($this->once())
210210
->method('getValue');
211211
$this->valueMock->expects($this->once())
212-
->method('validateBeforeSave')
212+
->method('afterSave')
213213
->willThrowException(new \Exception('Invalid values'));
214214
$this->deploymentConfigWriterMock->expects($this->never())
215215
->method('saveConfig');

app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Magento\Framework\App\CacheInterface;
1515
use Magento\Framework\Serialize\Serializer\Json as Serializer;
16-
use Magento\Store\Api\StoreResolverInterface;
16+
use Magento\Store\Model\StoreManagerInterface;
1717
use Magento\Framework\App\ObjectManager;
1818
use Magento\Eav\Model\Cache\Type as CacheType;
1919
use Magento\Eav\Model\Entity\Attribute;
@@ -37,9 +37,9 @@ abstract class AbstractFrontend implements \Magento\Eav\Model\Entity\Attribute\F
3737
private $cache;
3838

3939
/**
40-
* @var StoreResolverInterface
40+
* @var StoreManagerInterface
4141
*/
42-
private $storeResolver;
42+
private $storeManager;
4343

4444
/**
4545
* @var Serializer
@@ -66,22 +66,25 @@ abstract class AbstractFrontend implements \Magento\Eav\Model\Entity\Attribute\F
6666
/**
6767
* @param BooleanFactory $attrBooleanFactory
6868
* @param CacheInterface $cache
69-
* @param StoreResolverInterface $storeResolver
69+
* @param $storeResolver @deprecated
7070
* @param array $cacheTags
7171
* @param Serializer $serializer
72+
* @param StoreManagerInterface $storeManager
7273
* @codeCoverageIgnore
74+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
7375
*/
7476
public function __construct(
7577
BooleanFactory $attrBooleanFactory,
7678
CacheInterface $cache = null,
77-
StoreResolverInterface $storeResolver = null,
79+
$storeResolver = null,
7880
array $cacheTags = null,
79-
Serializer $serializer = null
81+
Serializer $serializer = null,
82+
StoreManagerInterface $storeManager = null
8083
) {
8184
$this->_attrBooleanFactory = $attrBooleanFactory;
8285
$this->cache = $cache ?: ObjectManager::getInstance()->get(CacheInterface::class);
83-
$this->storeResolver = $storeResolver ?: ObjectManager::getInstance()->get(StoreResolverInterface::class);
8486
$this->cacheTags = $cacheTags ?: self::$defaultCacheTags;
87+
$this->storeManager = $storeManager ?: ObjectManager::getInstance()->get(StoreManagerInterface::class);
8588
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Serializer::class);
8689
}
8790

@@ -299,7 +302,7 @@ public function getSelectOptions()
299302
{
300303
$cacheKey = 'attribute-navigation-option-' .
301304
$this->getAttribute()->getAttributeCode() . '-' .
302-
$this->storeResolver->getCurrentStoreId();
305+
$this->storeManager->getStore()->getId();
303306
$optionString = $this->cache->load($cacheKey);
304307
if (false === $optionString) {
305308
$options = $this->getAttribute()->getSource()->getAllOptions();

app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
use Magento\Eav\Model\Entity\Attribute\Frontend\DefaultFrontend;
99
use Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory;
1010
use Magento\Framework\Serialize\Serializer\Json as Serializer;
11-
use Magento\Store\Api\StoreResolverInterface;
11+
use Magento\Store\Model\StoreManagerInterface;
12+
use Magento\Store\Api\Data\StoreInterface;
1213
use Magento\Framework\App\CacheInterface;
1314
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
1415
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
@@ -31,9 +32,14 @@ class DefaultFrontendTest extends \PHPUnit_Framework_TestCase
3132
private $serializerMock;
3233

3334
/**
34-
* @var StoreResolverInterface|\PHPUnit_Framework_MockObject_MockObject
35+
* @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
3536
*/
36-
private $storeResolverMock;
37+
private $storeManagerMock;
38+
39+
/**
40+
* @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
41+
*/
42+
private $storeMock;
3743

3844
/**
3945
* @var CacheInterface|\PHPUnit_Framework_MockObject_MockObject
@@ -64,7 +70,9 @@ protected function setUp()
6470
->getMock();
6571
$this->serializerMock = $this->getMockBuilder(Serializer::class)
6672
->getMock();
67-
$this->storeResolverMock = $this->getMockBuilder(StoreResolverInterface::class)
73+
$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
74+
->getMockForAbstractClass();
75+
$this->storeMock = $this->getMockBuilder(StoreInterface::class)
6876
->getMockForAbstractClass();
6977
$this->cacheMock = $this->getMockBuilder(CacheInterface::class)
7078
->getMockForAbstractClass();
@@ -83,7 +91,7 @@ protected function setUp()
8391
[
8492
'_attrBooleanFactory' => $this->booleanFactory,
8593
'cache' => $this->cacheMock,
86-
'storeResolver' => $this->storeResolverMock,
94+
'storeManager' => $this->storeManagerMock,
8795
'serializer' => $this->serializerMock,
8896
'_attribute' => $this->attributeMock,
8997
'cacheTags' => $this->cacheTags
@@ -188,8 +196,11 @@ public function testGetSelectOptions()
188196
$options = ['option1', 'option2'];
189197
$serializedOptions = "{['option1', 'option2']}";
190198

191-
$this->storeResolverMock->expects($this->once())
192-
->method('getCurrentStoreId')
199+
$this->storeManagerMock->expects($this->once())
200+
->method('getStore')
201+
->willReturn($this->storeMock);
202+
$this->storeMock->expects($this->once())
203+
->method('getId')
193204
->willReturn($storeId);
194205
$this->attributeMock->expects($this->once())
195206
->method('getAttributeCode')

0 commit comments

Comments
 (0)