diff --git a/app/code/Magento/Sales/Controller/AbstractController/View.php b/app/code/Magento/Sales/Controller/AbstractController/View.php index ebc5d087cdd833344c01d3b8a1e508835bf518b3..cd851bc94b9d9001a01552dfc047fa1d09453a9f 100644 --- a/app/code/Magento/Sales/Controller/AbstractController/View.php +++ b/app/code/Magento/Sales/Controller/AbstractController/View.php @@ -52,6 +52,7 @@ abstract class View extends Action\Action $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->initMessages(); + /** @var \Magento\Framework\View\Element\Html\Links $navigationBlock */ $navigationBlock = $resultPage->getLayout()->getBlock('customer_account_navigation'); if ($navigationBlock) { $navigationBlock->setActive('sales/order/history'); diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Shared/AllcartTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Shared/AllcartTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fbd2ce5f641ac78949c061f63885d182daaad5c9 --- /dev/null +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Shared/AllcartTest.php @@ -0,0 +1,163 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Wishlist\Test\Unit\Controller\Shared; + +class AllcartTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Wishlist\Controller\Shared\WishlistProvider|\PHPUnit_Framework_MockObject_MockObject + */ + protected $wishlistProvider; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \Magento\Wishlist\Model\ItemCarrier|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemCarrier; + + /** + * @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $response; + + /** + * @var \Magento\Framework\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + protected function setUp() + { + $this->wishlistProvider = $this->getMock( + '\Magento\Wishlist\Controller\Shared\WishlistProvider', + [], + [], + '', + false + ); + $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->itemCarrier = $this->getMock('Magento\Wishlist\Model\ItemCarrier', [], [], '', false); + $this->context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); + $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + } + + protected function prepareContext() + { + $om = $this->getMock('Magento\Framework\App\ObjectManager', [], [], '', false); + $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false); + $url = $this->getMock('Magento\Framework\Url', [], [], '', false); + $actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false); + $redirect = $this->getMock('\Magento\Store\App\Response\Redirect', [], [], '', false); + $view = $this->getMock('Magento\Framework\App\View', [], [], '', false); + $messageManager = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); + + $this->context + ->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($om)); + $this->context + ->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->request)); + $this->context + ->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->response)); + $this->context + ->expects($this->any()) + ->method('getEventManager') + ->will($this->returnValue($eventManager)); + $this->context + ->expects($this->any()) + ->method('getUrl') + ->will($this->returnValue($url)); + $this->context + ->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($actionFlag)); + $this->context + ->expects($this->any()) + ->method('getRedirect') + ->will($this->returnValue($redirect)); + $this->context + ->expects($this->any()) + ->method('getView') + ->will($this->returnValue($view)); + $this->context + ->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($messageManager)); + } + + public function getController() + { + $this->prepareContext(); + return new \Magento\Wishlist\Controller\Shared\Allcart( + $this->context, + $this->wishlistProvider, + $this->itemCarrier + ); + } + + public function testExecuteWithNoWishlist() + { + $this->wishlistProvider->expects($this->once()) + ->method('getWishlist') + ->willReturn(false); + + $this->request + ->expects($this->once()) + ->method('initForward') + ->will($this->returnValue(true)); + $this->request + ->expects($this->once()) + ->method('setActionName') + ->with('noroute') + ->will($this->returnValue(true)); + $this->request + ->expects($this->once()) + ->method('setDispatched') + ->with(false) + ->will($this->returnValue(true)); + + $controller = $this->getController(); + $controller->execute(); + } + + public function testExecuteWithWishlist() + { + $wishlist = $this->getMockBuilder('Magento\Wishlist\Model\Wishlist') + ->disableOriginalConstructor() + ->getMock(); + $this->wishlistProvider->expects($this->once()) + ->method('getWishlist') + ->willReturn($wishlist); + + $this->request + ->expects($this->once()) + ->method('getParam') + ->with('qty') + ->will($this->returnValue(2)); + + $this->itemCarrier + ->expects($this->once()) + ->method('moveAllToCart') + ->with($wishlist, 2) + ->will($this->returnValue('http://redirect-url.com')); + + $this->response + ->expects($this->once()) + ->method('setRedirect') + ->will($this->returnValue('http://redirect-url.com')); + + $controller = $this->getController(); + $controller->execute(); + } +} diff --git a/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php b/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5a4959ba7e961db3e220fb274bc261f932a5de05 --- /dev/null +++ b/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php @@ -0,0 +1,252 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Wishlist\Test\Unit\Helper; + +class RssTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Wishlist\Helper\Rss + */ + protected $model; + + /** + * @var \Magento\Wishlist\Model\WishlistFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $wishlistFactoryMock; + + /** + * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\Url\DecoderInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $urlDecoderMock; + + /** + * @var \Magento\Customer\Api\Data\CustomerInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerFactoryMock; + + /** + * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \Magento\Customer\Api\CustomerRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerRepositoryMock; + + /** + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $moduleManagerMock; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigMock; + + public function setUp() + { + $this->wishlistFactoryMock = $this->getMockBuilder('Magento\Wishlist\Model\WishlistFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + ->getMock(); + + $this->urlDecoderMock = $this->getMockBuilder('Magento\Framework\Url\DecoderInterface') + ->getMock(); + + $this->customerFactoryMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterfaceFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->getMock(); + + $this->customerRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + ->getMock(); + + $this->moduleManagerMock = $this->getMockBuilder('Magento\Framework\Module\Manager') + ->disableOriginalConstructor() + ->getMock(); + + $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->getMock(); + + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->model = $objectManager->getObject( + 'Magento\Wishlist\Helper\Rss', + [ + 'wishlistFactory' => $this->wishlistFactoryMock, + 'httpRequest' => $this->requestMock, + 'urlDecoder' => $this->urlDecoderMock, + 'customerFactory' => $this->customerFactoryMock, + 'customerSession' => $this->customerSessionMock, + 'customerRepository' => $this->customerRepositoryMock, + 'moduleManager' => $this->moduleManagerMock, + 'scopeConfig' => $this->scopeConfigMock, + ] + ); + } + + public function testGetWishlistWithWishlistId() + { + $wishlistId = 1; + + $wishlist = $this->getMockBuilder('Magento\Wishlist\Model\Wishlist') + ->disableOriginalConstructor() + ->getMock(); + $this->wishlistFactoryMock->expects($this->once()) + ->method('create') + ->with([]) + ->willReturn($wishlist); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->with('wishlist_id', null) + ->willReturn($wishlistId); + + $wishlist->expects($this->once()) + ->method('load') + ->with($wishlistId, null) + ->willReturnSelf(); + + $this->assertEquals($wishlist, $this->model->getWishlist()); + // Check that wishlist is cached + $this->assertSame($wishlist, $this->model->getWishlist()); + } + + public function testGetWishlistWithCustomerId() + { + $customerId = 1; + $data = $customerId . ',2'; + + $wishlist = $this->getMockBuilder('Magento\Wishlist\Model\Wishlist') + ->disableOriginalConstructor() + ->getMock(); + $this->wishlistFactoryMock->expects($this->once()) + ->method('create') + ->with([]) + ->willReturn($wishlist); + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('wishlist_id', null) + ->willReturn(''); + + $this->urlDecoderMock->expects($this->any()) + ->method('decode') + ->willReturnArgument(0); + + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('data', null) + ->willReturn($data); + + $this->customerSessionMock->expects($this->once()) + ->method('getCustomerId') + ->willReturn(0); + + $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->customerFactoryMock->expects($this->once()) + ->method('create') + ->with([]) + ->willReturn($customer); + + $this->customerRepositoryMock->expects($this->never()) + ->method('getById'); + + $customer->expects($this->exactly(2)) + ->method('getId') + ->willReturn($customerId); + + $wishlist->expects($this->once()) + ->method('loadByCustomerId') + ->with($customerId, false) + ->willReturnSelf(); + + $this->assertEquals($wishlist, $this->model->getWishlist()); + } + + public function testGetCustomerWithSession() + { + $customerId = 1; + $data = $customerId . ',2'; + + $this->urlDecoderMock->expects($this->any()) + ->method('decode') + ->willReturnArgument(0); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->with('data', null) + ->willReturn($data); + + $this->customerSessionMock->expects($this->once()) + ->method('getCustomerId') + ->willReturn($customerId); + + $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->customerRepositoryMock->expects($this->once()) + ->method('getById') + ->with($customerId) + ->willReturn($customer); + + $this->customerFactoryMock->expects($this->never()) + ->method('create'); + + $this->assertEquals($customer, $this->model->getCustomer()); + // Check that customer is cached + $this->assertSame($customer, $this->model->getCustomer()); + } + + /** + * @param bool $isModuleEnabled + * @param bool $isWishlistActive + * @param bool $result + * @dataProvider dataProviderIsRssAllow + */ + public function testIsRssAllow($isModuleEnabled, $isWishlistActive, $result) + { + $this->moduleManagerMock->expects($this->once()) + ->method('isEnabled') + ->with('Magento_Rss') + ->willReturn($isModuleEnabled); + + $this->scopeConfigMock->expects($this->any()) + ->method('isSetFlag') + ->with('rss/wishlist/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ->willReturn($isWishlistActive); + + $this->assertEquals($result, $this->model->isRssAllow()); + } + + /** + * @return array + */ + public function dataProviderIsRssAllow() + { + return [ + [false, false, false], + [true, false, false], + [false, true, false], + [true, true, true], + ]; + } +} diff --git a/app/code/Magento/Wishlist/i18n/de_DE.csv b/app/code/Magento/Wishlist/i18n/de_DE.csv index 364939cebbb084d7898b300060311b23bf45dab1..7d170fb8ee8f5702e701cfb9e889fbfdd62e6c8b 100644 --- a/app/code/Magento/Wishlist/i18n/de_DE.csv +++ b/app/code/Magento/Wishlist/i18n/de_DE.csv @@ -1,5 +1,5 @@ Back,Zurück -Product,Produkt +Product Name,Produkt Quantity,Quantity Configure,Configure "You added %1 to your shopping cart.","You added %1 to your shopping cart." @@ -101,5 +101,5 @@ Message,Nachricht "My Wish List Link","My Wish List Link" "Display Wish List Summary","Display Wish List Summary" "No Items Found","No Items Found" -"User description","Anwender Beschreibung" +"User Description","Anwender Beschreibung" "Product Details and Comment","Produktangaben und Kommentare" diff --git a/app/code/Magento/Wishlist/i18n/en_US.csv b/app/code/Magento/Wishlist/i18n/en_US.csv index 125f7266ade2bd3d8df8223912d3dc8cd51e02c8..032419a9e0618024eb892ffb4f2478c25bcb0e12 100644 --- a/app/code/Magento/Wishlist/i18n/en_US.csv +++ b/app/code/Magento/Wishlist/i18n/en_US.csv @@ -1,5 +1,5 @@ Back,Back -Product,Product +Product Name,Product Name Quantity,Quantity Configure,Configure "You added %1 to your shopping cart.","You added %1 to your shopping cart." @@ -101,5 +101,5 @@ Message,Message "My Wish List Link","My Wish List Link" "Display Wish List Summary","Display Wish List Summary" "No Items Found","No Items Found" -"User description","User description" +"User Description","User Description" "Product Details and Comment","Product Details and Comment" diff --git a/app/code/Magento/Wishlist/i18n/es_ES.csv b/app/code/Magento/Wishlist/i18n/es_ES.csv index cd8aab6a37915de181661717949dc201d3bf84fa..0c3d383c19eb5b00384fb9278a46f6c6a864dc28 100644 --- a/app/code/Magento/Wishlist/i18n/es_ES.csv +++ b/app/code/Magento/Wishlist/i18n/es_ES.csv @@ -1,5 +1,5 @@ Back,Volver -Product,Producto +Product Name,Producto Quantity,Quantity Configure,Configure "You added %1 to your shopping cart.","You added %1 to your shopping cart." @@ -101,5 +101,5 @@ Message,Mensaje "My Wish List Link","My Wish List Link" "Display Wish List Summary","Display Wish List Summary" "No Items Found","No Items Found" -"User description","Descripción del usuario" +"User Description","Descripción del usuario" "Product Details and Comment","Detalles del producto y comentarios" diff --git a/app/code/Magento/Wishlist/i18n/fr_FR.csv b/app/code/Magento/Wishlist/i18n/fr_FR.csv index 512c6ad4ec38dca4642b48a2142c82c82f112175..393bd7ad11c2455ddb548f10a17cb532ea4c10d1 100644 --- a/app/code/Magento/Wishlist/i18n/fr_FR.csv +++ b/app/code/Magento/Wishlist/i18n/fr_FR.csv @@ -1,5 +1,5 @@ Back,Retour -Product,Produit +Product Name,Produit Quantity,Quantity Configure,Configure "You added %1 to your shopping cart.","You added %1 to your shopping cart." @@ -101,5 +101,5 @@ Message,Message "My Wish List Link","My Wish List Link" "Display Wish List Summary","Display Wish List Summary" "No Items Found","No Items Found" -"User description","Description utilisateur" +"User Description","Description utilisateur" "Product Details and Comment","Détails et commentaires sur le produit" diff --git a/app/code/Magento/Wishlist/i18n/nl_NL.csv b/app/code/Magento/Wishlist/i18n/nl_NL.csv index 9a25398b7cdadff32bdf1964fd0730304487edc4..8742b17c50cbdcfb6999186862a5f55e8c634d66 100644 --- a/app/code/Magento/Wishlist/i18n/nl_NL.csv +++ b/app/code/Magento/Wishlist/i18n/nl_NL.csv @@ -1,5 +1,5 @@ Back,Terug -Product,Product +Product Name,Product Quantity,Quantity Configure,Configure "You added %1 to your shopping cart.","You added %1 to your shopping cart." @@ -101,5 +101,5 @@ Message,Boodschap "My Wish List Link","My Wish List Link" "Display Wish List Summary","Display Wish List Summary" "No Items Found","No Items Found" -"User description","Gebruikers beschrijving" +"User Description","Gebruikers beschrijving" "Product Details and Comment","Product Details en het Commentaar" diff --git a/app/code/Magento/Wishlist/i18n/pt_BR.csv b/app/code/Magento/Wishlist/i18n/pt_BR.csv index 9e297438a2bcf5cd7e22a01ca82fd6f2e093fa91..21f4da865aca77be54eddc52c8e5761342522e44 100644 --- a/app/code/Magento/Wishlist/i18n/pt_BR.csv +++ b/app/code/Magento/Wishlist/i18n/pt_BR.csv @@ -1,5 +1,5 @@ Back,Voltar -Product,Produto +Product Name,Produto Quantity,Quant. Configure,Configure "You added %1 to your shopping cart.","You added %1 to your shopping cart." @@ -101,5 +101,5 @@ Message,Mensagem "My Wish List Link","My Wish List Link" "Display Wish List Summary","Display Wish List Summary" "No Items Found","No Items Found" -"User description","Descrição do usuário" +"User Description","Descrição do usuário" "Product Details and Comment","Detalhes de produto e comentários" diff --git a/app/code/Magento/Wishlist/i18n/zh_CN.csv b/app/code/Magento/Wishlist/i18n/zh_CN.csv index 9c0338dae00531b3e39f990261d1e320b326d29b..5ad8d2e6066973040f76226ddae69ca8b2733964 100644 --- a/app/code/Magento/Wishlist/i18n/zh_CN.csv +++ b/app/code/Magento/Wishlist/i18n/zh_CN.csv @@ -1,5 +1,5 @@ Back,返回 -Product,äº§å“ +Product Name,äº§å“ Quantity,Quantity Configure,Configure "You added %1 to your shopping cart.","You added %1 to your shopping cart." @@ -101,5 +101,5 @@ Message,ä¿¡æ¯ "My Wish List Link","My Wish List Link" "Display Wish List Summary","Display Wish List Summary" "No Items Found","No Items Found" -"User description",用户æè¿° +"User Description",用户æè¿° "Product Details and Comment",产å“详情与评论 diff --git a/app/code/Magento/Wishlist/view/adminhtml/layout/customer_index_wishlist.xml b/app/code/Magento/Wishlist/view/adminhtml/layout/customer_index_wishlist.xml index 9f4c0cc8513679c3f977fd8e4f83f8249d08a2a4..599991c00bccd6551091ddd1aae37db7e45f2971 100644 --- a/app/code/Magento/Wishlist/view/adminhtml/layout/customer_index_wishlist.xml +++ b/app/code/Magento/Wishlist/view/adminhtml/layout/customer_index_wishlist.xml @@ -32,7 +32,7 @@ </arguments> <block class="Magento\Backend\Block\Widget\Grid\Column" as="product_name"> <arguments> - <argument name="header" xsi:type="string" translate="true">Product</argument> + <argument name="header" xsi:type="string" translate="true">Product Name</argument> <argument name="id" xsi:type="string">product_name</argument> <argument name="index" xsi:type="string">product_name</argument> <argument name="filter" xsi:type="string">Magento\Wishlist\Block\Adminhtml\Widget\Grid\Column\Filter\Text</argument> @@ -43,7 +43,7 @@ </block> <block class="Magento\Backend\Block\Widget\Grid\Column" as="description"> <arguments> - <argument name="header" xsi:type="string" translate="true">User description</argument> + <argument name="header" xsi:type="string" translate="true">User Description</argument> <argument name="index" xsi:type="string">description</argument> <argument name="id" xsi:type="string">description</argument> <argument name="renderer" xsi:type="string">Magento\Customer\Block\Adminhtml\Edit\Tab\Wishlist\Grid\Renderer\Description</argument> diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/test_default/Magento_Backend/layout_test_grid_handle.xml b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/test_default/Magento_Backend/layout_test_grid_handle.xml index bfc66880afd106048caaa66cb9822118492c0778..aeac3057672ae1af9547fa748fa65cfd0034b0f2 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/test_default/Magento_Backend/layout_test_grid_handle.xml +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/test_default/Magento_Backend/layout_test_grid_handle.xml @@ -21,7 +21,7 @@ </block> <block class="Magento\Backend\Block\Widget\Grid\Column" as="description" output="1"> <arguments> - <header>User description</header> + <header>User Description</header> <index>description</index> <type>text</type> </arguments> diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Helper/RssTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Helper/RssTest.php deleted file mode 100644 index 72264a8ccf60d40c0a06515cdfc02b31e26e3297..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Wishlist/Helper/RssTest.php +++ /dev/null @@ -1,125 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\Wishlist\Helper; - -class RssTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Customer\Model\Session - */ - protected $_customerSession; - - /** - * Core data - * - * @var \Magento\Framework\Url\EncoderInterface - */ - protected $urlEncoder; - - /** - * @var \Magento\Framework\ObjectManagerInterface - */ - protected $_objectManager; - - /** - * @var \Magento\Framework\App\Helper\Context - */ - protected $_contextHelper; - - /** - * @var \Magento\Wishlist\Helper\Rss - */ - protected $_wishlistHelper; - - /** - * @var int - */ - protected $_fixtureCustomerId; - - protected function setUp() - { - $this->_fixtureCustomerId = 1; - - $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_customerSession = $this->_objectManager->create('Magento\Customer\Model\Session'); - $this->urlEncoder = $this->_objectManager->create('Magento\Framework\Url\EncoderInterface'); - - $this->_contextHelper = $this->_objectManager->create('Magento\Framework\App\Helper\Context'); - $request = $this->_contextHelper->getRequest(); - $request->setParam('data', $this->urlEncoder->encode($this->_fixtureCustomerId)); - - $this->_wishlistHelper = $this->_objectManager->create('Magento\Wishlist\Helper\Rss', - [ - 'context' => $this->_contextHelper, - 'customerSession' => $this->_customerSession - ] - ); - - $this->_customerSession->loginById($this->_fixtureCustomerId); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoAppArea frontend - */ - public function testGetCustomer() - { - $expectedCustomer = $this->_customerSession->getCustomerDataObject(); - $actualCustomer = $this->_wishlistHelper->getCustomer(); - $this->assertInstanceOf('Magento\Customer\Api\Data\CustomerInterface', $actualCustomer); - $this->assertEquals((int)$expectedCustomer->getId(), (int)$actualCustomer->getId()); - $this->assertEquals((int)$expectedCustomer->getWebsiteId(), (int)$actualCustomer->getWebsiteId()); - $this->assertEquals((int)$expectedCustomer->getStoreId(), (int)$actualCustomer->getStoreId()); - $this->assertEquals((int)$expectedCustomer->getGroupId(), (int)$actualCustomer->getGroupId()); - $this->assertEquals($expectedCustomer->getCustomAttributes(), $actualCustomer->getCustomAttributes()); - $this->assertEquals($expectedCustomer->getFirstname(), $actualCustomer->getFirstname()); - $this->assertEquals($expectedCustomer->getLastname(), $actualCustomer->getLastname()); - $this->assertEquals($expectedCustomer->getEmail(), $actualCustomer->getEmail()); - $this->assertEquals($expectedCustomer->getEmail(), $actualCustomer->getEmail()); - $this->assertEquals((int)$expectedCustomer->getDefaultBilling(), (int)$actualCustomer->getDefaultBilling()); - $this->assertEquals((int)$expectedCustomer->getDefaultShipping(), (int)$actualCustomer->getDefaultShipping()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_increments.php - * @magentoAppArea frontend - */ - public function testGetWishlistByParam() - { - /** @var \Magento\Wishlist\Model\Wishlist $wishlist */ - $wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist') - ->loadByCustomerId($this->_fixtureCustomerId); - $wishlist->load($wishlist->getId()); - - /** @var \Magento\Framework\App\Request\Http $request */ - $request = $this->_contextHelper->getRequest(); - $request->setParam('wishlist_id', $wishlist->getId()); - - $this->assertEquals($wishlist, $this->_wishlistHelper->getWishlist()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_increments.php - * @magentoAppArea frontend - */ - public function testGetWishlistByCustomerId() - { - /** @var \Magento\Wishlist\Model\Wishlist $wishlist */ - $wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist') - ->loadByCustomerId($this->_fixtureCustomerId); - - /** @var \Magento\Framework\App\Request\Http $request */ - $request = $this->_contextHelper->getRequest(); - $request->setParam('wishlist_id', ''); - - $this->assertEquals($wishlist, $this->_wishlistHelper->getWishlist()); - } -} diff --git a/lib/internal/Magento/Framework/View/Element/Html/Link/Current.php b/lib/internal/Magento/Framework/View/Element/Html/Link/Current.php index 811bea3e4eb33d05aba2d29227fe34e056b345b6..7c971eaf437f13a4b301b4b210affbea20ce35d8 100644 --- a/lib/internal/Magento/Framework/View/Element/Html/Link/Current.php +++ b/lib/internal/Magento/Framework/View/Element/Html/Link/Current.php @@ -110,7 +110,19 @@ class Current extends \Magento\Framework\View\Element\Template $html .= $this->getTitle() ? ' title="' . $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getTitle())) . '"' : ''; - $html .= '>' . $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getLabel())) . '</a></li>'; + $html .= '>'; + + if ($this->getIsHighlighted()) { + $html .= '<strong>'; + } + + $html .= $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getLabel())); + + if ($this->getIsHighlighted()) { + $html .= '</strong>'; + } + + $html .= '</a></li>'; } return $html; diff --git a/lib/internal/Magento/Framework/View/Element/Html/Links.php b/lib/internal/Magento/Framework/View/Element/Html/Links.php index d4dfc7b14942aa160bba7d9dda3dc1482cb5bd42..ffc9c297d8b219df6e1ec2ce5dc1102ac80ebe9c 100644 --- a/lib/internal/Magento/Framework/View/Element/Html/Links.php +++ b/lib/internal/Magento/Framework/View/Element/Html/Links.php @@ -20,6 +20,35 @@ class Links extends \Magento\Framework\View\Element\Template return $this->_layout->getChildBlocks($this->getNameInLayout()); } + /** + * Find link by path + * + * @param string $path + * @return \Magento\Framework\View\Element\Html\Link + */ + protected function getLinkByPath($path) + { + foreach ($this->getLinks() as $link) { + if ($link->getPath() == $path) { + return $link; + } + } + } + + /** + * Set active link + * + * @param string $path + * @return void + */ + public function setActive($path) + { + $link = $this->getLinkByPath($path); + if ($link) { + $link->setIsHighlighted(true); + } + } + /** * Render Block * diff --git a/lib/internal/Magento/Framework/View/Template/Html/Minifier.php b/lib/internal/Magento/Framework/View/Template/Html/Minifier.php index 4dfbbc69d060e63398a90a981e6f8ee1c151d97a..af80583da16e7f37c084151650869ef3f7c39c89 100644 --- a/lib/internal/Magento/Framework/View/Template/Html/Minifier.php +++ b/lib/internal/Magento/Framework/View/Template/Html/Minifier.php @@ -126,7 +126,7 @@ class Minifier implements MinifierInterface . '(?:<(?>textarea|pre|script)\b|\z))#', ' ', preg_replace( - '#(?<!:|\\\\)//(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*#', + '#(?<!:|\\\\|\'|")//(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*#', '', preg_replace( '#(?<!:)//[^\n\r]*(\s\?\>)#', diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinksTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinksTest.php index 2b90d037cbb0ba0f18e24dda153a55fc0c55d956..8e4d84db273cbef5aa7c0a06df07a1a99222e512 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinksTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinksTest.php @@ -5,70 +5,88 @@ */ namespace Magento\Framework\View\Test\Unit\Element\Html; +use Magento\Framework\View\Element\Html\Links; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Framework\View\Element\Template\Context; + class LinksTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + * @var ObjectManager|\PHPUnit_Framework_MockObject_MockObject */ - protected $_objectManagerHelper; + protected $objectManagerHelper; - /** @var \Magento\Framework\View\Element\Html\Links */ - protected $_block; + /** @var Links|\PHPUnit_Framework_MockObject_MockObject */ + protected $block; - /** @var \Magento\Framework\View\Element\Template\Context */ - protected $_context; + /** @var Context|\PHPUnit_Framework_MockObject_MockObject */ + protected $context; protected function setUp() { - $this->_objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - /** @var \Magento\Framework\View\Element\Template\Context $context */ - $this->_context = $this->_objectManagerHelper->getObject('Magento\Framework\View\Element\Template\Context'); + $this->objectManagerHelper = new ObjectManager($this); - /** @var \Magento\Framework\View\Element\Html\Links $block */ - $this->_block = $this->_objectManagerHelper->getObject( - 'Magento\Framework\View\Element\Html\Links', - ['context' => $this->_context] - ); + /** @var Context $context */ + $this->context = $this->objectManagerHelper->getObject('Magento\Framework\View\Element\Template\Context'); + $this->block = new Links($this->context); } public function testGetLinks() { $blocks = [0 => 'blocks']; $name = 'test_name'; - $this->_context->getLayout()->expects( - $this->once() - )->method( - 'getChildBlocks' - )->with( - $name - )->will( - $this->returnValue($blocks) - ); - $this->_block->setNameInLayout($name); - $this->assertEquals($blocks, $this->_block->getLinks()); + $this->context->getLayout() + ->expects($this->once()) + ->method('getChildBlocks') + ->with($name) + ->willReturn($blocks); + $this->block->setNameInLayout($name); + $this->assertEquals($blocks, $this->block->getLinks()); + } + + public function testSetActive() + { + $link = $this->getMock('Magento\Framework\View\Element\Html\Link', [], [], '', false); + $link + ->expects($this->at(1)) + ->method('__call') + ->with('setIsHighlighted', [true]); + $link + ->expects($this->at(0)) + ->method('__call') + ->with('getPath', []) + ->willReturn('test/path'); + + $name = 'test_name'; + $this->context->getLayout() + ->expects($this->once()) + ->method('getChildBlocks') + ->with($name) + ->willReturn([$link]); + + $this->block->setNameInLayout($name); + $this->block->setActive('test/path'); } public function testRenderLink() { $blockHtml = 'test'; $name = 'test_name'; - $this->_context->getLayout()->expects( - $this->once() - )->method( - 'renderElement' - )->with( - $name - )->will( - $this->returnValue($blockHtml) - ); + $this->context->getLayout() + ->expects($this->once()) + ->method('renderElement') + ->with($name) + ->willReturn($blockHtml); /** @var \Magento\Framework\View\Element\AbstractBlock $link */ $link = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock') ->disableOriginalConstructor() ->getMock(); - $link->expects($this->once())->method('getNameInLayout')->will($this->returnValue($name)); + $link + ->expects($this->once()) + ->method('getNameInLayout') + ->willReturn($name); - $this->assertEquals($blockHtml, $this->_block->renderLink($link)); + $this->assertEquals($blockHtml, $this->block->renderLink($link)); } }