diff --git a/app/code/Magento/Backend/etc/adminhtml/system.xml b/app/code/Magento/Backend/etc/adminhtml/system.xml index 162aba1cfa3ef6fd6d86ada42171e834be6bcb80..e755e364cde87cdb9b7b04ad6b5d7e86ee8eb35b 100644 --- a/app/code/Magento/Backend/etc/adminhtml/system.xml +++ b/app/code/Magento/Backend/etc/adminhtml/system.xml @@ -142,13 +142,17 @@ <label>Developer</label> <tab>advanced</tab> <resource>Magento_Backend::dev</resource> - <group id="debug" translate="label" type="text" sortOrder="20" showInDefault="0" showInWebsite="1" showInStore="1"> + <group id="debug" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Debug</label> - <field id="template_hints" translate="label" type="select" sortOrder="20" showInDefault="0" showInWebsite="1" showInStore="1"> - <label>Template Path Hints</label> + <field id="template_hints_storefront" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Enabled Template Path Hints for Storefront</label> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> </field> - <field id="template_hints_blocks" translate="label" type="select" sortOrder="21" showInDefault="0" showInWebsite="1" showInStore="1"> + <field id="template_hints_admin" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0"> + <label>Enabled Template Path Hints for Admin</label> + <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> + </field> + <field id="template_hints_blocks" translate="label" type="select" sortOrder="21" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Add Block Names to Hints</label> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> </field> diff --git a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php index e25b1105ea2efa870b8b1f3c5629d96a6619326b..45f9f7566344512b39f3ccf4211269f9f1328828 100644 --- a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php +++ b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php @@ -30,7 +30,7 @@ class ColumnFactory 'text' => 'text', 'boolean' => 'select', 'select' => 'select', - 'multiselect' => 'text', + 'multiselect' => 'select', 'date' => 'date', ]; diff --git a/app/code/Magento/Customer/Ui/Component/DataProvider.php b/app/code/Magento/Customer/Ui/Component/DataProvider.php index 91a14122678c9ea128c5263a30c86bc68ce4c845..16fcaa639690231160ee7eba69ca9c0919c0c59a 100644 --- a/app/code/Magento/Customer/Ui/Component/DataProvider.php +++ b/app/code/Magento/Customer/Ui/Component/DataProvider.php @@ -58,59 +58,16 @@ class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvi ); } - /** - * Retrieve custom attributes options - * - * @return array - */ - public function getCustomAttributesOptions() - { - $attributes = []; - foreach ($this->attributeRepository->getList() as $attributeCode => $attributeData) { - if ($attributeData[AttributeMetadataInterface::BACKEND_TYPE] != 'static' - && $attributeData[AttributeMetadataInterface::IS_USED_IN_GRID] - && $attributeData[AttributeMetadataInterface::OPTIONS] - ) { - $attributes[$attributeCode] = $attributeData[AttributeMetadataInterface::OPTIONS]; - } - } - return $attributes; - } - - /** - * Retrieve attribute option label by option value - * - * @param array $attributeData - * @param string $value - * @return string - */ - protected function getAttributeOptionLabelByValue(array $attributeData, $value) - { - if (empty($value)) { - return $value; - } - foreach ($attributeData as $option) { - if ($option['value'] === $value) { - return $option['label']; - } - } - return $value; - } - /** * {@inheritdoc} */ public function getData() { - $data = $this->searchResultToOutput($this->getSearchResult()); - $customAttributesOptions = $this->getCustomAttributesOptions(); - foreach ($customAttributesOptions as $attributeCode => $attributeData) { + $data = parent::getData(); + foreach ($this->attributeRepository->getList() as $attributeCode => $attributeData) { foreach ($data['items'] as &$item) { - if (isset($item[$attributeCode])) { - $item[$attributeCode] = $this->getAttributeOptionLabelByValue( - $attributeData, - $item[$attributeCode] - ); + if (isset($item[$attributeCode]) && !empty($attributeData[AttributeMetadataInterface::OPTIONS])) { + $item[$attributeCode] = explode(',', $item[$attributeCode]); } } } diff --git a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml index 1144b3c1ed13dfcd518468d17fe43795c90f7fce..b144ac27d89bb6a514f786631375d9765ab0432d 100644 --- a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml +++ b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml @@ -267,18 +267,18 @@ </item> </argument> </column> - <column name="remote_addr"> - <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> - <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">IP Address</item> - </item> - </argument> - </column> + <!--<column name="remote_addr">--> + <!--<argument name="data" xsi:type="array">--> + <!--<item name="js_config" xsi:type="array">--> + <!--<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item>--> + <!--</item>--> + <!--<item name="config" xsi:type="array">--> + <!--<item name="dataType" xsi:type="string">text</item>--> + <!--<item name="align" xsi:type="string">left</item>--> + <!--<item name="label" xsi:type="string" translate="true">IP Address</item>--> + <!--</item>--> + <!--</argument>--> + <!--</column>--> <column name="first_visit_at"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> @@ -315,17 +315,17 @@ </item> </argument> </column> - <column name="last_url"> - <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> - <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Last URL</item> - </item> - </argument> - </column> + <!--<column name="last_url">--> + <!--<argument name="data" xsi:type="array">--> + <!--<item name="js_config" xsi:type="array">--> + <!--<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item>--> + <!--</item>--> + <!--<item name="config" xsi:type="array">--> + <!--<item name="dataType" xsi:type="string">text</item>--> + <!--<item name="align" xsi:type="string">left</item>--> + <!--<item name="label" xsi:type="string" translate="true">Last URL</item>--> + <!--</item>--> + <!--</argument>--> + <!--</column>--> </columns> </listing> diff --git a/app/code/Magento/Customer/view/frontend/templates/widget/gender.phtml b/app/code/Magento/Customer/view/frontend/templates/widget/gender.phtml index 4452a8b46fa6ad07c7ecdde0b47f7bb8fe9da194..b5d537a55956ad0fe2a5b10c48fe8936a04b6d1d 100644 --- a/app/code/Magento/Customer/view/frontend/templates/widget/gender.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/widget/gender.phtml @@ -14,7 +14,7 @@ <?php $options = $block->getGenderOptions(); ?> <?php $value = $block->getGender();?> <?php foreach ($options as $option):?> - <option value="<?php /* @escapeNotVerified */ echo $option->getValue() ?>"<?php if ($option->getValue() == $value) echo ' selected="selected"' ?>><?php /* @escapeNotVerified */ echo $option->getLabel() ?></option> + <option value="<?php /* @escapeNotVerified */ echo $option->getValue() ?>"<?php if ($option->getValue() == $value) echo ' selected="selected"' ?>><?php /* @escapeNotVerified */ echo __($option->getLabel()) ?></option> <?php endforeach;?> </select> </div> diff --git a/app/code/Magento/Deploy/Model/Deployer.php b/app/code/Magento/Deploy/Model/Deployer.php index 7337a9f0896e5299efa3f45b6d1f7a04b74b6386..cada5a4549aee90b4f18f6df5a2588dd37d82c25 100644 --- a/app/code/Magento/Deploy/Model/Deployer.php +++ b/app/code/Magento/Deploy/Model/Deployer.php @@ -118,21 +118,23 @@ class Deployer /** @var \Magento\Theme\Model\View\Design $design */ $design = $this->objectManager->create('Magento\Theme\Model\View\Design'); $design->setDesignTheme($themePath, $area); + $assetRepo = $this->objectManager->create( + 'Magento\Framework\View\Asset\Repository', + [ + 'design' => $design, + ] + ); $fileManager = $this->objectManager->create( 'Magento\RequireJs\Model\FileManager', [ 'config' => $this->objectManager->create( 'Magento\Framework\RequireJs\Config', [ - 'assetRepo' => $this->objectManager->create( - 'Magento\Framework\View\Asset\Repository', - [ - 'design' => $design, - ] - ), + 'assetRepo' => $assetRepo, 'design' => $design, ] ), + 'assetRepo' => $assetRepo, ] ); $fileManager->createRequireJsConfigAsset(); @@ -161,6 +163,7 @@ class Deployer null ); } + $fileManager->clearBundleJsPool(); $this->bundleManager->flush(); $this->output->writeln("\nSuccessful: {$this->count} files; errors: {$this->errorCount}\n---\n"); } diff --git a/app/code/Magento/Developer/Model/TemplateEngine/Plugin/DebugHints.php b/app/code/Magento/Developer/Model/TemplateEngine/Plugin/DebugHints.php index 33f9eea54015be86a303b36ce309b83340cd7331..b23ba2f88779d3be265a2dc489d9951b3dc56154 100644 --- a/app/code/Magento/Developer/Model/TemplateEngine/Plugin/DebugHints.php +++ b/app/code/Magento/Developer/Model/TemplateEngine/Plugin/DebugHints.php @@ -5,77 +5,100 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - -// @codingStandardsIgnoreFile - namespace Magento\Developer\Model\TemplateEngine\Plugin; +use Magento\Developer\Helper\Data as DevHelper; +use Magento\Developer\Model\TemplateEngine\Decorator\DebugHintsFactory; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\View\TemplateEngineFactory; +use Magento\Framework\View\TemplateEngineInterface; use Magento\Store\Model\ScopeInterface; +use Magento\Store\Model\StoreManagerInterface; class DebugHints { - /**#@+ - * XPath of configuration of the debugging hints + /** + * XPath of configuration of the debug block names */ - const XML_PATH_DEBUG_TEMPLATE_HINTS = 'dev/debug/template_hints'; - const XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS = 'dev/debug/template_hints_blocks'; - /**#@-*/ + /** + * @var ScopeConfigInterface + */ + protected $scopeConfig; + + /** + * @var StoreManagerInterface + */ + protected $storeManager; /** - * @var \Magento\Framework\ObjectManagerInterface + * @var DevHelper */ - private $objectManager; + protected $devHelper; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var DebugHintsFactory */ - private $scopeConfig; + protected $debugHintsFactory; /** - * @var \Magento\Developer\Helper\Data + * XPath of configuration of the debug hints + * + * Allowed values: + * dev/debug/template_hints_storefront + * dev/debug/template_hints_admin + * + * @var string */ - private $devHelper; + protected $debugHintsPath; /** - * @param \Magento\Framework\ObjectManagerInterface $objectManager - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Developer\Helper\Data $devHelper + * @param ScopeConfigInterface $scopeConfig + * @param StoreManagerInterface $storeManager + * @param DevHelper $devHelper + * @param DebugHintsFactory $debugHintsFactory + * @param string $debugHintsPath */ public function __construct( - \Magento\Framework\ObjectManagerInterface $objectManager, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Developer\Helper\Data $devHelper + ScopeConfigInterface $scopeConfig, + StoreManagerInterface $storeManager, + DevHelper $devHelper, + DebugHintsFactory $debugHintsFactory, + $debugHintsPath ) { - $this->objectManager = $objectManager; $this->scopeConfig = $scopeConfig; + $this->storeManager = $storeManager; $this->devHelper = $devHelper; + $this->debugHintsFactory = $debugHintsFactory; + $this->debugHintsPath = $debugHintsPath; } /** * Wrap template engine instance with the debugging hints decorator, depending of the store configuration * - * @param \Magento\Framework\View\TemplateEngineFactory $subject - * @param \Magento\Framework\View\TemplateEngineInterface $invocationResult + * @param TemplateEngineFactory $subject + * @param TemplateEngineInterface $invocationResult * - * @return \Magento\Framework\View\TemplateEngineInterface + * @return TemplateEngineInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterCreate( - \Magento\Framework\View\TemplateEngineFactory $subject, - \Magento\Framework\View\TemplateEngineInterface $invocationResult + TemplateEngineFactory $subject, + TemplateEngineInterface $invocationResult ) { - if ($this->scopeConfig->getValue(self::XML_PATH_DEBUG_TEMPLATE_HINTS, ScopeInterface::SCOPE_STORE) && - $this->devHelper->isDevAllowed()) { + $storeCode = $this->storeManager->getStore()->getCode(); + if ($this->scopeConfig->getValue($this->debugHintsPath, ScopeInterface::SCOPE_STORE, $storeCode) + && $this->devHelper->isDevAllowed()) { $showBlockHints = $this->scopeConfig->getValue( self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS, - ScopeInterface::SCOPE_STORE - ); - return $this->objectManager->create( - 'Magento\Developer\Model\TemplateEngine\Decorator\DebugHints', - ['subject' => $invocationResult, 'showBlockHints' => $showBlockHints] + ScopeInterface::SCOPE_STORE, + $storeCode ); + return $this->debugHintsFactory->create([ + 'subject' => $invocationResult, + 'showBlockHints' => $showBlockHints, + ]); } return $invocationResult; } diff --git a/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php b/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php index 00cc776db30eb9e2195366971f391957be16f2a1..9ccd6cb99dd3ce194ec35007c2c11932a9eb52a4 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php @@ -5,130 +5,194 @@ */ namespace Magento\Developer\Test\Unit\Model\TemplateEngine\Plugin; +use Magento\Developer\Model\TemplateEngine\Decorator\DebugHintsFactory; use Magento\Developer\Model\TemplateEngine\Plugin\DebugHints; +use Magento\Store\Model\ScopeInterface; class DebugHintsTest extends \PHPUnit_Framework_TestCase { /** - * @var DebugHints + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $model; + protected $scopeConfigMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $objectManagerMock; + protected $storeManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Developer\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ - protected $scopeConfigMock; + protected $devHelperMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var DebugHintsFactory | \PHPUnit_Framework_MockObject_MockObject */ - protected $devHelperMock; + protected $debugHintsFactory; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @return void */ - protected $subjectMock; - protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->devHelperMock = $this->getMock('Magento\Developer\Helper\Data', [], [], '', false); - $this->subjectMock = $this->getMock( - 'Magento\Framework\View\TemplateEngineFactory', - [], - [], - '', - false - ); - $this->model = new \Magento\Developer\Model\TemplateEngine\Plugin\DebugHints($this->objectManagerMock, $this->scopeConfigMock, $this->devHelperMock); + $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->getMockForAbstractClass(); + + $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + ->getMockForAbstractClass(); + + $this->devHelperMock = $this->getMockBuilder('Magento\Developer\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + + $this->debugHintsFactory = $this->getMockBuilder( + 'Magento\Developer\Model\TemplateEngine\Decorator\DebugHintsFactory' + ) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); } /** + * @param string $debugHintsPath * @param bool $showBlockHints + * @return void * @dataProvider afterCreateActiveDataProvider */ - public function testAfterCreateActive($showBlockHints) + public function testAfterCreateActive($debugHintsPath, $showBlockHints) { - $this->devHelperMock->expects($this->once())->method('isDevAllowed')->will($this->returnValue(true)); - $this->_setupConfigFixture(true, $showBlockHints); + $this->devHelperMock->expects($this->once()) + ->method('isDevAllowed') + ->willReturn(true); + + $this->setupConfigFixture($debugHintsPath, true, $showBlockHints); + $engine = $this->getMock('Magento\Framework\View\TemplateEngineInterface'); - $engineDecorated = $this->getMock('Magento\Framework\View\TemplateEngineInterface'); - $this->objectManagerMock->expects( - $this->once() - )->method( - 'create' - )->with( - 'Magento\Developer\Model\TemplateEngine\Decorator\DebugHints', - $this->identicalTo(['subject' => $engine, 'showBlockHints' => $showBlockHints]) - )->will( - $this->returnValue($engineDecorated) + + $debugHintsDecorator = $this->getMockBuilder( + 'Magento\Developer\Model\TemplateEngine\Decorator\DebugHints' + ) + ->disableOriginalConstructor() + ->getMock(); + + $this->debugHintsFactory->expects($this->once()) + ->method('create') + ->with([ + 'subject' => $engine, + 'showBlockHints' => $showBlockHints, + ]) + ->willReturn($debugHintsDecorator); + + $subjectMock = $this->getMockBuilder('Magento\Framework\View\TemplateEngineFactory') + ->disableOriginalConstructor() + ->getMock(); + + $debugHints = new DebugHints( + $this->scopeConfigMock, + $this->storeManager, + $this->devHelperMock, + $this->debugHintsFactory, + $debugHintsPath ); - $this->assertEquals($engineDecorated, $this->model->afterCreate($this->subjectMock, $engine)); + + $this->assertEquals($debugHintsDecorator, $debugHints->afterCreate($subjectMock, $engine)); } + /** + * @return array + */ public function afterCreateActiveDataProvider() { - return ['block hints disabled' => [false], 'block hints enabled' => [true]]; + return [ + ['dev/debug/template_hints_storefront', false], + ['dev/debug/template_hints_storefront', true], + ['dev/debug/template_hints_admin', false], + ['dev/debug/template_hints_admin', true], + ]; } /** + * @param string $debugHintsPath * @param bool $isDevAllowed * @param bool $showTemplateHints + * @return void * @dataProvider afterCreateInactiveDataProvider */ - public function testAfterCreateInactive($isDevAllowed, $showTemplateHints) + public function testAfterCreateInactive($debugHintsPath, $isDevAllowed, $showTemplateHints) { - $this->devHelperMock->expects($this->any())->method('isDevAllowed')->will($this->returnValue($isDevAllowed)); - $this->_setupConfigFixture($showTemplateHints, true); - $this->objectManagerMock->expects($this->never())->method('create'); - $engine = $this->getMock('Magento\Framework\View\TemplateEngineInterface', [], [], '', false); - $this->assertSame($engine, $this->model->afterCreate($this->subjectMock, $engine)); + $this->devHelperMock->expects($this->any()) + ->method('isDevAllowed') + ->willReturn($isDevAllowed); + + $this->setupConfigFixture($debugHintsPath, $showTemplateHints, true); + + $engine = $this->getMock('Magento\Framework\View\TemplateEngineInterface'); + + $subjectMock = $this->getMockBuilder('Magento\Framework\View\TemplateEngineFactory') + ->disableOriginalConstructor() + ->getMock(); + + $debugHints = new DebugHints( + $this->scopeConfigMock, + $this->storeManager, + $this->devHelperMock, + $this->debugHintsFactory, + $debugHintsPath + ); + + $this->assertSame($engine, $debugHints->afterCreate($subjectMock, $engine)); } + /** + * @return array + */ public function afterCreateInactiveDataProvider() { return [ - 'dev disabled, template hints disabled' => [false, false], - 'dev disabled, template hints enabled' => [false, true], - 'dev enabled, template hints disabled' => [true, false] + ['dev/debug/template_hints_storefront', false, false], + ['dev/debug/template_hints_storefront', false, true], + ['dev/debug/template_hints_storefront', true, false], + ['dev/debug/template_hints_admin', false, false], + ['dev/debug/template_hints_admin', false, true], + ['dev/debug/template_hints_admin', true, false], ]; } /** * Setup fixture values for store config * + * @param string $debugHintsPath * @param bool $showTemplateHints * @param bool $showBlockHints + * @return void */ - protected function _setupConfigFixture($showTemplateHints, $showBlockHints) + protected function setupConfigFixture($debugHintsPath, $showTemplateHints, $showBlockHints) { - $this->scopeConfigMock->expects( - $this->atLeastOnce() - )->method( - 'getValue' - )->will( - $this->returnValueMap( + $storeCode = 'default'; + $storeMock = $this->getMock('Magento\Store\Api\Data\StoreInterface'); + $storeMock->expects($this->once()) + ->method('getCode') + ->willReturn($storeCode); + $this->storeManager->expects($this->once()) + ->method('getStore') + ->willReturn($storeMock); + + $this->scopeConfigMock->expects($this->atLeastOnce()) + ->method('getValue') + ->willReturnMap([ [ - [ - DebugHints::XML_PATH_DEBUG_TEMPLATE_HINTS, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - null, - $showTemplateHints, - ], - [ - DebugHints::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - null, - $showBlockHints - ], + $debugHintsPath, + ScopeInterface::SCOPE_STORE, + $storeCode, + $showTemplateHints, + ], + [ + DebugHints::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS, + ScopeInterface::SCOPE_STORE, + $storeCode, + $showBlockHints ] - ) - ); + ]); } } diff --git a/app/code/Magento/Developer/etc/adminhtml/di.xml b/app/code/Magento/Developer/etc/adminhtml/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..ff22a95f0e92c698ff6d80185c0f5e505fca1e32 --- /dev/null +++ b/app/code/Magento/Developer/etc/adminhtml/di.xml @@ -0,0 +1,17 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\Framework\View\TemplateEngineFactory"> + <plugin name="debug_hints" type="Magento\Developer\Model\TemplateEngine\Plugin\DebugHints" sortOrder="10"/> + </type> + <type name="Magento\Developer\Model\TemplateEngine\Plugin\DebugHints"> + <arguments> + <argument name="debugHintsPath" xsi:type="string">dev/debug/template_hints_admin</argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/Developer/etc/di.xml b/app/code/Magento/Developer/etc/di.xml index ea0f67f38bed507d85c70467b78457555a012136..436385046bc060fdce294221979dae5a5f6383a4 100644 --- a/app/code/Magento/Developer/etc/di.xml +++ b/app/code/Magento/Developer/etc/di.xml @@ -10,9 +10,6 @@ <preference for="Magento\Framework\Css\PreProcessor\ErrorHandlerInterface" type="Magento\Framework\Css\PreProcessor\ErrorHandler" /> <preference for="Magento\Framework\Css\PreProcessor\AdapterInterface" type="Magento\Framework\Css\PreProcessor\Adapter\Less\Oyejorge" /> - <type name="Magento\Framework\View\TemplateEngineFactory"> - <plugin name="debug_hints" type="Magento\Developer\Model\TemplateEngine\Plugin\DebugHints" sortOrder="10"/> - </type> <type name="Magento\Framework\View\Result\Page"> <arguments> <argument name="pageConfigRendererFactory" xsi:type="object">Magento\Developer\Model\View\Page\Config\RendererFactory</argument> diff --git a/app/code/Magento/Developer/etc/frontend/di.xml b/app/code/Magento/Developer/etc/frontend/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..3fd5f545b9d04f1f9c68f9b2b969984c9ffaefba --- /dev/null +++ b/app/code/Magento/Developer/etc/frontend/di.xml @@ -0,0 +1,17 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\Framework\View\TemplateEngineFactory"> + <plugin name="debug_hints" type="Magento\Developer\Model\TemplateEngine\Plugin\DebugHints" sortOrder="10"/> + </type> + <type name="Magento\Developer\Model\TemplateEngine\Plugin\DebugHints"> + <arguments> + <argument name="debugHintsPath" xsi:type="string">dev/debug/template_hints_storefront</argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/Eav/Model/Validator/Attribute/Data.php b/app/code/Magento/Eav/Model/Validator/Attribute/Data.php index 883ca66f6a822947c9f928f857791dcca9b8e590..011f79252967ac3101251f832a76c278dc7fa620 100644 --- a/app/code/Magento/Eav/Model/Validator/Attribute/Data.php +++ b/app/code/Magento/Eav/Model/Validator/Attribute/Data.php @@ -163,6 +163,9 @@ class Data extends \Magento\Framework\Validator\AbstractValidator $attributesByCode = []; $attributesCodes = []; foreach ($attributes as $attribute) { + if (!$attribute->getIsVisible()) { + continue; + } $attributeCode = $attribute->getAttributeCode(); $attributesByCode[$attributeCode] = $attribute; $attributesCodes[] = $attributeCode; diff --git a/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php b/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php index e8c80df9efbf701c6bb6afcc6b9a6e33ce3ec7f6..d39ee81d5ae452670239fe6856fcee8907eaf817 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php @@ -44,16 +44,10 @@ class DataTest extends \PHPUnit_Framework_TestCase $validator->setAttributes([$attribute])->setData($data); if ($attribute->getDataModel() || $attribute->getFrontendInput()) { $dataModel = $this->_getDataModelMock($result); - $attrDataFactory->expects( - $this->once() - )->method( - 'create' - )->with( - $attribute, - $entity - )->will( - $this->returnValue($dataModel) - ); + $attrDataFactory->expects($this->any()) + ->method('create') + ->with($attribute, $entity) + ->will($this->returnValue($dataModel)); } $this->assertEquals($expected, $validator->isValid($entity)); $this->assertEquals($messages, $validator->getMessages()); @@ -72,6 +66,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'attribute_code' => 'attribute', 'data_model' => $this->_getDataModelMock(null), 'frontend_input' => 'text', + 'is_visible' => true, ], 'attributeReturns' => true, 'isValid' => true, @@ -82,19 +77,27 @@ class DataTest extends \PHPUnit_Framework_TestCase 'attribute_code' => 'attribute', 'data_model' => $this->_getDataModelMock(null), 'frontend_input' => 'text', + 'is_visible' => true, ], 'attributeReturns' => ['Error'], 'isValid' => false, 'messages' => ['attribute' => ['Error']], ], 'no_data_models' => [ - 'attributeData' => ['attribute_code' => 'attribute', 'frontend_input' => 'text'], + 'attributeData' => [ + 'attribute_code' => 'attribute', + 'frontend_input' => 'text', + 'is_visible' => true, + ], 'attributeReturns' => ['Error'], 'isValid' => false, 'messages' => ['attribute' => ['Error']], ], 'no_data_models_no_frontend_input' => [ - 'attributeData' => ['attribute_code' => 'attribute'], + 'attributeData' => [ + 'attribute_code' => 'attribute', + 'is_visible' => true, + ], 'attributeReturns' => ['Error'], 'isValid' => true, 'messages' => [], @@ -104,6 +107,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'attribute_code' => 'attribute', 'data_model' => $this->_getDataModelMock(null), 'frontend_input' => 'text', + 'is_visible' => true, ], 'attributeReturns' => true, 'isValid' => true, @@ -115,12 +119,24 @@ class DataTest extends \PHPUnit_Framework_TestCase 'attribute_code' => 'attribute', 'data_model' => $this->_getDataModelMock(null), 'frontend_input' => 'text', + 'is_visible' => true, ], 'attributeReturns' => true, 'isValid' => true, 'messages' => [], 'setData' => [], - ] + ], + 'is_invisible' => [ + 'attributeData' => [ + 'attribute_code' => 'attribute', + 'data_model' => $this->_getDataModelMock(null), + 'frontend_input' => 'text', + 'is_visible' => false, + ], + 'attributeReturns' => ['Error'], + 'isValid' => true, + 'messages' => [], + ], ]; } @@ -138,6 +154,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'attribute_code' => 'attribute', 'data_model' => $this->_getDataModelMock(null), 'frontend_input' => 'text', + 'is_visible' => true, ] ); $collection = $this->getMockBuilder('Magento\Framework\DataObject')->setMethods(['getItems'])->getMock(); @@ -185,6 +202,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'attribute_code' => 'attribute', 'data_model' => $this->_getDataModelMock(null), 'frontend_input' => 'text', + 'is_visible' => true, ] ); $secondAttribute = $this->_getAttributeMock( @@ -192,6 +210,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'attribute_code' => 'attribute2', 'data_model' => $this->_getDataModelMock(null), 'frontend_input' => 'text', + 'is_visible' => true, ] ); $data = ['attribute' => 'new_test_data', 'attribute2' => 'some data']; @@ -279,6 +298,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'attribute_code' => 'attribute1', 'data_model' => $firstDataModel = $this->_getDataModelMock(['Error1']), 'frontend_input' => 'text', + 'is_visible' => true, ] ); $secondAttribute = $this->_getAttributeMock( @@ -286,6 +306,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'attribute_code' => 'attribute2', 'data_model' => $secondDataModel = $this->_getDataModelMock(['Error2']), 'frontend_input' => 'text', + 'is_visible' => true, ] ); $expectedMessages = ['attribute1' => ['Error1'], 'attribute2' => ['Error2']]; @@ -354,11 +375,17 @@ class DataTest extends \PHPUnit_Framework_TestCase */ protected function _getAttributeMock($attributeData) { - $attribute = $this->getMockBuilder( - 'Magento\Eav\Model\Attribute' - )->setMethods( - ['getAttributeCode', 'getDataModel', 'getFrontendInput', '__wakeup'] - )->disableOriginalConstructor()->getMock(); + $attribute = $this->getMockBuilder('Magento\Eav\Model\Attribute') + ->setMethods([ + 'getAttributeCode', + 'getDataModel', + 'getFrontendInput', + '__wakeup', + 'getIsVisible', + ]) + ->disableOriginalConstructor() + ->getMock(); + if (isset($attributeData['attribute_code'])) { $attribute->expects( $this->any() @@ -386,6 +413,11 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->returnValue($attributeData['frontend_input']) ); } + if (isset($attributeData['is_visible'])) { + $attribute->expects($this->any()) + ->method('getIsVisible') + ->willReturn($attributeData['is_visible']); + } return $attribute; } diff --git a/app/code/Magento/Quote/etc/fieldset.xml b/app/code/Magento/Quote/etc/fieldset.xml index 4be04d06516414c73923f4d48b04de409a4c47a7..aa695aadc4214d3f89f454ee00385157fa212a88 100644 --- a/app/code/Magento/Quote/etc/fieldset.xml +++ b/app/code/Magento/Quote/etc/fieldset.xml @@ -157,6 +157,26 @@ <aspect name="to_order_address" /> <aspect name="to_customer_address" /> </field> + <field name="vat_id"> + <aspect name="to_order_address" /> + <aspect name="to_customer_address" /> + </field> + <field name="vat_is_valid"> + <aspect name="to_order_address" /> + <aspect name="to_customer_address" /> + </field> + <field name="vat_request_id"> + <aspect name="to_order_address" /> + <aspect name="to_customer_address" /> + </field> + <field name="vat_request_date"> + <aspect name="to_order_address" /> + <aspect name="to_customer_address" /> + </field> + <field name="vat_request_success"> + <aspect name="to_order_address" /> + <aspect name="to_customer_address" /> + </field> <field name="email"> <aspect name="to_order" targetField="customer_email"/> <aspect name="to_order_address" /> diff --git a/app/code/Magento/RequireJs/Model/FileManager.php b/app/code/Magento/RequireJs/Model/FileManager.php index 6ce74ef2139b1232879b6ffafa20c46017cbae53..8ca3298865efcaa9a4354af6db10ecfbd8fe0616 100644 --- a/app/code/Magento/RequireJs/Model/FileManager.php +++ b/app/code/Magento/RequireJs/Model/FileManager.php @@ -171,4 +171,18 @@ class FileManager return $bundles; } + + /** + * Remove all bundles from pool + * + * @return bool + */ + public function clearBundleJsPool() + { + $dirWrite = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW); + /** @var $context \Magento\Framework\View\Asset\File\FallbackContext */ + $context = $this->assetRepo->getStaticViewFileContext(); + $bundleDir = $context->getPath() . '/' . Config::BUNDLE_JS_DIR; + return $dirWrite->delete($bundleDir); + } } diff --git a/app/code/Magento/RequireJs/Test/Unit/Model/FileManagerTest.php b/app/code/Magento/RequireJs/Test/Unit/Model/FileManagerTest.php index 0993494d09f57a185e1fca3fee9f70717dcb5f6c..1d89833a73b7f26c6fffba5e6d69ff3a9aef91eb 100644 --- a/app/code/Magento/RequireJs/Test/Unit/Model/FileManagerTest.php +++ b/app/code/Magento/RequireJs/Test/Unit/Model/FileManagerTest.php @@ -223,4 +223,27 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase $this->assertSame($this->asset, $this->object->createRequireJsMixinsAsset()); } + + public function testClearBundleJsPool() + { + $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') + ->disableOriginalConstructor() + ->getMock(); + $this->fileSystem->expects($this->once()) + ->method('getDirectoryWrite') + ->with(DirectoryList::STATIC_VIEW) + ->willReturn($this->dir); + $this->assetRepoMock + ->expects($this->once()) + ->method('getStaticViewFileContext') + ->willReturn($context); + $context->expects($this->once()) + ->method('getPath') + ->willReturn('/path/to/directory'); + $this->dir->expects($this->once()) + ->method('delete') + ->with('/path/to/directory/' . \Magento\Framework\RequireJs\Config::BUNDLE_JS_DIR) + ->willReturn(true); + $this->assertTrue($this->object->clearBundleJsPool()); + } } diff --git a/app/code/Magento/Sales/Model/Order/CustomerManagement.php b/app/code/Magento/Sales/Model/Order/CustomerManagement.php index 0a5b3ee6ccbf39c979c9f6290c30f5edcf0c00de..32ef6bb7ebbf57daafe0688c5391f84ff5c4601f 100644 --- a/app/code/Magento/Sales/Model/Order/CustomerManagement.php +++ b/app/code/Magento/Sales/Model/Order/CustomerManagement.php @@ -6,6 +6,7 @@ namespace Magento\Sales\Model\Order; use Magento\Framework\Exception\AlreadyExistsException; +use Magento\Quote\Model\Quote\Address as QuoteAddress; /** * Class CustomerManagement @@ -91,6 +92,15 @@ class CustomerManagement implements \Magento\Sales\Api\OrderCustomerManagementIn ); /** @var \Magento\Customer\Api\Data\AddressInterface $customerAddress */ $customerAddress = $this->addressFactory->create(['data' => $addressData]); + switch ($address->getAddressType()) { + case QuoteAddress::ADDRESS_TYPE_BILLING: + $customerAddress->setIsDefaultBilling(true); + break; + case QuoteAddress::ADDRESS_TYPE_SHIPPING: + $customerAddress->setIsDefaultShipping(true); + break; + } + if (is_string($address->getRegion())) { /** @var \Magento\Customer\Api\Data\RegionInterface $region */ $region = $this->regionFactory->create(); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php index 62ab12af42dda52141338fb41e191a469a298005..4485d5ef43e83c8832041f478b5e764f041558d9 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php @@ -5,6 +5,8 @@ */ namespace Magento\Sales\Test\Unit\Model\Order; +use Magento\Quote\Model\Quote\Address; + /** * Class BuilderTest */ @@ -98,18 +100,40 @@ class CustomerManagementTest extends \PHPUnit_Framework_TestCase $orderMock = $this->getMock('\Magento\Sales\Api\Data\OrderInterface'); $orderMock->expects($this->once())->method('getCustomerId')->will($this->returnValue(null)); $orderMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue('billing_address')); - $orderAddress = $this->getMock('\Magento\Sales\Api\Data\OrderAddressInterface'); - $addresses = [$orderAddress, $orderAddress]; - $orderMock->expects($this->any())->method('getAddresses')->will($this->returnValue($addresses)); + $orderBillingAddress = $this->getMock('\Magento\Sales\Api\Data\OrderAddressInterface'); + $orderBillingAddress->expects($this->once()) + ->method('getAddressType') + ->willReturn(Address::ADDRESS_TYPE_BILLING); + + $orderShippingAddress = $this->getMock('\Magento\Sales\Api\Data\OrderAddressInterface'); + $orderShippingAddress->expects($this->once()) + ->method('getAddressType') + ->willReturn(Address::ADDRESS_TYPE_SHIPPING); + + $orderMock->expects($this->any()) + ->method('getAddresses') + ->will($this->returnValue([$orderBillingAddress, $orderShippingAddress])); + $this->orderRepository->expects($this->once())->method('get')->with(1)->will($this->returnValue($orderMock)); $this->objectCopyService->expects($this->any())->method('copyFieldsetToTarget')->will($this->returnValueMap( [ ['order_address', 'to_customer', 'billing_address', [], 'global', ['customer_data' => []]], - ['order_address', 'to_customer_address', $orderAddress, [], 'global', 'address_data'] + ['order_address', 'to_customer_address', $orderBillingAddress, [], 'global', 'address_data'], + ['order_address', 'to_customer_address', $orderShippingAddress, [], 'global', 'address_data'], ] )); - $addressMock = $this->getMock('\Magento\Customer\Api\Data\CustomerAddressInterface'); + + $addressMock = $this->getMock('\Magento\Customer\Api\Data\AddressInterface'); + $addressMock->expects($this->any()) + ->method('setIsDefaultBilling') + ->with(true) + ->willReturnSelf(); + $addressMock->expects($this->any()) + ->method('setIsDefaultShipping') + ->with(true) + ->willReturnSelf(); + $this->addressFactory->expects($this->any())->method('create')->with(['data' => 'address_data'])->will( $this->returnValue($addressMock) ); @@ -124,6 +148,5 @@ class CustomerManagementTest extends \PHPUnit_Framework_TestCase $orderMock->expects($this->once())->method('setCustomerId')->with('customer_id'); $this->orderRepository->expects($this->once())->method('save')->with($orderMock); $this->assertEquals($customerMock, $this->service->create(1)); - } } diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js index 46cbff1cf1dfd610ea5a3cd016304493cf880fde..f55a2efdd6311ec0078830eb1a50d37dc82bb3a5 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js @@ -11,24 +11,24 @@ define([ /** * Retrieves label associated with a provided value. * - * @param {(String|Number)} value - Value of the option. + * @param {Array} values - Values of the option. * @returns {String} */ - getLabel: function (value) { + getLabel: function (values) { var options = this.options || [], - label = ''; + labels = []; - value = value || ''; + values = values || []; /*eslint-disable eqeqeq*/ - options.some(function (item) { - label = item.label; - - return item.value == value; + options.forEach(function (item) { + if(values.indexOf(item.value) > -1) { + labels.push(item.label); + } }); /*eslint-enable eqeqeq*/ - return label; + return labels.join(', '); } }); }); diff --git a/app/code/Magento/Wishlist/Controller/Index/Fromcart.php b/app/code/Magento/Wishlist/Controller/Index/Fromcart.php index c17fe8022295bee6efe7ac24e41c40aad374d9b0..8ee09cc1d33b71d068ae3c15f6a4346bf272e2ee 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Fromcart.php +++ b/app/code/Magento/Wishlist/Controller/Index/Fromcart.php @@ -5,28 +5,69 @@ */ namespace Magento\Wishlist\Controller\Index; +use Magento\Checkout\Helper\Cart as CartHelper; +use Magento\Checkout\Model\Cart as CheckoutCart; +use Magento\Customer\Model\Session; use Magento\Framework\App\Action; +use Magento\Framework\Escaper; use Magento\Framework\Exception\NotFoundException; use Magento\Framework\Exception\LocalizedException; use Magento\Wishlist\Controller\IndexInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Wishlist\Controller\WishlistProviderInterface; +use Magento\Wishlist\Helper\Data as WishlistHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Fromcart extends Action\Action implements IndexInterface { /** - * @var \Magento\Wishlist\Controller\WishlistProviderInterface + * @var WishlistProviderInterface */ protected $wishlistProvider; + /** + * @var WishlistHelper + */ + protected $wishlistHelper; + + /** + * @var CheckoutCart + */ + protected $cart; + + /** + * @var CartHelper + */ + protected $cartHelper; + + /** + * @var Escaper + */ + protected $escaper; + /** * @param Action\Context $context - * @param \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider + * @param WishlistProviderInterface $wishlistProvider + * @param WishlistHelper $wishlistHelper + * @param CheckoutCart $cart + * @param CartHelper $cartHelper + * @param Escaper $escaper */ public function __construct( Action\Context $context, - \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider + WishlistProviderInterface $wishlistProvider, + WishlistHelper $wishlistHelper, + CheckoutCart $cart, + CartHelper $cartHelper, + Escaper $escaper ) { $this->wishlistProvider = $wishlistProvider; + $this->wishlistHelper = $wishlistHelper; + $this->cart = $cart; + $this->cartHelper = $cartHelper; + $this->escaper = $escaper; parent::__construct($context); } @@ -43,14 +84,10 @@ class Fromcart extends Action\Action implements IndexInterface if (!$wishlist) { throw new NotFoundException(__('Page not found.')); } - $itemId = (int)$this->getRequest()->getParam('item'); - - /* @var \Magento\Checkout\Model\Cart $cart */ - $cart = $this->_objectManager->get('Magento\Checkout\Model\Cart'); - $session = $this->_objectManager->get('Magento\Checkout\Model\Session'); try { - $item = $cart->getQuote()->getItemById($itemId); + $itemId = (int)$this->getRequest()->getParam('item'); + $item = $this->cart->getQuote()->getItemById($itemId); if (!$item) { throw new LocalizedException( __('The requested cart item doesn\'t exist.') @@ -59,27 +96,26 @@ class Fromcart extends Action\Action implements IndexInterface $productId = $item->getProductId(); $buyRequest = $item->getBuyRequest(); - $wishlist->addNewItem($productId, $buyRequest); - $productIds[] = $productId; - $cart->getQuote()->removeItem($itemId); - $cart->save(); - $this->_objectManager->get('Magento\Wishlist\Helper\Data')->calculate(); - $productName = $this->_objectManager->get('Magento\Framework\Escaper') - ->escapeHtml($item->getProduct()->getName()); - $wishlistName = $this->_objectManager->get('Magento\Framework\Escaper') - ->escapeHtml($wishlist->getName()); - $this->messageManager->addSuccess(__("%1 has been moved to wish list %2", $productName, $wishlistName)); + $this->cart->getQuote()->removeItem($itemId); + $this->cart->save(); + + $this->wishlistHelper->calculate(); $wishlist->save(); + + $this->messageManager->addSuccessMessage(__( + "%1 has been moved to your wish list.", + $this->escaper->escapeHtml($item->getProduct()->getName()) + )); } catch (LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('We can\'t move the item to the wish list.')); + $this->messageManager->addExceptionMessage($e, __('We can\'t move the item to the wish list.')); } /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - return $resultRedirect->setUrl($this->_objectManager->get('Magento\Checkout\Helper\Cart')->getCartUrl()); + return $resultRedirect->setUrl($this->cartHelper->getCartUrl()); } } diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/FromcartTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/FromcartTest.php new file mode 100644 index 0000000000000000000000000000000000000000..58109d6dc3d256607c2b1ba33b3101d50ede0944 --- /dev/null +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/FromcartTest.php @@ -0,0 +1,362 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Wishlist\Test\Unit\Controller\Index; + +use Magento\Checkout\Helper\Cart as CartHelper; +use Magento\Checkout\Model\Cart as CheckoutCart; +use Magento\Framework\App\Action\Context; +use Magento\Framework\App\Request\Http; +use Magento\Framework\Controller\Result\Redirect as ResultRedirect; +use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\DataObject; +use Magento\Framework\Escaper; +use Magento\Framework\Message\Manager as MessageManager; +use Magento\Wishlist\Controller\Index\Fromcart; +use Magento\Wishlist\Controller\WishlistProviderInterface; +use Magento\Wishlist\Helper\Data as WishlistHelper; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class FromcartTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Fromcart + */ + protected $controller; + + /** + * @var Context | \PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + /** + * @var WishlistProviderInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $wishlistProvider; + + /** + * @var WishlistHelper | \PHPUnit_Framework_MockObject_MockObject + */ + protected $wishlistHelper; + + /** + * @var CheckoutCart | \PHPUnit_Framework_MockObject_MockObject + */ + protected $cart; + + /** + * @var CartHelper | \PHPUnit_Framework_MockObject_MockObject + */ + protected $cartHelper; + + /** + * @var Escaper | \PHPUnit_Framework_MockObject_MockObject + */ + protected $escaper; + + /** + * @var Http | \PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var MessageManager | \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManager; + + /** + * @var ResultFactory | \PHPUnit_Framework_MockObject_MockObject + */ + protected $resultFactory; + + /** + * @var ResultRedirect | \PHPUnit_Framework_MockObject_MockObject + */ + protected $resultRedirect; + + protected function setUp() + { + $this->prepareContext(); + + $this->wishlistProvider = $this->getMockBuilder('Magento\Wishlist\Controller\WishlistProviderInterface') + ->getMockForAbstractClass(); + + $this->wishlistHelper = $this->getMockBuilder('Magento\Wishlist\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + + $this->cart = $this->getMockBuilder('Magento\Checkout\Model\Cart') + ->disableOriginalConstructor() + ->getMock(); + + $this->cartHelper = $this->getMockBuilder('Magento\Checkout\Helper\Cart') + ->disableOriginalConstructor() + ->getMock(); + + $this->escaper = $this->getMockBuilder('Magento\Framework\Escaper') + ->disableOriginalConstructor() + ->getMock(); + + $this->controller = new Fromcart( + $this->context, + $this->wishlistProvider, + $this->wishlistHelper, + $this->cart, + $this->cartHelper, + $this->escaper + ); + } + + /** + * @expectedException \Magento\Framework\Exception\NotFoundException + * @expectedExceptionMessage Page not found + */ + public function testExecutePageNotFound() + { + $this->wishlistProvider->expects($this->once()) + ->method('getWishlist') + ->willReturn(null); + + $this->controller->execute(); + } + + public function testExecuteNoCartItem() + { + $itemId = 1; + $cartUrl = 'cart_url'; + + $wishlistMock = $this->getMockBuilder('Magento\Wishlist\Model\Wishlist') + ->disableOriginalConstructor() + ->getMock(); + + $this->wishlistProvider->expects($this->once()) + ->method('getWishlist') + ->willReturn($wishlistMock); + + $this->request->expects($this->once()) + ->method('getParam') + ->with('item') + ->willReturn($itemId); + + $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + ->disableOriginalConstructor() + ->getMock(); + + $quoteMock->expects($this->once()) + ->method('getItemById') + ->with($itemId) + ->willReturn(null); + + $this->cart->expects($this->once()) + ->method('getQuote') + ->willReturn($quoteMock); + + $this->cartHelper->expects($this->once()) + ->method('getCartUrl') + ->willReturn($cartUrl); + + $this->messageManager->expects($this->once()) + ->method('addErrorMessage') + ->with(__('The requested cart item doesn\'t exist.')) + ->willReturnSelf(); + + $this->resultRedirect->expects($this->once()) + ->method('setUrl') + ->with($cartUrl) + ->willReturnSelf(); + + $this->assertSame($this->resultRedirect, $this->controller->execute()); + } + + public function testExecute() + { + $itemId = 1; + $cartUrl = 'cart_url'; + $productId = 1; + $productName = 'product_name'; + + $dataObjectMock = $this->getMockBuilder('Magento\Framework\DataObject') + ->disableOriginalConstructor() + ->getMock(); + + $wishlistMock = $this->getMockBuilder('Magento\Wishlist\Model\Wishlist') + ->disableOriginalConstructor() + ->getMock(); + $wishlistMock->expects($this->once()) + ->method('addNewItem') + ->with($productId, $dataObjectMock) + ->willReturnSelf(); + $wishlistMock->expects($this->once()) + ->method('save') + ->willReturnSelf(); + + $this->wishlistProvider->expects($this->once()) + ->method('getWishlist') + ->willReturn($wishlistMock); + + $this->wishlistHelper->expects($this->once()) + ->method('calculate') + ->willReturnSelf(); + + $this->request->expects($this->once()) + ->method('getParam') + ->with('item') + ->willReturn($itemId); + + $quoteMock = $this->createQuoteMock($productId, $productName, $dataObjectMock, $itemId); + + $this->cart->expects($this->exactly(2)) + ->method('getQuote') + ->willReturn($quoteMock); + $this->cart->expects($this->once()) + ->method('save') + ->willReturnSelf(); + + $this->cartHelper->expects($this->once()) + ->method('getCartUrl') + ->willReturn($cartUrl); + + $this->escaper->expects($this->once()) + ->method('escapeHtml') + ->with($productName) + ->willReturn($productName); + + $this->messageManager->expects($this->once()) + ->method('addSuccessMessage') + ->with(__("%1 has been moved to your wish list.", $productName)) + ->willReturnSelf(); + + $this->resultRedirect->expects($this->once()) + ->method('setUrl') + ->with($cartUrl) + ->willReturnSelf(); + + $this->assertSame($this->resultRedirect, $this->controller->execute()); + } + + public function testExecuteWithException() + { + $cartUrl = 'cart_url'; + $exceptionMessage = 'exception_message'; + $exception = new \Exception($exceptionMessage); + + $wishlistMock = $this->getMockBuilder('Magento\Wishlist\Model\Wishlist') + ->disableOriginalConstructor() + ->getMock(); + + $this->wishlistProvider->expects($this->once()) + ->method('getWishlist') + ->willReturn($wishlistMock); + + $this->request->expects($this->once()) + ->method('getParam') + ->with('item') + ->willThrowException($exception); + + $this->messageManager->expects($this->once()) + ->method('addExceptionMessage') + ->with($exception, __('We can\'t move the item to the wish list.')) + ->willReturnSelf(); + + $this->cartHelper->expects($this->once()) + ->method('getCartUrl') + ->willReturn($cartUrl); + + $this->resultRedirect->expects($this->once()) + ->method('setUrl') + ->with($cartUrl) + ->willReturnSelf(); + + $this->assertSame($this->resultRedirect, $this->controller->execute()); + } + + protected function prepareContext() + { + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->getMock(); + + $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->getMock(); + + $this->resultRedirect = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + ->disableOriginalConstructor() + ->getMock(); + + $this->resultFactory = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->resultFactory->expects($this->any()) + ->method('create') + ->with(ResultFactory::TYPE_REDIRECT) + ->willReturn($this->resultRedirect); + + $this->context = $this->getMockBuilder('Magento\Framework\App\Action\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->context->expects($this->any()) + ->method('getRequest') + ->willReturn($this->request); + $this->context->expects($this->any()) + ->method('getMessageManager') + ->willReturn($this->messageManager); + $this->context->expects($this->any()) + ->method('getResultFactory') + ->willReturn($this->resultFactory); + } + + /** + * @param int $productId + * @param string $productName + * @param DataObject $dataObjectMock + * @param int $itemId + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function createQuoteMock($productId, $productName, $dataObjectMock, $itemId) + { + $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + $productMock->expects($this->once()) + ->method('getName') + ->willReturn($productName); + + $quoteItemMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods([ + 'getProductId', + 'getBuyRequest', + 'getProduct', + ]) + ->getMock(); + $quoteItemMock->expects($this->once()) + ->method('getProductId') + ->willReturn($productId); + $quoteItemMock->expects($this->once()) + ->method('getBuyRequest') + ->willReturn($dataObjectMock); + $quoteItemMock->expects($this->once()) + ->method('getProduct') + ->willReturn($productMock); + + $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + ->disableOriginalConstructor() + ->getMock(); + $quoteMock->expects($this->once()) + ->method('getItemById') + ->with($itemId) + ->willReturn($quoteItemMock); + $quoteMock->expects($this->once()) + ->method('removeItem') + ->with($itemId) + ->willReturnSelf(); + + return $quoteMock; + } +} diff --git a/app/code/Magento/Wishlist/i18n/de_DE.csv b/app/code/Magento/Wishlist/i18n/de_DE.csv index 7d170fb8ee8f5702e701cfb9e889fbfdd62e6c8b..23cf75b5751db36f4440279d19055fc0a609f088 100644 --- a/app/code/Magento/Wishlist/i18n/de_DE.csv +++ b/app/code/Magento/Wishlist/i18n/de_DE.csv @@ -65,7 +65,7 @@ Message,Nachricht "An error occurred while deleting the item from wish list.","An error occurred while deleting the item from wish list." "Cannot add item to shopping cart","Kann Objekt nicht zum Warenkorb hinzufügen" "The requested cart item doesn't exist.","The requested cart item doesn't exist." -"%1 has been moved to wish list %2","%1 has been moved to wish list %2" +"%1 has been moved to your wish list.","%1 has been moved to your wish list." "We can't move the item to the wish list.","We can't move the item to the wish list." "Message length must not exceed %1 symbols","Message length must not exceed %1 symbols" "Email address can't be empty.","E-Mail-Adressfeld darf nicht leer sein." diff --git a/app/code/Magento/Wishlist/i18n/en_US.csv b/app/code/Magento/Wishlist/i18n/en_US.csv index 032419a9e0618024eb892ffb4f2478c25bcb0e12..5bbcbde21a8085f640b14c6d1bc47cde46362289 100644 --- a/app/code/Magento/Wishlist/i18n/en_US.csv +++ b/app/code/Magento/Wishlist/i18n/en_US.csv @@ -65,7 +65,7 @@ Message,Message "An error occurred while deleting the item from wish list.","An error occurred while deleting the item from wish list." "Cannot add item to shopping cart","Cannot add item to shopping cart" "The requested cart item doesn't exist.","The requested cart item doesn't exist." -"%1 has been moved to wish list %2","%1 has been moved to wish list %2" +"%1 has been moved to your wish list.","%1 has been moved to your wish list." "We can't move the item to the wish list.","We can't move the item to the wish list." "Message length must not exceed %1 symbols","Message length must not exceed %1 symbols" "Email address can't be empty.","Email address can't be empty." diff --git a/app/code/Magento/Wishlist/i18n/es_ES.csv b/app/code/Magento/Wishlist/i18n/es_ES.csv index 0c3d383c19eb5b00384fb9278a46f6c6a864dc28..e811032517e7ce9b5a7a5f9c2488c0f4b16eec7f 100644 --- a/app/code/Magento/Wishlist/i18n/es_ES.csv +++ b/app/code/Magento/Wishlist/i18n/es_ES.csv @@ -65,7 +65,7 @@ Message,Mensaje "An error occurred while deleting the item from wish list.","An error occurred while deleting the item from wish list." "Cannot add item to shopping cart","No se pudo añadir el artÃculo al carrito de compra" "The requested cart item doesn't exist.","The requested cart item doesn't exist." -"%1 has been moved to wish list %2","%1 has been moved to wish list %2" +"%1 has been moved to your wish list.","%1 has been moved to your wish list." "We can't move the item to the wish list.","We can't move the item to the wish list." "Message length must not exceed %1 symbols","Message length must not exceed %1 symbols" "Email address can't be empty.","El campo Dirección de correo electrónico no puede estar vacÃo." diff --git a/app/code/Magento/Wishlist/i18n/fr_FR.csv b/app/code/Magento/Wishlist/i18n/fr_FR.csv index 393bd7ad11c2455ddb548f10a17cb532ea4c10d1..23d53490578b6701525ef258b068e6a48e738872 100644 --- a/app/code/Magento/Wishlist/i18n/fr_FR.csv +++ b/app/code/Magento/Wishlist/i18n/fr_FR.csv @@ -65,7 +65,7 @@ Message,Message "An error occurred while deleting the item from wish list.","An error occurred while deleting the item from wish list." "Cannot add item to shopping cart","Ne peut ajouter l'article au caddy" "The requested cart item doesn't exist.","The requested cart item doesn't exist." -"%1 has been moved to wish list %2","%1 has been moved to wish list %2" +"%1 has been moved to your wish list.","%1 has been moved to your wish list." "We can't move the item to the wish list.","We can't move the item to the wish list." "Message length must not exceed %1 symbols","Message length must not exceed %1 symbols" "Email address can't be empty.","Adresse courriel ne peut être vide." diff --git a/app/code/Magento/Wishlist/i18n/nl_NL.csv b/app/code/Magento/Wishlist/i18n/nl_NL.csv index 8742b17c50cbdcfb6999186862a5f55e8c634d66..d72bfd19d242d5ee4c25146204223a4ca39add91 100644 --- a/app/code/Magento/Wishlist/i18n/nl_NL.csv +++ b/app/code/Magento/Wishlist/i18n/nl_NL.csv @@ -65,7 +65,7 @@ Message,Boodschap "An error occurred while deleting the item from wish list.","An error occurred while deleting the item from wish list." "Cannot add item to shopping cart","Kan het item niet toevoegen aan het winkelwagentje" "The requested cart item doesn't exist.","The requested cart item doesn't exist." -"%1 has been moved to wish list %2","%1 has been moved to wish list %2" +"%1 has been moved to your wish list.","%1 has been moved to your wish list." "We can't move the item to the wish list.","We can't move the item to the wish list." "Message length must not exceed %1 symbols","Message length must not exceed %1 symbols" "Email address can't be empty.","E-mailadres mag niet leeg zijn." diff --git a/app/code/Magento/Wishlist/i18n/pt_BR.csv b/app/code/Magento/Wishlist/i18n/pt_BR.csv index 21f4da865aca77be54eddc52c8e5761342522e44..4c130bd89b6a90c0799dfcd24893f0dd6e308cb3 100644 --- a/app/code/Magento/Wishlist/i18n/pt_BR.csv +++ b/app/code/Magento/Wishlist/i18n/pt_BR.csv @@ -65,7 +65,7 @@ Message,Mensagem "An error occurred while deleting the item from wish list.","An error occurred while deleting the item from wish list." "Cannot add item to shopping cart","Não é possÃvel adicionar item ao carrinho de compras" "The requested cart item doesn't exist.","The requested cart item doesn't exist." -"%1 has been moved to wish list %2","%1 has been moved to wish list %2" +"%1 has been moved to your wish list.","%1 has been moved to your wish list." "We can't move the item to the wish list.","We can't move the item to the wish list." "Message length must not exceed %1 symbols","Message length must not exceed %1 symbols" "Email address can't be empty.","O endereço de email não pode ficar vazio." diff --git a/app/code/Magento/Wishlist/i18n/zh_CN.csv b/app/code/Magento/Wishlist/i18n/zh_CN.csv index 5ad8d2e6066973040f76226ddae69ca8b2733964..12caf10849a5a806dac0e7ee9274bba219e259a5 100644 --- a/app/code/Magento/Wishlist/i18n/zh_CN.csv +++ b/app/code/Magento/Wishlist/i18n/zh_CN.csv @@ -65,7 +65,7 @@ Message,ä¿¡æ¯ "An error occurred while deleting the item from wish list.","An error occurred while deleting the item from wish list." "Cannot add item to shopping cart",æ— æ³•æ·»åŠ å†…å®¹åˆ°è´ç‰©è½¦ "The requested cart item doesn't exist.","The requested cart item doesn't exist." -"%1 has been moved to wish list %2","%1 has been moved to wish list %2" +"%1 has been moved to your wish list.","%1 has been moved to your wish list." "We can't move the item to the wish list.","We can't move the item to the wish list." "Message length must not exceed %1 symbols","Message length must not exceed %1 symbols" "Email address can't be empty.",邮件地å€ä¸èƒ½ä¸ºç©ºã€‚ diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/GridFilteringTest.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/GridFilteringTest.xml index 6c34dc0371fc4f64f4e88ddaa3343de93c18b63e..ebc2492058a5d8b79955b24be3fe7cab5268da46 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/GridFilteringTest.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/GridFilteringTest.xml @@ -15,7 +15,7 @@ <data name="filters" xsi:type="array"> <item name="0" xsi:type="array"> <item name="name" xsi:type="string">:lastname</item> - <item name="entity_id_from" xsi:type="string">:id</item> + <item name="email" xsi:type="string">:email</item> </item> <item name="1" xsi:type="array"> <item name="email" xsi:type="string">:email</item> diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertMoveProductToWishlistSuccessMessage.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertMoveProductToWishlistSuccessMessage.php index 29ef84e8349a6a0f2a998a011db4a6a95a525c40..88a588fe6309f0f7aa70c7bf380598a8effad1ed 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertMoveProductToWishlistSuccessMessage.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertMoveProductToWishlistSuccessMessage.php @@ -19,7 +19,7 @@ class AssertMoveProductToWishlistSuccessMessage extends AbstractConstraint /** * Success add message */ - const SUCCESS_MESSAGE = "%s has been moved to wish list Wish List"; + const SUCCESS_MESSAGE = "%s has been moved to your wish list."; /** * Assert that success message appears on My Wish List page after moving product to wishlist. diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListTest.php index 078756484d66e89349eb59dde03d619f83f71bd8..84d96284b9945e52a6db58b749968bdd7fe7d4d2 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListTest.php @@ -9,6 +9,7 @@ namespace Magento\Catalog\Block\Product; * Test class for \Magento\Catalog\Block\Product\List. * * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoAppArea frontend */ class ListTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/integration/testsuite/Magento/Config/Model/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Config/Model/ConfigTest.php index 623db01dd154451011068f6e09d90c1097e0c6e0..09ceb5584c6b7398142d673c234958b8ac2f3381 100644 --- a/dev/tests/integration/testsuite/Magento/Config/Model/ConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Config/Model/ConfigTest.php @@ -36,16 +36,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase /** @var $_configDataObject \Magento\Config\Model\Config */ $_configDataObject = Bootstrap::getObjectManager()->create('Magento\Config\Model\Config'); - $_configDataObject->setSection('dev')->setWebsite('base'); - - $_configData = $_configDataObject->load(); - $this->assertArrayHasKey('dev/debug/template_hints', $_configData); + $_configData = $_configDataObject->setSection('dev')->load(); + $this->assertArrayHasKey('dev/debug/template_hints_admin', $_configData); $this->assertArrayHasKey('dev/debug/template_hints_blocks', $_configData); $_configDataObject = Bootstrap::getObjectManager()->create('Magento\Config\Model\Config'); - $_configDataObject->setSection('dev'); - $_configData = $_configDataObject->load(); - $this->assertArrayNotHasKey('dev/debug/template_hints', $_configData); + $_configData = $_configDataObject->setSection('dev')->setWebsite('base')->load(); + $this->assertArrayNotHasKey('dev/debug/template_hints_admin', $_configData); $this->assertArrayNotHasKey('dev/debug/template_hints_blocks', $_configData); } diff --git a/dev/tests/integration/testsuite/Magento/Config/Model/_files/config_groups.php b/dev/tests/integration/testsuite/Magento/Config/Model/_files/config_groups.php index 7b2c8f02ba2759a2db8405a827508bba939d4dcd..6dca3bdf2658216af2bae0b26e6772f5070bfb95 100644 --- a/dev/tests/integration/testsuite/Magento/Config/Model/_files/config_groups.php +++ b/dev/tests/integration/testsuite/Magento/Config/Model/_files/config_groups.php @@ -10,7 +10,7 @@ return [ 'restrict' => ['fields' => ['allow_ips' => ['value' => '']]], 'debug' => [ 'fields' => [ - 'template_hints' => ['value' => '0'], + 'template_hints_admin' => ['value' => '0'], 'template_hints_blocks' => ['value' => '0'], ], ], diff --git a/dev/tests/integration/testsuite/Magento/Config/Model/_files/config_section.php b/dev/tests/integration/testsuite/Magento/Config/Model/_files/config_section.php index c13e1e3e1b81260bda69f5aaeb86d454f2e118a8..06eb5f2789efb5006880517cbc374b9c5ec74e9d 100644 --- a/dev/tests/integration/testsuite/Magento/Config/Model/_files/config_section.php +++ b/dev/tests/integration/testsuite/Magento/Config/Model/_files/config_section.php @@ -17,7 +17,7 @@ return [ ], 'debug' => [ 'fields' => [ - 'template_hints' => ['value' => '1'], + 'template_hints_storefront' => ['value' => '1'], 'template_hints_blocks' => ['value' => '0'], ], ], @@ -28,7 +28,10 @@ return [ 'dev/log/file' => 'fileName.log', 'dev/log/exception_file' => 'exceptionFileName.log', ], - 'dev/debug' => ['dev/debug/template_hints' => '1', 'dev/debug/template_hints_blocks' => '0'], + 'dev/debug' => [ + 'dev/debug/template_hints_storefront' => '1', + 'dev/debug/template_hints_blocks' => '0', + ], ], ] ]; diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/GenderTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/GenderTest.php index c612baf883b32e7b8a9216316473f80b630cb179..13c3a9e0c26481324defc4d7191329ccdbd25d26 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/GenderTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/GenderTest.php @@ -7,6 +7,9 @@ namespace Magento\Customer\Block\Widget; use Magento\TestFramework\Helper\Bootstrap; +/** + * @magentoAppArea frontend + */ class GenderTest extends \PHPUnit_Framework_TestCase { /** @var Gender */ diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/NameTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/NameTest.php index e5aea1f1e6d9a984cffc9c8e00eecdf28b1e9a9a..fa5fb5cfbc5b3d34ce45fc0dc5ef09343443a415 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/NameTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/NameTest.php @@ -9,6 +9,7 @@ use Magento\TestFramework\Helper\Bootstrap; /** * Test \Magento\Customer\Block\Widget\Name + * @magentoAppArea frontend */ class NameTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/TotalsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/TotalsTest.php index 14d39817dec02dc1aa4c1304d2548827a2bf92ba..35e1a7dfc8d21e43fc9eb90dbca9afd8e02dd386 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/TotalsTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/TotalsTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Sales\Block\Order; +/** + * @magentoAppArea frontend + */ class TotalsTest extends \PHPUnit_Framework_TestCase { public function testToHtmlChildrenInitialized() diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php index 1014c56087499dc1cacb3fbb86c3edbac5df6fd7..1588c0a838047247e301f0aefc80595538e271a9 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Sales\Model\Order\Email\Sender; +/** + * @magentoAppArea frontend + */ class ShipmentSenderTest extends \PHPUnit_Framework_TestCase { /** diff --git a/dev/tests/integration/testsuite/Magento/Theme/Block/Html/BreadcrumbsTest.php b/dev/tests/integration/testsuite/Magento/Theme/Block/Html/BreadcrumbsTest.php index 594369188dd1ab65a78ac26f6a6b340adff0be24..8a315025436d82696a8bd1497415d1f2850dd053 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Block/Html/BreadcrumbsTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Block/Html/BreadcrumbsTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Theme\Block\Html; +/** + * @magentoAppArea frontend + */ class BreadcrumbsTest extends \PHPUnit_Framework_TestCase { /** diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php index 353b7bef2f399d008fcee3a39a21802e0b9cb333..fa4ee8e1c8825fe8f62bf1d774f654f9aa7139b5 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php @@ -168,7 +168,6 @@ return [ [ 'XML_PATH_DEBUG_TEMPLATE_HINTS', 'Magento\Framework\View\Element\Template', - 'Magento\Core\Model\TemplateEngine\Plugin::XML_PATH_DEBUG_TEMPLATE_HINTS', ], [ 'XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS', diff --git a/lib/internal/Magento/Framework/DB/Sql/ConcatExpression.php b/lib/internal/Magento/Framework/DB/Sql/ConcatExpression.php index b9d9ffb4a48ae07c1a1ae5645c2bd753d8109273..09c1d2a36aa4582b714b32d078ef5732cda8a6aa 100644 --- a/lib/internal/Magento/Framework/DB/Sql/ConcatExpression.php +++ b/lib/internal/Magento/Framework/DB/Sql/ConcatExpression.php @@ -45,7 +45,7 @@ class ConcatExpression extends \Zend_Db_Expr /** * Returns SQL expression - * TRIM(CONCAT_WS(separator, IFNULL(str1,''), IFNULL(str2,''), ...)) + * TRIM(CONCAT_WS(separator, IF(str1 <> '', str1, NULL), IF(str2 <> '', str2, NULL) ...)) * * @return string */ @@ -61,7 +61,7 @@ class ConcatExpression extends \Zend_Db_Expr . (isset($part['columnName']) ? $part['columnName'] : $key) ); } - $columns[] = $this->adapter->getIfNullSql($column, "''"); + $columns[] = $this->adapter->getCheckSql($column . " <> ''", $column, 'NULL'); } return sprintf( 'TRIM(%s)', diff --git a/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php b/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php index 0b1c7f2cd5b05d20d37b951012650d3044cf7c65..b461ff19c638047aa68717fbf24060e0e51c8d4b 100644 --- a/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php +++ b/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php @@ -10,6 +10,7 @@ use Magento\Framework\View\Asset; use Magento\Framework\Filesystem; use Magento\Framework\View\Asset\Bundle; use Magento\Framework\View\Asset\LocalInterface; +use Magento\Framework\App\Filesystem\DirectoryList; /** * BundleService model @@ -126,7 +127,7 @@ class Manager /** @var $asset LocalInterface */ $filePathInfo = $this->splitPath($filePath); if ($filePathInfo && $this->compareModules($filePathInfo, $asset)) { - return $asset->getFilePath() == $filePathInfo['excludedPath']; + return $asset->getSourceFile() == $filePathInfo['excludedPath']; } return false; } @@ -190,33 +191,21 @@ class Manager protected function isAssetMinification(LocalInterface $asset) { $sourceFile = $asset->getSourceFile(); - if (in_array($asset->getFilePath(), $this->excluded)) { + $extension = $asset->getContentType(); + if (in_array($sourceFile, $this->excluded)) { return false; } - if ($this->minification->isEnabled($asset->getContentType())) { - if (strpos($sourceFile, '.min.') !== false) { - $this->excluded[] = str_replace('.min.', '', $sourceFile); - return true; - } - - $extension = $asset->getContentType(); - $minAbsolutePath = str_replace($extension, "min.{$extension}", $sourceFile); - if (file_exists($minAbsolutePath)) { - return false; - } - - return true; - } - - if (strpos($sourceFile, '.min.') !== false) { - $absolutePath = str_replace('.min.', '', $asset->getFilePath()); - if (file_exists($absolutePath)) { + if (strpos($sourceFile, '.min.') === false) { + $info = pathinfo($asset->getPath()); + $assetMinifiedPath = $info['dirname'] . '/' . $info['filename'] . '.min.' . $info['extension']; + if ($this->filesystem->getDirectoryRead(DirectoryList::APP)->isExist($assetMinifiedPath)) { + $this->excluded[] = $sourceFile; return false; } } else { - $extension = $asset->getContentType(); - $this->excluded[] = str_replace($extension, "min.{$extension}", $asset->getFilePath()); + $this->excluded[] = $this->filesystem->getDirectoryRead(DirectoryList::APP) + ->getAbsolutePath(str_replace(".min.$extension", ".$extension", $asset->getPath())); } return true; diff --git a/lib/internal/Magento/Framework/View/Asset/File.php b/lib/internal/Magento/Framework/View/Asset/File.php index 8354e2aa3d417b93690f41168861b073a5da4633..19a8026f4668d0cbea5502c50fac40bfebd47e53 100644 --- a/lib/internal/Magento/Framework/View/Asset/File.php +++ b/lib/internal/Magento/Framework/View/Asset/File.php @@ -6,8 +6,6 @@ namespace Magento\Framework\View\Asset; -use Magento\Framework\View\Asset\ConfigInterface as AssetConfigInterface; - /** * A locally available static view file asset that can be referred with a file path * diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php index 30d80e64d0ac96796e7c301a42913b19d8f630ed..840ed49c995b67167b3d4f70a88a9a35e6b0eab3 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php @@ -9,7 +9,7 @@ use Magento\Framework\View\Asset\Bundle\Manager; class ManagerTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Framework\View\Asset\Bundle\Manager|\PHPUnit_Framework_MockObject_MockObject */ + /** @var Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $manager; /** @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject */ @@ -91,55 +91,73 @@ class ManagerTest extends \PHPUnit_Framework_TestCase public function testAddAssetWithExcludedFile() { + $dirRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + ->disableOriginalConstructor() + ->getMock(); $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $configView = $this->getMockBuilder('Magento\Framework\Config\View') - ->disableOriginalConstructor() - ->getMock(); + ->setMockClassName('configView') + ->disableOriginalConstructor() + ->getMock(); + $this->asset->expects($this->atLeastOnce()) + ->method('getContext') + ->willReturn($context); $this->asset->expects($this->atLeastOnce()) ->method('getContentType') ->willReturn('js'); - $this->asset->expects($this->once()) - ->method('getSourceFile') - ->willReturn('/source/file'); - $this->asset->expects($this->once()) - ->method('getModule') - ->willReturn(''); $this->asset->expects($this->atLeastOnce()) - ->method('getFilePath') - ->willReturn('file/path.js'); + ->method('getModule') + ->willReturn('Lib'); $this->asset->expects($this->atLeastOnce()) - ->method('getContext') - ->willReturn($context); - $this->bundleConfig - ->expects($this->atLeastOnce()) + ->method('getSourceFile') + ->willReturn('source/file.min.js'); + $this->filesystem->expects($this->once()) + ->method('getDirectoryRead') + ->with(\Magento\Framework\App\Filesystem\DirectoryList::APP) + ->willReturn($dirRead); + $this->bundleConfig->expects($this->atLeastOnce()) ->method('getConfig') ->with($context) ->willReturn($configView); $configView->expects($this->once()) ->method('getExcludedFiles') - ->willReturn(['Lib:' . ':file/path.js']); + ->willReturn(['Lib:' . ':source/file.min.js']); $this->assertFalse($this->manager->addAsset($this->asset)); } public function testAddAssetWithExcludedDirectory() { + $dirRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + ->disableOriginalConstructor() + ->getMock(); $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $configView = $this->getMockBuilder('Magento\Framework\Config\View') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); + $this->filesystem->expects($this->once()) + ->method('getDirectoryRead') + ->with(\Magento\Framework\App\Filesystem\DirectoryList::APP) + ->willReturn($dirRead); + $dirRead->expects($this->once()) + ->method('getAbsolutePath') + ->with('/path/to/file.js') + ->willReturn(true); + $this->asset->expects($this->atLeastOnce()) + ->method('getSourceFile') + ->willReturn('/path/to/source/file.min.js'); $this->asset->expects($this->atLeastOnce()) ->method('getContentType') ->willReturn('js'); $this->asset->expects($this->once()) - ->method('getSourceFile') - ->willReturn('/source/file'); + ->method('getPath') + ->willReturn('/path/to/file.js'); $this->asset->expects($this->atLeastOnce()) ->method('getModule') ->willReturn(''); @@ -149,8 +167,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $this->asset->expects($this->atLeastOnce()) ->method('getContext') ->willReturn($context); - $this->bundleConfig - ->expects($this->atLeastOnce()) + $this->bundleConfig->expects($this->atLeastOnce()) ->method('getConfig') ->with($context) ->willReturn($configView); @@ -166,6 +183,9 @@ class ManagerTest extends \PHPUnit_Framework_TestCase public function testAddAsset() { + $dirRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + ->disableOriginalConstructor() + ->getMock(); $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') ->disableOriginalConstructor() ->getMock(); @@ -173,20 +193,23 @@ class ManagerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $this->filesystem->expects($this->once()) + ->method('getDirectoryRead') + ->with(\Magento\Framework\App\Filesystem\DirectoryList::APP) + ->willReturn($dirRead); + $this->asset->expects($this->atLeastOnce()) + ->method('getSourceFile') + ->willReturn('/path/to/source/file.min.js'); $this->asset->expects($this->atLeastOnce()) ->method('getContentType') ->willReturn('js'); $this->asset->expects($this->once()) - ->method('getSourceFile') - ->willReturn('/source/file'); - $this->asset->expects($this->atLeastOnce()) - ->method('getFilePath') - ->willReturn('file/path.js'); + ->method('getPath') + ->willReturn('/path/to/file.js'); $this->asset->expects($this->atLeastOnce()) ->method('getContext') ->willReturn($context); - $this->bundleConfig - ->expects($this->atLeastOnce()) + $this->bundleConfig->expects($this->atLeastOnce()) ->method('getConfig') ->with($context) ->willReturn($configView); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php index 128081901a5c97d0cee7f901429ac1cf6466feb5..8e72abcf4189f80230cd40457d9287df482e553e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php @@ -6,7 +6,7 @@ namespace Magento\Framework\View\Test\Unit\Asset; -use \Magento\Framework\View\Asset\File; +use Magento\Framework\View\Asset\File; class FileTest extends \PHPUnit_Framework_TestCase {