diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index b1f9dbf8c327a46176208cec90f8130065d8400a..9e855e05c7ce388dd52c11829882d5b46f634d02 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -65,7 +65,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements */ const TREE_ROOT_ID = 1; - const CACHE_TAG = 'catalog_category'; + const CACHE_TAG = 'cat_c'; /**#@+ * Constants diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 49df6fd57c323bc1f12f65c590ff39ff4e041123..9e9f18e0113717ad6853ea5d4512661a897e926c 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -58,12 +58,12 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements /** * Product cache tag */ - const CACHE_TAG = 'catalog_product'; + const CACHE_TAG = 'cat_p'; /** * Category product relation cache tag */ - const CACHE_PRODUCT_CATEGORY_TAG = 'catalog_category_product'; + const CACHE_PRODUCT_CATEGORY_TAG = 'cat_c_p'; /** * Product Store Id diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php index d974174ef7088e4a14a9e031e7e266d827ceb13d..70c20a4e314903ce9defb0e40f50c912a83d7307 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php @@ -5,6 +5,7 @@ */ namespace Magento\Catalog\Model\Product\Option\Type; +use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem; use Magento\Framework\Exception\LocalizedException; use Magento\Catalog\Model\Product\Exception as ProductException; @@ -69,17 +70,23 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType */ protected $validatorFile; + /** + * @var Filesystem + */ + private $filesystem; + /** * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\Item\OptionFactory $itemOptionFactory - * @param \Magento\Catalog\Model\Product\Option\UrlBuilder $urlBuilder - * @param \Magento\Framework\Escaper $escaper * @param \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase * @param File\ValidatorInfo $validatorInfo * @param File\ValidatorFile $validatorFile + * @param \Magento\Catalog\Model\Product\Option\UrlBuilder $urlBuilder + * @param \Magento\Framework\Escaper $escaper * @param array $data - * @throws \Magento\Framework\Exception\FileSystemException + * @param Filesystem $filesystem + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Checkout\Model\Session $checkoutSession, @@ -90,12 +97,15 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType \Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile $validatorFile, \Magento\Catalog\Model\Product\Option\UrlBuilder $urlBuilder, \Magento\Framework\Escaper $escaper, - array $data = [] + array $data = [], + Filesystem $filesystem = null ) { $this->_itemOptionFactory = $itemOptionFactory; $this->_urlBuilder = $urlBuilder; $this->_escaper = $escaper; $this->_coreFileStorageDatabase = $coreFileStorageDatabase; + $this->filesystem = $filesystem ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Filesystem::class); + $this->_rootDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); $this->validatorInfo = $validatorInfo; $this->validatorFile = $validatorFile; parent::__construct($checkoutSession, $scopeConfig, $data); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php index 38ef297e684267c17c128298147343c979c43f85..f420f140b35820e3cbcebf986ed305217523aab2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php @@ -114,8 +114,8 @@ class ListProductTest extends \PHPUnit_Framework_TestCase public function testGetIdentities() { - $productTag = 'catalog_product_1'; - $categoryTag = 'catalog_category_product_1'; + $productTag = 'cat_p_1'; + $categoryTag = 'cat_c_p_1'; $this->productMock->expects($this->once()) ->method('getIdentities') diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php index d030cf456b6b13e9e8dfa240df6252d4016decd4..f0287e05a4b7b3b94f837e9adec3e4a43667e34c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php @@ -32,7 +32,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->productTypeConfig = $this->getMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class); $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $this->view = $helper->getObject( + $this->view = $helper->getObject( \Magento\Catalog\Block\Product\View::class, ['productTypeConfig' => $this->productTypeConfig, 'registry' => $this->registryMock] ); @@ -65,7 +65,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase public function testGetIdentities() { - $productTags = ['catalog_product_1']; + $productTags = ['cat_p_1']; $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); @@ -84,6 +84,6 @@ class ViewTest extends \PHPUnit_Framework_TestCase ] ) ); - $this->assertEquals(['catalog_product_1', 'catalog_category_1'], $this->view->getIdentities()); + $this->assertEquals(['cat_p_1', 'cat_c_1'], $this->view->getIdentities()); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php index 9b41651863fdb21112d422dd7bda8ee6a97aa09b..6682b295476325f2df099faa183d5edb451cadb5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php @@ -5,6 +5,12 @@ */ namespace Magento\Catalog\Test\Unit\Model\Product\Option\Type; +use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface; +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem; +use Magento\Framework\Filesystem\Directory\ReadInterface; +use Magento\Framework\Filesystem\DriverPool; + class FileTest extends \PHPUnit_Framework_TestCase { /** @@ -13,7 +19,7 @@ class FileTest extends \PHPUnit_Framework_TestCase protected $objectManager; /** - * @var \Magento\Framework\Filesystem\Directory\ReadInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ReadInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $rootDirectory; @@ -22,14 +28,26 @@ class FileTest extends \PHPUnit_Framework_TestCase */ protected $coreFileStorageDatabase; + /** + * @var Filesystem|\PHPUnit_Framework_MockObject_MockObject + */ + private $filesystemMock; + protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->rootDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) + $this->filesystemMock = $this->getMockBuilder(Filesystem::class) ->disableOriginalConstructor() - ->setMethods(['isFile', 'isReadable', 'getAbsolutePath']) - ->getMockForAbstractClass(); + ->getMock(); + + $this->rootDirectory = $this->getMockBuilder(ReadInterface::class) + ->getMock(); + + $this->filesystemMock->expects($this->once()) + ->method('getDirectoryRead') + ->with(DirectoryList::MEDIA, DriverPool::FILE) + ->willReturn($this->rootDirectory); $this->coreFileStorageDatabase = $this->getMock( \Magento\MediaStorage\Helper\File\Storage\Database::class, @@ -48,26 +66,27 @@ class FileTest extends \PHPUnit_Framework_TestCase return $this->objectManager->getObject( \Magento\Catalog\Model\Product\Option\Type\File::class, [ - 'saleableItem' => $this->rootDirectory, - 'priceCurrency' => $this->coreFileStorageDatabase + 'filesystem' => $this->filesystemMock, + 'coreFileStorageDatabase' => $this->coreFileStorageDatabase ] ); } public function testCopyQuoteToOrder() { - $optionMock = $this->getMockBuilder( - \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class - )->disableOriginalConstructor()->setMethods(['getValue'])->getMockForAbstractClass(); + $optionMock = $this->getMockBuilder(OptionInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getValue']) + ->getMockForAbstractClass(); $quotePath = '/quote/path/path/uploaded.file'; $orderPath = '/order/path/path/uploaded.file'; $optionMock->expects($this->any()) ->method('getValue') - ->will($this->returnValue(['quote_path' => $quotePath, 'order_path' => $orderPath])); + ->will($this->returnValue(serialize(['quote_path' => $quotePath, 'order_path' => $orderPath]))); - $this->rootDirectory->expects($this->any()) + $this->rootDirectory->expects($this->once()) ->method('isFile') ->with($this->equalTo($quotePath)) ->will($this->returnValue(true)); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php index b586436b5680d942daa4f9fc6f884138f0a7eeb5..f8e162dff45f390156e63c779ce2c2818d723aa5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php @@ -708,13 +708,13 @@ class ProductTest extends \PHPUnit_Framework_TestCase return [ 'no changes' => [ - ['catalog_product_1'], + ['cat_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1]], ['id' => 1, 'name' => 'value', 'category_ids' => [1]], ], 'new product' => $this->getNewProductProviderData(), 'status and category change' => [ - [0 => 'catalog_product_1', 1 => 'catalog_category_product_1', 2 => 'catalog_category_product_2'], + [0 => 'cat_p_1', 1 => 'cat_c_p_1', 2 => 'cat_c_p_2'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 2], [ 'id' => 1, @@ -726,18 +726,18 @@ class ProductTest extends \PHPUnit_Framework_TestCase ], ], 'status change only' => [ - [0 => 'catalog_product_1', 1 => 'catalog_category_product_7'], + [0 => 'cat_p_1', 1 => 'cat_c_p_7'], ['id' => 1, 'name' => 'value', 'category_ids' => [7], 'status' => 1], ['id' => 1, 'name' => 'value', 'category_ids' => [7], 'status' => 2], ], 'status changed, category unassigned' => $this->getStatusAndCategoryChangesData(), 'no status changes' => [ - [0 => 'catalog_product_1'], + [0 => 'cat_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], ], 'no stock status changes' => [ - [0 => 'catalog_product_1'], + [0 => 'cat_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], [ 'id' => 1, @@ -749,7 +749,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase ], ], 'no stock status data 1' => [ - [0 => 'catalog_product_1'], + [0 => 'cat_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], [ 'id' => 1, @@ -760,7 +760,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase ], ], 'no stock status data 2' => [ - [0 => 'catalog_product_1'], + [0 => 'cat_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], [ 'id' => 1, @@ -780,7 +780,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase private function getStatusAndCategoryChangesData() { return [ - [0 => 'catalog_product_1', 1 => 'catalog_category_product_5'], + [0 => 'cat_p_1', 1 => 'cat_c_p_5'], ['id' => 1, 'name' => 'value', 'category_ids' => [5], 'status' => 2], [ 'id' => 1, @@ -799,7 +799,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase private function getNewProductProviderData() { return [ - ['catalog_product_1', 'catalog_category_product_1'], + ['cat_p_1', 'cat_c_p_1'], null, [ 'id' => 1, @@ -818,7 +818,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase private function getStatusStockProviderData($extensionAttributesMock) { return [ - [0 => 'catalog_product_1', 1 => 'catalog_category_product_1'], + [0 => 'cat_p_1', 1 => 'cat_c_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], [ 'id' => 1, diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index b355dd2601c3da3a62ad21c0ccf0267e0c2ef809..d191f0332f5f28d28f22e981f8ebc74f0c0c8b98 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -834,4 +834,7 @@ <argument name="collectionProcessor" xsi:type="object">Magento\Eav\Model\Api\SearchCriteria\CollectionProcessor</argument> </arguments> </type> + <type name="Magento\Quote\Model\Quote\Item\ToOrderItem"> + <plugin name="copy_quote_files_to_order" type="Magento\Catalog\Model\Plugin\QuoteItemProductOption"/> + </type> </config> diff --git a/app/code/Magento/Catalog/etc/frontend/di.xml b/app/code/Magento/Catalog/etc/frontend/di.xml index 9b99bd4a781402d662fa6e9c7a17d925c28e6460..ac8c3693e8f3056611a9152e7f259a7e547c4311 100644 --- a/app/code/Magento/Catalog/etc/frontend/di.xml +++ b/app/code/Magento/Catalog/etc/frontend/di.xml @@ -18,9 +18,6 @@ <argument name="fetchStrategy" xsi:type="object">Magento\Catalog\Model\ResourceModel\Category\Collection\FetchStrategy</argument> </arguments> </type> - <type name="Magento\Quote\Model\Quote\Item\ToOrderItem"> - <plugin name="copy_quote_files_to_order" type="Magento\Catalog\Model\Plugin\QuoteItemProductOption"/> - </type> <type name="Magento\Catalog\Model\Indexer\AbstractFlatState"> <arguments> <argument name="isAvailable" xsi:type="boolean">true</argument> diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php index 2abd8d97ebc01b07bf786173e50969688d4388f1..86b150062d3c057afe500a6d76aac3665690ba87 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php @@ -5,6 +5,7 @@ */ namespace Magento\CatalogImportExport\Model\Export; +use Magento\Framework\DB\Ddl\Table; use Magento\ImportExport\Model\Import; use \Magento\Store\Model\Store; use \Magento\CatalogImportExport\Model\Import\Product as ImportProduct; @@ -127,6 +128,13 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity */ protected $_attributeTypes = []; + /** + * Attributes defined by user + * + * @var array + */ + private $userDefinedAttributes = []; + /** * Product collection * @@ -261,7 +269,11 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity */ protected $dateAttrCodes = [ 'special_from_date', - 'special_to_date' + 'special_to_date', + 'news_from_date', + 'news_to_date', + 'custom_design_from', + 'custom_design_to' ]; /** @@ -910,20 +922,24 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity } $fieldName = isset($this->_fieldsMap[$code]) ? $this->_fieldsMap[$code] : $code; - 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, - \IntlDateFormatter::SHORT - ); + if ($this->_attributeTypes[$code] == 'datetime') { + if (in_array($code, $this->dateAttrCodes) + || in_array($code, $this->userDefinedAttributes) + ) { + $attrValue = $this->_localeDate->formatDateTime( + new \DateTime($attrValue), + \IntlDateFormatter::SHORT, + \IntlDateFormatter::NONE, + null, + date_default_timezone_get() + ); + } else { + $attrValue = $this->_localeDate->formatDateTime( + new \DateTime($attrValue), + \IntlDateFormatter::SHORT, + \IntlDateFormatter::SHORT + ); + } } if ($storeId != Store::DEFAULT_STORE_ID @@ -1380,6 +1396,9 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity $this->_attributeValues[$attribute->getAttributeCode()] = $this->getAttributeOptions($attribute); $this->_attributeTypes[$attribute->getAttributeCode()] = \Magento\ImportExport\Model\Import::getAttributeType($attribute); + if ($attribute->getIsUserDefined()) { + $this->userDefinedAttributes[] = $attribute->getAttributeCode(); + } } return $this; } diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index a0feddec6529441ee5f3530bde7db9636fc88895..16df0866135a7f07760134c7aff9a0b15bc6fb01 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -217,7 +217,11 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity */ protected $dateAttrCodes = [ 'special_from_date', - 'special_to_date' + 'special_to_date', + 'news_from_date', + 'news_to_date', + 'custom_design_from', + 'custom_design_to' ]; /** @@ -1699,7 +1703,10 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity if ( 'datetime' == $attribute->getBackendType() - && in_array($attribute->getAttributeCode(), $this->dateAttrCodes) + && ( + in_array($attribute->getAttributeCode(), $this->dateAttrCodes) + || $attribute->getIsUserDefined() + ) ) { $attrValue = $this->dateTime->formatDate($attrValue, false); } else if ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) { @@ -2533,7 +2540,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity $rowData = $this->_customFieldsMapping($rowData); $this->validateRow($rowData, $source->key()); - + $source->next(); } $this->checkUrlKeyDuplicates(); diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php index aef8141e70f340862e7c8f610cdfbf6cd4d6cf8d..dfb8073e718a7f31dd316a88efc7bf9b373dcd60 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php @@ -62,6 +62,6 @@ class ItemTest extends \PHPUnit_Framework_TestCase public function testGetIdentities() { $this->_model->setProductId(1); - $this->assertEquals(['catalog_product_1'], $this->_model->getIdentities()); + $this->assertEquals(['cat_p_1'], $this->_model->getIdentities()); } } diff --git a/app/code/Magento/Cms/Model/Block.php b/app/code/Magento/Cms/Model/Block.php index d87f0f0d18884b6c31672fc5fdae32cd47e99c22..b25d433b0fee4f96618a31111940f9d410d9f006 100644 --- a/app/code/Magento/Cms/Model/Block.php +++ b/app/code/Magento/Cms/Model/Block.php @@ -23,7 +23,7 @@ class Block extends AbstractModel implements BlockInterface, IdentityInterface /** * CMS block cache tag */ - const CACHE_TAG = 'cms_block'; + const CACHE_TAG = 'cms_b'; /**#@+ * Block's statuses @@ -36,7 +36,7 @@ class Block extends AbstractModel implements BlockInterface, IdentityInterface /** * @var string */ - protected $_cacheTag = 'cms_block'; + protected $_cacheTag = self::CACHE_TAG; /** * Prefix of model events names diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index 20c2e0547193160643feddf1ddded16208e74a57..f98b56d82db03660e8a81353332a089f6739d37d 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -39,12 +39,12 @@ class Page extends AbstractModel implements PageInterface, IdentityInterface /** * CMS page cache tag */ - const CACHE_TAG = 'cms_page'; + const CACHE_TAG = 'cms_p'; /** * @var string */ - protected $_cacheTag = 'cms_page'; + protected $_cacheTag = self::CACHE_TAG; /** * Prefix of model events names diff --git a/app/code/Magento/Email/Model/Mail/TransportInterfacePlugin.php b/app/code/Magento/Email/Model/Mail/TransportInterfacePlugin.php new file mode 100644 index 0000000000000000000000000000000000000000..02c1fee1b0745efbdee91e025f7b7c4d9b6f03b4 --- /dev/null +++ b/app/code/Magento/Email/Model/Mail/TransportInterfacePlugin.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Email\Model\Mail; + +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Exception\MailException; +use Magento\Framework\Mail\TransportInterface; +use Magento\Store\Model\ScopeInterface; + +class TransportInterfacePlugin +{ + /** + * Config path to mail sending setting that shows if email communications are disabled + */ + const XML_PATH_SYSTEM_SMTP_DISABLE = 'system/smtp/disable'; + + /** + * @var ScopeConfigInterface + */ + private $scopeConfig; + + /** + * @param ScopeConfigInterface $scopeConfig + */ + public function __construct( + ScopeConfigInterface $scopeConfig + ) { + $this->scopeConfig = $scopeConfig; + } + + /** + * Omit email sending if disabled + * + * @param TransportInterface $subject + * @param \Closure $proceed + * @return void + * @throws MailException + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundSendMessage( + TransportInterface $subject, + \Closure $proceed + ) { + if (!$this->scopeConfig->isSetFlag(self::XML_PATH_SYSTEM_SMTP_DISABLE, ScopeInterface::SCOPE_STORE)) { + $proceed(); + } + } +} diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php index c281a08ab97b6bd153b77a0803b7d2c21792cc50..c42c4088793d7c429bf246bd3090731751e4ddff 100644 --- a/app/code/Magento/Email/Model/Template.php +++ b/app/code/Magento/Email/Model/Template.php @@ -5,26 +5,11 @@ */ namespace Magento\Email\Model; -use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; /** * Template model * - * Example: - * - * // Loading of template - * \Magento\Email\Model\TemplateFactory $templateFactory - * $templateFactory->create()->load($this->_scopeConfig->getValue( - * 'path_to_email_template_id_config', - * \Magento\Store\Model\ScopeInterface::SCOPE_STORE - * )); - * $variables = array( - * 'someObject' => $this->_coreResourceEmailTemplate - * 'someString' => 'Some string value' - * ); - * $emailTemplate->send('some@domain.com', 'Name Of User', $variables); - * * @method \Magento\Email\Model\ResourceModel\Template _getResource() * @method \Magento\Email\Model\ResourceModel\Template getResource() * @method string getTemplateCode() @@ -63,6 +48,8 @@ class Template extends AbstractTemplate implements \Magento\Framework\Mail\Templ /** * Config path to mail sending setting that shows if email communications are disabled + * @deprecated + * @see \Magento\Email\Model\Mail\TransportInterfacePlugin::XML_PATH_SYSTEM_SMTP_DISABLE */ const XML_PATH_SYSTEM_SMTP_DISABLE = 'system/smtp/disable'; @@ -196,8 +183,7 @@ class Template extends AbstractTemplate implements \Magento\Framework\Mail\Templ */ public function isValidForSend() { - return !$this->scopeConfig->isSetFlag(Template::XML_PATH_SYSTEM_SMTP_DISABLE, ScopeInterface::SCOPE_STORE) - && $this->getSenderName() && $this->getSenderEmail() && $this->getTemplateSubject(); + return $this->getSenderName() && $this->getSenderEmail() && $this->getTemplateSubject(); } /** @@ -344,7 +330,8 @@ class Template extends AbstractTemplate implements \Magento\Framework\Mail\Templ if ($this->_getResource()->checkCodeUsage($this)) { throw new \Magento\Framework\Exception\MailException(__('Duplicate Of Template Name')); } - return parent::beforeSave(); + parent::beforeSave(); + return $this; } /** diff --git a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php index f2195a64220e25effc00550af98c93d21e5e0145..3ee95954c0a3af7d122d62631e77f94d54ad5dda 100644 --- a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php @@ -5,7 +5,6 @@ */ namespace Magento\Email\Test\Unit\Model; -use Magento\Email\Model\Template\Filter; use Magento\Framework\App\Area; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\TemplateTypesInterface; @@ -426,18 +425,13 @@ class TemplateTest extends \PHPUnit_Framework_TestCase } /** - * @param $isSMTPDisabled bool * @param $senderName string * @param $senderEmail string * @param $templateSubject string * @dataProvider isValidForSendDataProvider */ - public function testIsValidForSend($isSMTPDisabled, $senderName, $senderEmail, $templateSubject, $expectedValue) + public function testIsValidForSend($senderName, $senderEmail, $templateSubject, $expectedValue) { - $this->scopeConfig->expects($this->once()) - ->method('isSetFlag') - ->with('system/smtp/disable', ScopeInterface::SCOPE_STORE) - ->will($this->returnValue($isSMTPDisabled)); $model = $this->getModelMock(['getSenderName', 'getSenderEmail', 'getTemplateSubject']); $model->expects($this->any()) ->method('getSenderName') @@ -455,35 +449,24 @@ class TemplateTest extends \PHPUnit_Framework_TestCase { return [ 'should be valid' => [ - 'isSMTPDisabled' => false, 'senderName' => 'sender name', 'senderEmail' => 'email@example.com', 'templateSubject' => 'template subject', 'expectedValue' => true ], - 'no smtp so not valid' => [ - 'isSMTPDisabled' => true, - 'senderName' => 'sender name', - 'senderEmail' => 'email@example.com', - 'templateSubject' => 'template subject', - 'expectedValue' => false - ], 'no sender name so not valid' => [ - 'isSMTPDisabled' => false, 'senderName' => '', 'senderEmail' => 'email@example.com', 'templateSubject' => 'template subject', 'expectedValue' => false ], 'no sender email so not valid' => [ - 'isSMTPDisabled' => false, 'senderName' => 'sender name', 'senderEmail' => '', 'templateSubject' => 'template subject', 'expectedValue' => false ], 'no subject so not valid' => [ - 'isSMTPDisabled' => false, 'senderName' => 'sender name', 'senderEmail' => 'email@example.com', 'templateSubject' => '', diff --git a/app/code/Magento/Email/etc/di.xml b/app/code/Magento/Email/etc/di.xml index d1477d470abd1d35416e4ba40d246ecd90148c26..380e5e6248fb3f3b6a42108f91a2a4f49b08e263 100644 --- a/app/code/Magento/Email/etc/di.xml +++ b/app/code/Magento/Email/etc/di.xml @@ -59,5 +59,6 @@ </type> <type name="Magento\Framework\Mail\TransportInterface"> <plugin name="WindowsSmtpConfig" type="Magento\Email\Model\Plugin\WindowsSmtpConfig" /> + <plugin name="disableSending" type="Magento\Email\Model\Mail\TransportInterfacePlugin" /> </type> </config> diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php index 7b454921b0ddc490a139aa35402d987b6cbdeda9..09ea825c612af13a08636a6d4d302ec65cad9a4f 100644 --- a/app/code/Magento/Newsletter/Model/Template.php +++ b/app/code/Magento/Newsletter/Model/Template.php @@ -174,7 +174,8 @@ class Template extends \Magento\Email\Model\AbstractTemplate public function beforeSave() { $this->validate(); - return parent::beforeSave(); + parent::beforeSave(); + return $this; } /** @@ -238,9 +239,6 @@ class Template extends \Magento\Email\Model\AbstractTemplate */ public function isValidForSend() { - return !$this->scopeConfig->isSetFlag( - \Magento\Email\Model\Template::XML_PATH_SYSTEM_SMTP_DISABLE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) && $this->getTemplateSenderName() && $this->getTemplateSenderEmail() && $this->getTemplateSubject(); + return $this->getTemplateSenderName() && $this->getTemplateSenderEmail() && $this->getTemplateSubject(); } } diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php index e51d5e0fdb3a75f6abcf79cd6289b398ec0e9391..c8599230652425348ce1b8eea8d0679defa9df16 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php @@ -379,4 +379,55 @@ class TemplateTest extends \PHPUnit_Framework_TestCase ], ]; } + + /** + * @param $senderName string + * @param $senderEmail string + * @param $templateSubject string + * @dataProvider isValidForSendDataProvider + */ + public function testIsValidForSend($senderName, $senderEmail, $templateSubject, $expectedValue) + { + $model = $this->getModelMock(['getTemplateSenderName', 'getTemplateSenderEmail', 'getTemplateSubject']); + $model->expects($this->any()) + ->method('getTemplateSenderName') + ->will($this->returnValue($senderName)); + $model->expects($this->any()) + ->method('getTemplateSenderEmail') + ->will($this->returnValue($senderEmail)); + $model->expects($this->any()) + ->method('getTemplateSubject') + ->will($this->returnValue($templateSubject)); + $this->assertEquals($expectedValue, $model->isValidForSend()); + } + + public function isValidForSendDataProvider() + { + return [ + 'should be valid' => [ + 'senderName' => 'sender name', + 'senderEmail' => 'email@example.com', + 'templateSubject' => 'template subject', + 'expectedValue' => true + ], + 'no sender name so not valid' => [ + 'senderName' => '', + 'senderEmail' => 'email@example.com', + 'templateSubject' => 'template subject', + 'expectedValue' => false + ], + 'no sender email so not valid' => [ + 'senderName' => 'sender name', + 'senderEmail' => '', + 'templateSubject' => 'template subject', + 'expectedValue' => false + ], + 'no subject so not valid' => [ + 'senderName' => 'sender name', + 'senderEmail' => 'email@example.com', + 'templateSubject' => '', + 'expectedValue' => false + ], + ]; + } } diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Widget/Chooser.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Widget/Chooser.php new file mode 100644 index 0000000000000000000000000000000000000000..b13ace25f020bfea737f6430916d957713ffa6f9 --- /dev/null +++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Widget/Chooser.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\SalesRule\Controller\Adminhtml\Promo\Widget; + +class Chooser extends \Magento\CatalogRule\Controller\Adminhtml\Promo\Widget\Chooser +{ + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_SalesRule::quote'; +} diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Product.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Product.php index f85daffd3f9625b08520548c1d96697aad3e58cf..1670819588e6106c13226f6d19ab23edcad93bd0 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Product.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Product.php @@ -51,4 +51,26 @@ class Product extends \Magento\Rule\Model\Condition\Product\AbstractProduct return parent::validate($product); } + + /** + * Retrieve value element chooser URL + * + * @return string + */ + public function getValueElementChooserUrl() + { + $url = false; + switch ($this->getAttribute()) { + case 'sku': + case 'category_ids': + $url = 'sales_rule/promo_widget/chooser/attribute/' . $this->getAttribute(); + if ($this->getJsFormObject()) { + $url .= '/form/' . $this->getJsFormObject(); + } + break; + default: + break; + } + return $url !== false ? $this->_backendData->getUrl($url) : ''; + } } diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/ProductTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/ProductTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a28ea216eda32ed78b368cf3a7b84c53659904dd --- /dev/null +++ b/app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/ProductTest.php @@ -0,0 +1,161 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\SalesRule\Test\Unit\Model\Rule\Condition; + +use \Magento\Rule\Model\Condition\Context; +use \Magento\Backend\Helper\Data; +use \Magento\Eav\Model\Config; +use \Magento\Catalog\Model\ProductFactory; +use \Magento\Catalog\Api\ProductRepositoryInterface; +use \Magento\Eav\Model\Entity\AbstractEntity; +use \Magento\Catalog\Model\ResourceModel\Product; +use \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection; +use \Magento\Framework\Locale\FormatInterface; +use \Magento\Eav\Model\Entity\AttributeLoaderInterface; +use \Magento\SalesRule\Model\Rule\Condition\Product as SalesRuleProduct; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ProductTest extends \PHPUnit_Framework_TestCase +{ + /** @var SalesRuleProduct */ + protected $model; + + /** @var Context|\PHPUnit_Framework_MockObject_MockObject */ + protected $contextMock; + + /** @var Data|\PHPUnit_Framework_MockObject_MockObject */ + protected $backendHelperMock; + + /** @var Config|\PHPUnit_Framework_MockObject_MockObject */ + protected $configMock; + + /** @var ProductFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $productFactoryMock; + + /** @var ProductRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $productRepositoryMock; + + /** @var Product|\PHPUnit_Framework_MockObject_MockObject */ + protected $productMock; + + /** @var Collection|\PHPUnit_Framework_MockObject_MockObject */ + protected $collectionMock; + + /** @var FormatInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $formatMock; + + /** @var AttributeLoaderInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $attributeLoaderInterfaceMock; + + /** + * Setup the test + */ + protected function setUp() + { + $this->contextMock = $this->getMockBuilder(Context::class) + ->disableOriginalConstructor() + ->getMock(); + $this->backendHelperMock = $this->getMockBuilder(Data::class) + ->disableOriginalConstructor() + ->getMock(); + $this->configMock = $this->getMockBuilder(Config::class) + ->disableOriginalConstructor() + ->getMock(); + $this->productFactoryMock = $this->getMockBuilder(ProductFactory::class) + ->disableOriginalConstructor() + ->getMock(); + $this->productRepositoryMock = $this->getMockBuilder(ProductRepositoryInterface::class) + ->getMockForAbstractClass(); + $this->attributeLoaderInterfaceMock = $this->getMockBuilder(AbstractEntity::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributesByCode']) + ->getMock(); + $this->attributeLoaderInterfaceMock + ->expects($this->any()) + ->method('getAttributesByCode') + ->will($this->returnValue([])); + $this->productMock = $this->getMockBuilder(Product::class) + ->disableOriginalConstructor() + ->setMethods(['loadAllAttributes']) + ->getMock(); + $this->productMock + ->expects($this->any()) + ->method('loadAllAttributes') + ->will($this->returnValue($this->attributeLoaderInterfaceMock)); + $this->collectionMock = $this->getMockBuilder(Collection::class) + ->disableOriginalConstructor() + ->getMock(); + $this->formatMock = $this->getMockBuilder(FormatInterface::class) + ->getMockForAbstractClass(); + $this->model = new SalesRuleProduct( + $this->contextMock, + $this->backendHelperMock, + $this->configMock, + $this->productFactoryMock, + $this->productRepositoryMock, + $this->productMock, + $this->collectionMock, + $this->formatMock + ); + } + + /** + * @return array + */ + public function testGetValueElementChooserUrlDataProvider() + { + return [ + 'category_ids_without_js_object' => [ + 'category_ids', + 'sales_rule/promo_widget/chooser/attribute/' + ], + 'category_ids_with_js_object' => [ + 'category_ids', + 'sales_rule/promo_widget/chooser/attribute/', + 'jsobject' + ], + 'sku_without_js_object' => [ + 'sku', + 'sales_rule/promo_widget/chooser/attribute/', + 'jsobject' + ], + 'sku_without_with_js_object' => [ + 'sku', + 'sales_rule/promo_widget/chooser/attribute/' + ], + 'none' => [ + '', + '' + ] + ]; + } + + /** + * test getValueElementChooserUrl + * @param string $attribute + * @param string $url + * @param string $jsObject + * @dataProvider testGetValueElementChooserUrlDataProvider + */ + public function testGetValueElementChooserUrl($attribute, $url, $jsObject = '') + { + $this->model->setJsFormObject($jsObject); + $this->model->setAttribute($attribute); + $url .= $this->model->getAttribute(); + $this->backendHelperMock + ->expects($this->any()) + ->method('getUrl') + ->willReturnArgument(0); + + if ($this->model->getJsFormObject()) { + $url .= '/form/' . $this->model->getJsFormObject(); + } + + $this->assertEquals($url, $this->model->getValueElementChooserUrl()); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml index 63535106514f2c893b0f822daeb7350fd7d892a3..dff1a9fd71d865dd52fd6cdd0e05d3e3d000db94 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml @@ -130,8 +130,8 @@ </design> <schedule_design_update> <class>\Magento\Ui\Test\Block\Adminhtml\Section</class> - <selector>//div[contains(@class,'admin__collapsible-block-wrapper')][descendant::input[@name='custom_design_to']]</selector> - <strategy>xpath</strategy> + <selector>[data-index="schedule_design_update"]</selector> + <strategy>css selector</strategy> <fields> <schedule_update_from> <input>datepicker</input> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php index 100930ad20aea7a40eff2fcf6b367c85db48a242..3d5e550560e857b8530037637b4f97f7763874e2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php @@ -28,7 +28,9 @@ class TopToolbar extends Block */ public function getSelectSortType() { - return $this->_rootElement->find("#sorter")->getElements('option[selected]')[0]->getText(); + $selectedOption = $this->_rootElement->find($this->sorter)->getElements('option[selected]')[0]->getText(); + preg_match('/\w+\s?\w+/', $selectedOption, $matches); + return $matches[0]; } /** @@ -38,7 +40,8 @@ class TopToolbar extends Block */ public function getSortType() { - $content = str_replace("\r", '', $this->_rootElement->find($this->sorter)->getText()); - return explode("\n", $content); + $content = $this->_rootElement->find($this->sorter)->getText(); + preg_match_all('/\w+\s?\w+/', $content, $matches); + return $matches[0]; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml index 30f870dea88f063a7278d7380f5d4fe24f508c9f..2fd8c04d1d80dfe643616ee7c550699da91aeece 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml @@ -67,7 +67,7 @@ <field name="name" xsi:type="string">Category%isolation%</field> <field name="url_key" xsi:type="string">category-%isolation%</field> <field name="parent_id" xsi:type="array"> - <item name="dataset" xsi:type="string">default_subcategory</item> + <item name="dataset" xsi:type="string">default</item> </field> <field name="is_active" xsi:type="string">Yes</field> <field name="include_in_menu" xsi:type="string">Yes</field> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml index 7e6f913dda6e7fd88c0723ccbd5e899ccbeeaafe..22cdab45ac875c6a6987892898e3c8dda3382944 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml @@ -39,8 +39,8 @@ <data name="category/data/layout_update_xml" xsi:type="string"><referenceContainer name="catalog.leftnav" remove="true"/></data> <data name="category/data/new_theme" xsi:type="string">Magento Luma</data> <data name="category/data/apply_design_to_products" xsi:type="string">Yes</data> - <data name="category/data/schedule_update_from" xsi:type="string">Jan 10, 2014</data> - <data name="category/data/schedule_update_to" xsi:type="string">Dec 31, 2024</data> + <data name="category/data/schedule_update_from" xsi:type="string">01/10/2014</data> + <data name="category/data/schedule_update_to" xsi:type="string">12/31/2024</data> <constraint name="Magento\Catalog\Test\Constraint\AssertCategorySaveMessage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForm" /> </variation> @@ -82,8 +82,8 @@ <data name="category/data/layout_update_xml" xsi:type="string"><referenceContainer name="content.aside" remove="true"/></data> <data name="category/data/new_theme" xsi:type="string">Magento Luma</data> <data name="category/data/apply_design_to_products" xsi:type="string">Yes</data> - <data name="category/data/schedule_update_from" xsi:type="string">Jan 1, 2014</data> - <data name="category/data/schedule_update_to" xsi:type="string">Dec 31, 2024</data> + <data name="category/data/schedule_update_from" xsi:type="string">01/10/2014</data> + <data name="category/data/schedule_update_to" xsi:type="string">12/31/2024</data> <constraint name="Magento\Catalog\Test\Constraint\AssertCategorySaveMessage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForm" /> <constraint name="Magento\Catalog\Test\Constraint\AssertCategoryPage" /> diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index 43ac499b8bd9dfce4312896c97ab506a4c93f02d..a5c1f07c164156a0941b0f8da05c43bdff644b5e 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -388,9 +388,13 @@ class ProductTest extends \Magento\TestFramework\Indexer\TestCase ); $productAfterImport->load($productBeforeImport->getId()); $this->assertEquals( - @strtotime($row['news_from_date']), + @strtotime(date('m/d/Y', @strtotime($row['news_from_date']))), @strtotime($productAfterImport->getNewsFromDate()) ); + $this->assertEquals( + @strtotime($row['news_to_date']), + @strtotime($productAfterImport->getNewsToDate()) + ); unset($productAfterImport); } unset($productsBeforeImport, $product); diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_datetime.csv b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_datetime.csv index ae7e27dbd95c0984548142c93c5d4e35afa0cc20..265e29fab65bb88f469454a7c77185c654e26acc 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_datetime.csv +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_datetime.csv @@ -1,4 +1,4 @@ -sku,news_from_date -simple1,"1/1/2015 20:00" -simple2,"10/8/2012 23:58" -simple3,"12/31/1998 17:30" +sku,news_from_date,news_to_date +simple1,"1/1/2015 20:00","1/2/2015" +simple2,"10/8/2012 23:58","1/3/2015" +simple3,"12/31/1998 17:30","1/4/2015" diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/SaveHandlerTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/SaveHandlerTest.php index 7ba149d361f4fcd15c9d5989ff619d9f81b53cc2..40fafeceae44cb8342e03de9cb3a204675c52a88 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/SaveHandlerTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Session/SaveHandlerTest.php @@ -29,32 +29,20 @@ class SaveHandlerTest extends \PHPUnit_Framework_TestCase */ public function testSetSaveHandler($deploymentConfigHandler, $iniHandler) { - $this->markTestSkipped('MAGETWO-56529'); - // Set expected session.save_handler config - if ($deploymentConfigHandler) { - if ($deploymentConfigHandler !== 'files') { - $expected = 'user'; - } else { - $expected = $deploymentConfigHandler; - } - } else if ($iniHandler) { - $expected = $iniHandler; - } else { - $expected = SaveHandlerInterface::DEFAULT_HANDLER; - } + $expected = $this->getExpectedSaveHandler($deploymentConfigHandler, $iniHandler); // Set ini configuration if ($iniHandler) { ini_set('session.save_handler', $iniHandler); } - + $defaultHandler = ini_get('session.save_handler') ?: SaveHandlerInterface::DEFAULT_HANDLER; /** @var DeploymentConfig | \PHPUnit_Framework_MockObject_MockObject $deploymentConfigMock */ $deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class) ->disableOriginalConstructor() ->getMock(); $deploymentConfigMock->expects($this->once()) ->method('get') - ->with(Config::PARAM_SESSION_SAVE_METHOD, SaveHandlerInterface::DEFAULT_HANDLER) + ->with(Config::PARAM_SESSION_SAVE_METHOD, $defaultHandler) ->willReturn($deploymentConfigHandler ?: SaveHandlerInterface::DEFAULT_HANDLER); new SaveHandler( @@ -85,4 +73,31 @@ class SaveHandlerTest extends \PHPUnit_Framework_TestCase [false, false], ]; } + + /** + * Retrieve expected session.save_handler + * + * @param string $deploymentConfigHandler + * @param string $iniHandler + * @return string + */ + private function getExpectedSaveHandler($deploymentConfigHandler, $iniHandler) + { + // Set expected session.save_handler config + if ($deploymentConfigHandler) { + if ($deploymentConfigHandler !== 'files') { + $expected = 'user'; + return $expected; + } else { + $expected = $deploymentConfigHandler; + return $expected; + } + } elseif ($iniHandler) { + $expected = $iniHandler; + return $expected; + } else { + $expected = SaveHandlerInterface::DEFAULT_HANDLER; + return $expected; + } + } } diff --git a/lib/internal/Magento/Framework/Pricing/Render/PriceBox.php b/lib/internal/Magento/Framework/Pricing/Render/PriceBox.php index 4048f2d105ac0f1d455e2a07f9ecc4acdc9bd962..ddf14cdc659a26533a60f4e79a25b39e5b94fddd 100644 --- a/lib/internal/Magento/Framework/Pricing/Render/PriceBox.php +++ b/lib/internal/Magento/Framework/Pricing/Render/PriceBox.php @@ -86,7 +86,7 @@ class PriceBox extends Template implements PriceBoxRenderInterface, IdentityInte */ protected function getCacheLifetime() { - return parent::hasCacheLifetime() ? parent::getCacheLifetime() : self::DEFAULT_LIFETIME; + return parent::hasCacheLifetime() ? parent::getCacheLifetime() : null; } /** diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php index 86e2dde6359d8a9f759905042d86521c135da04d..9a0dfcd7099ee94718f38f18c4af3ab3ed521109 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php @@ -241,4 +241,17 @@ class PriceBoxTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($this->rendererPool, $this->model->getRendererPool()); } + + /** + * This tests ensures that protected method getCacheLifetime() returns a null value when cacheLifeTime is not + * explicitly set in the parent block + */ + public function testCacheLifetime() + { + $reflectionClass = new \ReflectionClass(get_class($this->model)); + $methodReflection = $reflectionClass->getMethod('getCacheLifetime'); + $methodReflection->setAccessible(true); + $cacheLifeTime = $methodReflection->invoke($this->model); + $this->assertNull($cacheLifeTime, 'Expected null cache lifetime'); + } }