diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml
index 7307bbe09f1b4..8b52d08da48fb 100644
--- a/app/code/Magento/Backend/etc/di.xml
+++ b/app/code/Magento/Backend/etc/di.xml
@@ -71,7 +71,6 @@
Magento\Backend\Helper\Data\Proxy
-
diff --git a/app/code/Magento/Catalog/Plugin/Block/Topmenu.php b/app/code/Magento/Catalog/Plugin/Block/Topmenu.php
index 098b3282a1b10..72bf4468080e3 100644
--- a/app/code/Magento/Catalog/Plugin/Block/Topmenu.php
+++ b/app/code/Magento/Catalog/Plugin/Block/Topmenu.php
@@ -79,11 +79,18 @@ public function beforeGetHtml(
$currentCategory = $this->getCurrentCategory();
$mapping = [$rootId => $subject->getMenu()]; // use nodes stack to avoid recursion
foreach ($collection as $category) {
- if (!isset($mapping[$category->getParentId()])) {
- continue;
+ $categoryParentId = $category->getParentId();
+ if (!isset($mapping[$categoryParentId])) {
+ $parentIds = $category->getParentIds();
+ foreach ($parentIds as $parentId) {
+ if (isset($mapping[$parentId])) {
+ $categoryParentId = $parentId;
+ }
+ }
}
+
/** @var Node $parentCategoryNode */
- $parentCategoryNode = $mapping[$category->getParentId()];
+ $parentCategoryNode = $mapping[$categoryParentId];
$categoryNode = new Node(
$this->getCategoryAsArray($category, $currentCategory),
diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php
index 93e9a6f49e9a0..1f805016b7f51 100644
--- a/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php
@@ -4,12 +4,15 @@
* See COPYING.txt for license details.
*/
-// @codingStandardsIgnoreFile
-
namespace Magento\Catalog\Test\Unit\Plugin\Block;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+/**
+ * Class TopmenuTest
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class TopmenuTest extends \PHPUnit_Framework_TestCase
{
/**
@@ -18,96 +21,109 @@ class TopmenuTest extends \PHPUnit_Framework_TestCase
protected $block;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Helper\Category
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\StoreManagerInterface
*/
- protected $_catalogCategory;
+ protected $storeManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\Store
*/
- protected $_childrenCategory;
+ protected $storeMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver
+ */
+ protected $layerResolverMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer
+ */
+ protected $catalogLayerMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory
*/
- protected $_category;
+ protected $categoryCollectionFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Category\Collection
*/
- protected $menuCategoryData;
+ protected $categoryCollectionMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Indexer\Category\Flat\State
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Helper\Category
+ */
+ protected $categoryHelperMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
+ */
+ protected $childrenCategoryMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
*/
- protected $_categoryFlatState;
+ protected $categoryMock;
+ /**
+ * Set up
+ *
+ * @return void
+ */
protected function setUp()
{
- $this->_catalogCategory = $this->getMock(
- \Magento\Catalog\Helper\Category::class,
- ['getStoreCategories', 'getCategoryUrl'],
- [],
- '',
- false
+ $rootCategoryId = 2;
+ $categoryParentId = 3;
+ $categoryParentIds = [1, 2, 3];
+
+ $this->childrenCategoryMock = $this->_getCleanMock(\Magento\Catalog\Model\Category::class);
+ $this->categoryHelperMock = $this->_getCleanMock(\Magento\Catalog\Helper\Category::class);
+ $this->catalogLayerMock = $this->_getCleanMock(\Magento\Catalog\Model\Layer::class);
+ $this->categoryMock = $this->_getCleanMock(\Magento\Catalog\Model\Category::class);
+ $this->layerResolverMock = $this->_getCleanMock(\Magento\Catalog\Model\Layer\Resolver::class);
+ $this->storeMock = $this->_getCleanMock(\Magento\Store\Model\Store::class);
+ $this->storeManagerMock = $this->_getCleanMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->categoryCollectionMock = $this->_getCleanMock(
+ \Magento\Catalog\Model\ResourceModel\Category\Collection::class
);
-
- $this->menuCategoryData = $this->getMock(
- \Magento\Catalog\Observer\MenuCategoryData::class,
- ['getMenuCategoryData'],
+ $this->categoryCollectionFactoryMock = $this->getMock(
+ \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class,
+ ['create'],
[],
'',
false
);
- $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
- ->setMethods(['getRootCategoryId', 'getFilters', '__wakeup'])
- ->disableOriginalConstructor()
- ->getMockForAbstractClass();
-
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
- ->setMethods(['getStore'])
- ->disableOriginalConstructor()
- ->getMockForAbstractClass();
- $this->storeManager->expects($this->any())->method('getStore')
- ->will($this->returnValue($this->store));
-
- $this->store->expects($this->any())->method('getRootCategoryId')
- ->will($this->returnValue(1));
-
- $collectionFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class)
- ->setMethods(['create'])
- ->disableOriginalConstructor()
- ->getMock();
-
- $collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\Collection::class)
- ->setMethods(
- [
- 'addIsActiveFilter',
- 'addAttributeToSelect',
- 'addFieldToFilter',
- 'addAttributeToFilter',
- 'addUrlRewriteToResult',
- 'getIterator',
- 'setStoreId'
- ]
- )->disableOriginalConstructor()
- ->getMock();
- $collection->expects($this->once())->method('addIsActiveFilter');
- $collectionFactory->expects($this->once())->method('create')
- ->willReturn($collection);
-
- $collection->expects($this->once())->method('getIterator')
- ->willReturn(new \ArrayIterator([]));
+ $this->catalogLayerMock->expects($this->once())->method('getCurrentCategory')
+ ->will($this->returnValue($this->childrenCategoryMock));
+
+ $this->storeManagerMock->expects($this->atLeastOnce())->method('getStore')
+ ->will($this->returnValue($this->storeMock));
+
+ $this->categoryMock->expects($this->atLeastOnce())->method('getParentId')
+ ->will($this->returnValue($categoryParentId));
+ $this->categoryMock->expects($this->once())->method('getParentIds')
+ ->will($this->returnValue($categoryParentIds));
+
+ $this->layerResolverMock->expects($this->once())->method('get')
+ ->will($this->returnValue($this->catalogLayerMock));
+
+ $this->storeMock->expects($this->once())->method('getRootCategoryId')
+ ->will($this->returnValue($rootCategoryId));
+
+ $this->categoryCollectionMock->expects($this->once())->method('getIterator')
+ ->willReturn(new \ArrayIterator([$this->categoryMock]));
+
+ $this->categoryCollectionFactoryMock->expects($this->once())->method('create')
+ ->willReturn($this->categoryCollectionMock);
$this->block = (new ObjectManager($this))->getObject(
\Magento\Catalog\Plugin\Block\Topmenu::class,
[
- 'catalogCategory' => $this->_catalogCategory,
- 'menuCategoryData' => $this->menuCategoryData,
- 'storeManager' => $this->storeManager,
- 'categoryCollectionFactory' => $collectionFactory,
+ 'catalogCategory' => $this->categoryHelperMock,
+ 'categoryCollectionFactory' => $this->categoryCollectionFactoryMock,
+ 'storeManager' => $this->storeManagerMock,
+ 'layerResolver' => $this->layerResolverMock,
]
);
}
@@ -123,31 +139,21 @@ protected function _getCleanMock($className)
return $this->getMock($className, [], [], '', false);
}
- protected function _preparationData()
+ /**
+ * Test beforeGetHtml
+ *
+ */
+ public function testBeforeGetHtml()
{
- $this->_childrenCategory = $this->getMock(
- \Magento\Catalog\Model\Category::class,
- ['getIsActive', '__wakeup'],
- [],
- '',
- false
- );
-
+ $treeMock = $this->getMock(\Magento\Framework\Data\Tree::class);
- $this->_category = $this->getMock(
- \Magento\Catalog\Model\Category::class,
- ['getIsActive', '__wakeup', 'getName', 'getChildren', 'getUseFlatResource', 'getChildrenNodes'],
- [],
- '',
- false
- );
+ $parentCategoryNodeMock = $this->_getCleanMock(\Magento\Framework\Data\Tree\Node::class);
+ $parentCategoryNodeMock->expects($this->once())->method('getTree')->will($this->returnValue($treeMock));
+ $parentCategoryNodeMock->expects($this->once())->method('addChild');
$blockMock = $this->_getCleanMock(\Magento\Theme\Block\Html\Topmenu::class);
- return $blockMock;
- }
+ $blockMock->expects($this->once())->method('getMenu')->will($this->returnValue($parentCategoryNodeMock));
- public function testAddCatalogToTopMenuItems()
- {
- $this->block->beforeGetHtml($this->_preparationData());
+ $this->block->beforeGetHtml($blockMock);
}
}
diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php
index 441fb60f55ec4..73551f332d140 100644
--- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php
+++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php
@@ -254,6 +254,16 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
'tax_class_id' => 'tax_class_name',
];
+ /**
+ * Attributes codes which shows as date
+ *
+ * @var array
+ */
+ protected $dateAttrCodes = [
+ 'special_from_date',
+ 'special_to_date'
+ ];
+
/**
* Attributes codes which are appropriate for export and not the part of additional_attributes.
*
@@ -338,6 +348,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
* @param Product\Type\Factory $_typeFactory
* @param \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider
* @param \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface $rowCustomizer
+ * @param array $dateAttrCodes
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -356,7 +367,8 @@ public function __construct(
\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeColFactory,
\Magento\CatalogImportExport\Model\Export\Product\Type\Factory $_typeFactory,
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider,
- \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface $rowCustomizer
+ \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface $rowCustomizer,
+ array $dateAttrCodes = []
) {
$this->_entityCollectionFactory = $collectionFactory;
$this->_exportConfig = $exportConfig;
@@ -371,6 +383,7 @@ public function __construct(
$this->_typeFactory = $_typeFactory;
$this->_linkTypeProvider = $linkTypeProvider;
$this->rowCustomizer = $rowCustomizer;
+ $this->dateAttrCodes = array_merge($this->dateAttrCodes, $dateAttrCodes);
parent::__construct($localeDate, $config, $resource, $storeManager);
@@ -897,7 +910,15 @@ protected function collectRawData()
}
$fieldName = isset($this->_fieldsMap[$code]) ? $this->_fieldsMap[$code] : $code;
- if ($this->_attributeTypes[$code] === 'datetime') {
+ if (in_array($code, $this->dateAttrCodes)) {
+ $attrValue = $this->_localeDate->formatDateTime(
+ new \DateTime($attrValue),
+ \IntlDateFormatter::SHORT,
+ \IntlDateFormatter::NONE,
+ null,
+ date_default_timezone_get()
+ );
+ } else if ($this->_attributeTypes[$code] === 'datetime') {
$attrValue = $this->_localeDate->formatDateTime(
new \DateTime($attrValue),
\IntlDateFormatter::SHORT,
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php
index 0f89aa17d6029..21c12bf0a8b1a 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php
@@ -210,6 +210,16 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
'_upsell_' => \Magento\Catalog\Model\Product\Link::LINK_TYPE_UPSELL,
];
+ /**
+ * Attributes codes which shows as date
+ *
+ * @var array
+ */
+ protected $dateAttrCodes = [
+ 'special_from_date',
+ 'special_to_date'
+ ];
+
/**
* Need to log in import history
*
@@ -664,6 +674,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
* @param Product\TaxClassProcessor $taxClassProcessor
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param array $data
+ * @param array $dateAttrCodes
* @throws \Magento\Framework\Exception\LocalizedException
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -705,7 +716,8 @@ public function __construct(
Product\TaxClassProcessor $taxClassProcessor,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Catalog\Model\Product\Url $productUrl,
- array $data = []
+ array $data = [],
+ array $dateAttrCodes = []
) {
$this->_eventManager = $eventManager;
$this->stockRegistry = $stockRegistry;
@@ -734,6 +746,7 @@ public function __construct(
$this->taxClassProcessor = $taxClassProcessor;
$this->scopeConfig = $scopeConfig;
$this->productUrl = $productUrl;
+ $this->dateAttrCodes = array_merge($this->dateAttrCodes, $dateAttrCodes);
parent::__construct(
$jsonHelper,
$importExportData,
@@ -1642,7 +1655,12 @@ protected function _saveProducts()
$attrTable = $attribute->getBackend()->getTable();
$storeIds = [0];
- if ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) {
+ if (
+ 'datetime' == $attribute->getBackendType()
+ && in_array($attribute->getAttributeCode(), $this->dateAttrCodes)
+ ) {
+ $attrValue = $this->dateTime->formatDate($attrValue, false);
+ } else if ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) {
$attrValue = $this->dateTime->gmDate(
'Y-m-d H:i:s',
$this->_localeDate->date($attrValue)->getTimestamp()
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php
index e0ea12740b964..c61cb03aefa41 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php
@@ -343,9 +343,9 @@ protected function setUp()
$this->attributeColFactory,
$this->typeFactory,
$this->linkTypeProvider,
- $this->rowCustomizer,
- $this->metadataPool
+ $this->rowCustomizer
);
+ $this->setPropertyValue($this->product, 'metadataPool', $this->metadataPool);
$this->object = new StubProduct();
}
diff --git a/app/code/Magento/Cms/Setup/UpgradeData.php b/app/code/Magento/Cms/Setup/UpgradeData.php
index 9a7dce65b121f..41a28989439af 100644
--- a/app/code/Magento/Cms/Setup/UpgradeData.php
+++ b/app/code/Magento/Cms/Setup/UpgradeData.php
@@ -235,8 +235,11 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
EOD;
$privacyAndCookiePolicyPage = $this->createPage()->load(self::PRIVACY_COOKIE_PAGE_ID);
- $privacyAndCookiePolicyPage->setContent($newPageContent);
- $privacyAndCookiePolicyPage->save();
+ $privacyAndCookiePolicyPageId = $privacyAndCookiePolicyPage->getId();
+ if ($privacyAndCookiePolicyPageId) {
+ $privacyAndCookiePolicyPage->setContent($newPageContent);
+ $privacyAndCookiePolicyPage->save();
+ }
}
$setup->endSetup();
}
diff --git a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml
index a57c68d17258f..47ea803530f14 100644
--- a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml
+++ b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml
@@ -21,7 +21,7 @@
|
|
|
- |
+ |
diff --git a/app/code/Magento/SampleData/Console/Command/SampleDataDeployCommand.php b/app/code/Magento/SampleData/Console/Command/SampleDataDeployCommand.php
index 668c22073f00a..7697c24df79e3 100644
--- a/app/code/Magento/SampleData/Console/Command/SampleDataDeployCommand.php
+++ b/app/code/Magento/SampleData/Console/Command/SampleDataDeployCommand.php
@@ -9,14 +9,11 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-use Magento\SampleData\Model\Dependency;
use Magento\Framework\App\State;
use Symfony\Component\Console\Input\ArrayInput;
-use Symfony\Component\Console\Input\ArrayInputFactory;
use Magento\Framework\App\Filesystem\DirectoryList;
-use Magento\Framework\Filesystem;
use Composer\Console\Application;
-use Composer\Console\ApplicationFactory;
+use Magento\Setup\Model\PackagesAuth;
/**
* Command for deployment of Sample Data
@@ -24,37 +21,37 @@
class SampleDataDeployCommand extends Command
{
/**
- * @var Filesystem
+ * @var \Magento\Framework\Filesystem
*/
private $filesystem;
/**
- * @var Dependency
+ * @var \Magento\SampleData\Model\Dependency
*/
private $sampleDataDependency;
/**
- * @var ArrayInputFactory
+ * @var \Symfony\Component\Console\Input\ArrayInputFactory
* @deprecated
*/
private $arrayInputFactory;
/**
- * @var ApplicationFactory
+ * @var \Composer\Console\ApplicationFactory
*/
private $applicationFactory;
/**
- * @param Filesystem $filesystem
- * @param Dependency $sampleDataDependency
- * @param ArrayInputFactory $arrayInputFactory
- * @param ApplicationFactory $applicationFactory
+ * @param \Magento\Framework\Filesystem $filesystem
+ * @param \Magento\SampleData\Model\Dependency $sampleDataDependency
+ * @param \Symfony\Component\Console\Input\ArrayInputFactory $arrayInputFactory
+ * @param \Composer\Console\ApplicationFactory $applicationFactory
*/
public function __construct(
- Filesystem $filesystem,
- Dependency $sampleDataDependency,
- ArrayInputFactory $arrayInputFactory,
- ApplicationFactory $applicationFactory
+ \Magento\Framework\Filesystem $filesystem,
+ \Magento\SampleData\Model\Dependency $sampleDataDependency,
+ \Symfony\Component\Console\Input\ArrayInputFactory $arrayInputFactory,
+ \Composer\Console\ApplicationFactory $applicationFactory
) {
$this->filesystem = $filesystem;
$this->sampleDataDependency = $sampleDataDependency;
@@ -79,6 +76,7 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->updateMemoryLimit();
+ $this->createAuthFile();
$sampleDataPackages = $this->sampleDataDependency->getSampleDataPackages();
if (!empty($sampleDataPackages)) {
$baseDir = $this->filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath();
@@ -107,6 +105,30 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
+ /**
+ * Create new auth.json file if it doesn't exist.
+ *
+ * We create auth.json with correct permissions instead of relying on Composer.
+ *
+ * @return void
+ * @throws \Exception
+ */
+ private function createAuthFile()
+ {
+ $directory = $this->filesystem->getDirectoryWrite(DirectoryList::COMPOSER_HOME);
+
+ if (!$directory->isExist(PackagesAuth::PATH_TO_AUTH_FILE)) {
+ try {
+ $directory->writeFile(PackagesAuth::PATH_TO_AUTH_FILE, '{}');
+ } catch (\Exception $e) {
+ $message = 'Error in writing Auth file '
+ . $directory->getAbsolutePath(PackagesAuth::PATH_TO_AUTH_FILE)
+ . '. Please check permissions for writing.';
+ throw new \Exception($message);
+ }
+ }
+ }
+
/**
* @return void
*/
diff --git a/app/code/Magento/SampleData/Test/Unit/Console/Command/SampleDataDeployCommandTest.php b/app/code/Magento/SampleData/Test/Unit/Console/Command/SampleDataDeployCommandTest.php
index ba946b2eae388..4f337c61c729f 100644
--- a/app/code/Magento/SampleData/Test/Unit/Console/Command/SampleDataDeployCommandTest.php
+++ b/app/code/Magento/SampleData/Test/Unit/Console/Command/SampleDataDeployCommandTest.php
@@ -7,42 +7,106 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\SampleData\Console\Command\SampleDataDeployCommand;
+use Magento\Setup\Model\PackagesAuth;
use Symfony\Component\Console\Tester\CommandTester;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Filesystem\Directory\ReadInterface;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
+use Magento\SampleData\Model\Dependency;
+use Symfony\Component\Console\Input\ArrayInputFactory;
+use Composer\Console\ApplicationFactory;
+use Composer\Console\Application;
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class SampleDataDeployCommandTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @var ReadInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $directoryReadMock;
+
+ /**
+ * @var WriteInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $directoryWriteMock;
+
+ /**
+ * @var Filesystem|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $filesystemMock;
+
+ /**
+ * @var Dependency|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $sampleDataDependencyMock;
+
+ /**
+ * @var ArrayInputFactory|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $arrayInputFactoryMock;
+
+ /**
+ * @var Application|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $applicationMock;
+
+ /**
+ * @var ApplicationFactory|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $applicationFactoryMock;
+
+ /**
+ * @return void
+ */
+ protected function setUp()
+ {
+ $this->directoryReadMock = $this->getMock(ReadInterface::class, [], [], '', false);
+ $this->directoryWriteMock = $this->getMock(WriteInterface::class, [], [], '', false);
+ $this->filesystemMock = $this->getMock(Filesystem::class, [], [], '', false);
+ $this->sampleDataDependencyMock = $this->getMock(Dependency::class, [], [], '', false);
+ $this->arrayInputFactoryMock = $this->getMock(ArrayInputFactory::class, [], [], '', false);
+ $this->applicationMock = $this->getMock(Application::class, [], [], '', false);
+ $this->applicationFactoryMock = $this->getMock(ApplicationFactory::class, ['create'], [], '', false);
+ }
+
/**
* @param array $sampleDataPackages
* @param int $appRunResult - int 0 if everything went fine, or an error code
* @param string $expectedMsg
+ * @param bool $authExist
* @return void
*
* @dataProvider processDataProvider
*/
- public function testExecute(array $sampleDataPackages, $appRunResult, $expectedMsg)
+ public function testExecute(array $sampleDataPackages, $appRunResult, $expectedMsg, $authExist)
{
- $directoryRead = $this->getMock(
- \Magento\Framework\Filesystem\Directory\ReadInterface::class,
- [],
- [],
- '',
- false
- );
- $directoryRead->expects($this->any())->method('getAbsolutePath')->willReturn('/path/to/composer.json');
-
- $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false);
- $filesystem->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::ROOT)
- ->willReturn($directoryRead);
+ $pathToComposerJson = '/path/to/composer.json';
- $sampleDataDependency = $this->getMock(\Magento\SampleData\Model\Dependency::class, [], [], '', false);
- $sampleDataDependency
- ->expects($this->any())
+ $this->directoryReadMock->expects($this->any())
+ ->method('getAbsolutePath')
+ ->willReturn($pathToComposerJson);
+ $this->directoryWriteMock->expects($this->once())
+ ->method('isExist')
+ ->with(PackagesAuth::PATH_TO_AUTH_FILE)
+ ->willReturn($authExist);
+ $this->directoryWriteMock->expects($authExist ? $this->never() : $this->once())
+ ->method('writeFile')
+ ->with(PackagesAuth::PATH_TO_AUTH_FILE, '{}');
+ $this->filesystemMock->expects($this->any())
+ ->method('getDirectoryRead')
+ ->with(DirectoryList::ROOT)
+ ->willReturn($this->directoryReadMock);
+ $this->filesystemMock->expects($this->once())
+ ->method('getDirectoryWrite')
+ ->with(DirectoryList::COMPOSER_HOME)
+ ->willReturn($this->directoryWriteMock);
+ $this->sampleDataDependencyMock->expects($this->any())
->method('getSampleDataPackages')
->willReturn($sampleDataPackages);
-
- $arrayInputFactory = $this
- ->getMock(\Symfony\Component\Console\Input\ArrayInputFactory::class, ['create'], [], '', false);
- $arrayInputFactory->expects($this->never())->method('create');
+ $this->arrayInputFactoryMock->expects($this->never())
+ ->method('create');
array_walk($sampleDataPackages, function (&$v, $k) {
$v = "$k:$v";
@@ -52,24 +116,32 @@ public function testExecute(array $sampleDataPackages, $appRunResult, $expectedM
$requireArgs = [
'command' => 'require',
- '--working-dir' => '/path/to/composer.json',
+ '--working-dir' => $pathToComposerJson,
'--no-progress' => 1,
'packages' => $packages,
];
$commandInput = new \Symfony\Component\Console\Input\ArrayInput($requireArgs);
- $application = $this->getMock(\Composer\Console\Application::class, [], [], '', false);
- $application->expects($this->any())->method('run')
+ $this->applicationMock->expects($this->any())
+ ->method('run')
->with($commandInput, $this->anything())
->willReturn($appRunResult);
+
if (($appRunResult !== 0) && !empty($sampleDataPackages)) {
- $application->expects($this->once())->method('resetComposer')->willReturnSelf();
+ $this->applicationMock->expects($this->once())->method('resetComposer')->willReturnSelf();
}
- $applicationFactory = $this->getMock(\Composer\Console\ApplicationFactory::class, ['create'], [], '', false);
- $applicationFactory->expects($this->any())->method('create')->willReturn($application);
+
+ $this->applicationFactoryMock->expects($this->any())
+ ->method('create')
+ ->willReturn($this->applicationMock);
$commandTester = new CommandTester(
- new SampleDataDeployCommand($filesystem, $sampleDataDependency, $arrayInputFactory, $applicationFactory)
+ new SampleDataDeployCommand(
+ $this->filesystemMock,
+ $this->sampleDataDependencyMock,
+ $this->arrayInputFactoryMock,
+ $this->applicationFactoryMock
+ )
);
$commandTester->execute([]);
@@ -86,6 +158,7 @@ public function processDataProvider()
'sampleDataPackages' => [],
'appRunResult' => 1,
'expectedMsg' => 'There is no sample data for current set of modules.' . PHP_EOL,
+ 'authExist' => true,
],
[
'sampleDataPackages' => [
@@ -94,6 +167,7 @@ public function processDataProvider()
'appRunResult' => 1,
'expectedMsg' => 'There is an error during sample data deployment. Composer file will be reverted.'
. PHP_EOL,
+ 'authExist' => false,
],
[
'sampleDataPackages' => [
@@ -101,7 +175,43 @@ public function processDataProvider()
],
'appRunResult' => 0,
'expectedMsg' => '',
+ 'authExist' => true,
],
];
}
+
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Error in writing Auth file path/to/auth.json. Please check permissions for writing.
+ * @return void
+ */
+ public function testExecuteWithException()
+ {
+ $this->directoryWriteMock->expects($this->once())
+ ->method('isExist')
+ ->with(PackagesAuth::PATH_TO_AUTH_FILE)
+ ->willReturn(false);
+ $this->directoryWriteMock->expects($this->once())
+ ->method('writeFile')
+ ->with(PackagesAuth::PATH_TO_AUTH_FILE, '{}')
+ ->willThrowException(new \Exception('Something went wrong...'));
+ $this->directoryWriteMock->expects($this->once())
+ ->method('getAbsolutePath')
+ ->with(PackagesAuth::PATH_TO_AUTH_FILE)
+ ->willReturn('path/to/auth.json');
+ $this->filesystemMock->expects($this->once())
+ ->method('getDirectoryWrite')
+ ->with(DirectoryList::COMPOSER_HOME)
+ ->willReturn($this->directoryWriteMock);
+
+ $commandTester = new CommandTester(
+ new SampleDataDeployCommand(
+ $this->filesystemMock,
+ $this->sampleDataDependencyMock,
+ $this->arrayInputFactoryMock,
+ $this->applicationFactoryMock
+ )
+ );
+ $commandTester->execute([]);
+ }
}
diff --git a/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js b/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js
index ad4d680771c07..e598b5f567a84 100644
--- a/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js
+++ b/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js
@@ -213,7 +213,7 @@ define([
modal.closeModal();
}
},
- showSpecificStep: function () {
+ showSpecificStep: function (data, event) {
var index = _.indexOf(this.stepsNames, event.target.hash.substr(1)),
stepName = this.wizard.move(index);
diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html b/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html
index c14044de44eb2..113806471bc9b 100644
--- a/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html
+++ b/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html
@@ -16,7 +16,9 @@
disable="isDisabled($col())"
ko-checked="$col().visible"
attr="id: ++ko.uid"/>
-
+