-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Merge Pull Request #26066 from divyajyothi5321/magento2:fix-#26064 - Merged commits: 1. a882be9 2. e830f2e 3. 0d22017 4. 8251bc9 5. 0802b48 6. add2bbb
- Loading branch information
Showing
2 changed files
with
52 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ | |
*/ | ||
namespace Magento\Wishlist\Test\Unit\Controller\Index; | ||
|
||
use Magento\Captcha\Helper\Data as CaptchaHelper; | ||
use Magento\Captcha\Model\DefaultModel as CaptchaModel; | ||
use Magento\Customer\Model\Data\Customer as CustomerData; | ||
use Magento\Customer\Model\Session; | ||
use Magento\Framework\App\Action\Context as ActionContext; | ||
use Magento\Framework\App\RequestInterface; | ||
use Magento\Framework\Controller\Result\Redirect as ResultRedirect; | ||
|
@@ -14,15 +17,13 @@ | |
use Magento\Framework\Event\ManagerInterface as EventManagerInterface; | ||
use Magento\Framework\Mail\TransportInterface; | ||
use Magento\Framework\Message\ManagerInterface; | ||
use Magento\Framework\Phrase; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Magento\Framework\UrlInterface; | ||
use Magento\Framework\View\Result\Layout as ResultLayout; | ||
use Magento\Store\Model\Store; | ||
use Magento\Wishlist\Controller\Index\Send; | ||
use Magento\Wishlist\Controller\WishlistProviderInterface; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Magento\Captcha\Helper\Data as CaptchaHelper; | ||
use Magento\Captcha\Model\DefaultModel as CaptchaModel; | ||
use Magento\Customer\Model\Session; | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.TooManyFields) | ||
|
@@ -212,7 +213,12 @@ protected function setUp() | |
); | ||
} | ||
|
||
public function testExecuteNoFormKeyValidated() | ||
/** | ||
* Verify execute method without Form Key validated | ||
* | ||
* @return void | ||
*/ | ||
public function testExecuteNoFormKeyValidated(): void | ||
{ | ||
$this->formKeyValidator->expects($this->once()) | ||
->method('validate') | ||
|
@@ -228,8 +234,43 @@ public function testExecuteNoFormKeyValidated() | |
} | ||
|
||
/** | ||
* @expectedException \Magento\Framework\Exception\NotFoundException | ||
* @expectedExceptionMessage Page not found. | ||
* Verify execute with no emails left | ||
* | ||
* @return void | ||
*/ | ||
public function testExecuteWithNoEmailLeft(): void | ||
{ | ||
$expectedMessage = new Phrase('Maximum of %1 emails can be sent.', [0]); | ||
|
||
$this->formKeyValidator->expects($this->once()) | ||
->method('validate') | ||
->with($this->request) | ||
->willReturn(true); | ||
|
||
$this->request->expects($this->at(0)) | ||
->method('getPost') | ||
->with('emails') | ||
->willReturn('[email protected]', '[email protected]'); | ||
$this->request->expects($this->at(1)) | ||
->method('getPost') | ||
->with('message'); | ||
$wishlist = $this->createMock(\Magento\Wishlist\Model\Wishlist::class); | ||
$this->wishlistProvider->expects($this->once()) | ||
->method('getWishlist') | ||
->willReturn($wishlist); | ||
$this->resultRedirect->expects($this->once()) | ||
->method('setPath') | ||
->with('*/*/share') | ||
->willReturnSelf(); | ||
$this->messageManager->expects($this->once()) | ||
->method('addErrorMessage') | ||
->with($expectedMessage); | ||
|
||
$this->assertEquals($this->resultRedirect, $this->model->execute()); | ||
} | ||
|
||
/** | ||
* Execute method with no wishlist available | ||
*/ | ||
public function testExecuteNoWishlistAvailable() | ||
{ | ||
|
@@ -241,6 +282,8 @@ public function testExecuteNoWishlistAvailable() | |
$this->wishlistProvider->expects($this->once()) | ||
->method('getWishlist') | ||
->willReturn(null); | ||
$this->expectException(\Magento\Framework\Exception\NotFoundException::class); | ||
$this->expectExceptionMessage('Page not found'); | ||
|
||
$this->model->execute(); | ||
} | ||
|