diff --git a/app/code/Magento/Customer/view/frontend/web/template/customer-email.html b/app/code/Magento/Customer/view/frontend/web/template/customer-email.html index a2159cc764d2a6955f2fe8b79935f6a8253f163c..05d84467d543e6093fe2b548fb8ba29812158de4 100644 --- a/app/code/Magento/Customer/view/frontend/web/template/customer-email.html +++ b/app/code/Magento/Customer/view/frontend/web/template/customer-email.html @@ -37,7 +37,6 @@ </label> <div class="control"> <input class="input-text" - placeholder="optional" type="password" name="password" id="customer-password" diff --git a/app/code/Magento/Wishlist/Controller/Index/Share.php b/app/code/Magento/Wishlist/Controller/Index/Share.php index 0971a293d331f0bf0cf7c6ca089b81a480e803ab..b8da8ea74227f952614a4768d0620fa44df77a71 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Share.php +++ b/app/code/Magento/Wishlist/Controller/Index/Share.php @@ -11,15 +11,34 @@ use Magento\Framework\Controller\ResultFactory; class Share extends Action\Action implements IndexInterface { + /** + * @var \Magento\Customer\Model\Session + */ + protected $customerSession; + + /** + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + */ + public function __construct( + \Magento\Framework\App\Action\Context $context, + \Magento\Customer\Model\Session $customerSession + ) { + $this->customerSession = $customerSession; + parent::__construct($context); + } + /** * Prepare wishlist for share * - * @return \Magento\Framework\View\Result\Page + * @return void|\Magento\Framework\View\Result\Page */ public function execute() { - /** @var \Magento\Framework\View\Result\Page $resultPage */ - $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); - return $resultPage; + if ($this->customerSession->authenticate($this)) { + /** @var \Magento\Framework\View\Result\Page $resultPage */ + $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); + return $resultPage; + } } } diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/ShareTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/ShareTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b34b4e185a7430318ce9aa07e5788393b95eca09 --- /dev/null +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/ShareTest.php @@ -0,0 +1,66 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Wishlist\Test\Unit\Controller\Index; + +use Magento\Framework\Controller\ResultFactory; + +class ShareTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Wishlist\Controller\Index\Share + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $resultFactoryMock; + + protected function setUp() + { + $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); + $this->contextMock = $this->getMock('\Magento\Framework\App\Action\Context', [], [], '', false); + $this->resultFactoryMock = $this->getMock('\Magento\Framework\Controller\ResultFactory', [], [], '', false); + + $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactoryMock); + + $this->model = new \Magento\Wishlist\Controller\Index\Share( + $this->contextMock, + $this->customerSessionMock + ); + } + + public function testExecute() + { + $resultMock = $this->getMock('\Magento\Framework\Controller\ResultInterface', [], [], '', false); + + $this->customerSessionMock->expects($this->once())->method('authenticate')->with($this->model) + ->willReturn(true); + $this->resultFactoryMock->expects($this->once())->method('create')->with(ResultFactory::TYPE_PAGE) + ->willReturn($resultMock); + + $this->assertEquals($resultMock, $this->model->execute()); + } + + public function testExecuteAuthenticationFail() + { + $this->customerSessionMock->expects($this->once())->method('authenticate')->with($this->model) + ->willReturn(false); + + $this->assertEmpty($this->model->execute()); + } +}