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 d974174ef7088..70c20a4e31490 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 @@ public function __construct( \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/Model/Product/Option/Type/FileTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php index 9b41651863fdb..6682b29547632 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 @@ protected function getFileObject() 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/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index b355dd2601c3d..d191f0332f5f2 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -834,4 +834,7 @@ Magento\Eav\Model\Api\SearchCriteria\CollectionProcessor + + + diff --git a/app/code/Magento/Catalog/etc/frontend/di.xml b/app/code/Magento/Catalog/etc/frontend/di.xml index 9b99bd4a78140..ac8c3693e8f30 100644 --- a/app/code/Magento/Catalog/etc/frontend/di.xml +++ b/app/code/Magento/Catalog/etc/frontend/di.xml @@ -18,9 +18,6 @@ Magento\Catalog\Model\ResourceModel\Category\Collection\FetchStrategy - - - true 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 0000000000000..02c1fee1b0745 --- /dev/null +++ b/app/code/Magento/Email/Model/Mail/TransportInterfacePlugin.php @@ -0,0 +1,51 @@ +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 c281a08ab97b6..c42c4088793d7 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 @@ public function setId($value) */ 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 @@ public function beforeSave() 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 f2195a64220e2..3ee95954c0a3a 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 @@ public function testGetAndSetId() } /** - * @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 @@ public function isValidForSendDataProvider() { 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 d1477d470abd1..380e5e6248fb3 100644 --- a/app/code/Magento/Email/etc/di.xml +++ b/app/code/Magento/Email/etc/di.xml @@ -59,5 +59,6 @@ + diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php index 7b454921b0ddc..09ea825c612af 100644 --- a/app/code/Magento/Newsletter/Model/Template.php +++ b/app/code/Magento/Newsletter/Model/Template.php @@ -174,7 +174,8 @@ public function validate() public function beforeSave() { $this->validate(); - return parent::beforeSave(); + parent::beforeSave(); + return $this; } /** @@ -238,9 +239,6 @@ protected function getFilterFactory() */ 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 e51d5e0fdb3a7..c859923065242 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 @@ public function getProcessedTemplateDataProvider() ], ]; } + + /** + * @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 0000000000000..b13ace25f020b --- /dev/null +++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Widget/Chooser.php @@ -0,0 +1,16 @@ +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 0000000000000..a28ea216eda32 --- /dev/null +++ b/app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/ProductTest.php @@ -0,0 +1,161 @@ +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 63535106514f2..dff1a9fd71d86 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 @@ \Magento\Ui\Test\Block\Adminhtml\Section - //div[contains(@class,'admin__collapsible-block-wrapper')][descendant::input[@name='custom_design_to']] - xpath + [data-index="schedule_design_update"] + css selector datepicker 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 100930ad20aea..3d5e550560e85 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 @@ public function getSelectSortType() */ 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 30f870dea88f0..2fd8c04d1d80d 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 @@ Category%isolation% category-%isolation% - default_subcategory + default Yes Yes 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 7e6f913dda6e7..22cdab45ac875 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 @@ <referenceContainer name="catalog.leftnav" remove="true"/> Magento Luma Yes - Jan 10, 2014 - Dec 31, 2024 + 01/10/2014 + 12/31/2024 @@ -82,8 +82,8 @@ <referenceContainer name="content.aside" remove="true"/> Magento Luma Yes - Jan 1, 2014 - Dec 31, 2024 + 01/10/2014 + 12/31/2024 diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/SaveHandlerTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/SaveHandlerTest.php index 7ba149d361f4f..40fafeceae44c 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 @@ public function setUp() */ 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 @@ public function saveHandlerProvider() [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; + } + } }