当前位置: 首页>>代码示例>>PHP>>正文


PHP WishlistProviderInterface::expects方法代码示例

本文整理汇总了PHP中Magento\Wishlist\Controller\WishlistProviderInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP WishlistProviderInterface::expects方法的具体用法?PHP WishlistProviderInterface::expects怎么用?PHP WishlistProviderInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Wishlist\Controller\WishlistProviderInterface的用法示例。


在下文中一共展示了WishlistProviderInterface::expects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testExecutePassed

    public function testExecutePassed()
    {
        $url = 'http://redirect-url.com';
        $wishlist = $this->getMock('Magento\Wishlist\Model\Wishlist', [], [], '', false);
        
        $this->formKeyValidator->expects($this->once())
            ->method('validate')
            ->with($this->request)
            ->will($this->returnValue(true));
        $this->request->expects($this->once())
            ->method('getParam')
            ->with('qty')
            ->will($this->returnValue(2));
        $this->wishlistProvider->expects($this->once())
            ->method('getWishlist')
            ->will($this->returnValue($wishlist));
        $this->itemCarrier->expects($this->once())
            ->method('moveAllToCart')
            ->with($wishlist, 2)
            ->willReturn($url);
        $this->resultRedirectMock->expects($this->once())
            ->method('setUrl')
            ->with($url)
            ->willReturnSelf();

        $this->assertSame($this->resultRedirectMock, $this->getController()->executeInternal());
    }
开发者ID:nblair,项目名称:magescotch,代码行数:27,代码来源:AllcartTest.php

示例2: testExecutePassed

 public function testExecutePassed()
 {
     $wishlist = $this->getMock('Magento\\Wishlist\\Model\\Wishlist', [], [], '', false);
     $this->formKeyValidator->expects($this->once())->method('validate')->with($this->request)->will($this->returnValue(true));
     $this->request->expects($this->once())->method('getParam')->with('qty')->will($this->returnValue(2));
     $this->response->expects($this->once())->method('setRedirect')->will($this->returnValue('http://redirect-url.com'));
     $this->wishlistProvider->expects($this->once())->method('getWishlist')->will($this->returnValue($wishlist));
     $this->itemCarrier->expects($this->once())->method('moveAllToCart')->with($wishlist, 2)->will($this->returnValue('http://redirect-url.com'));
     $this->getController()->execute();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:AllcartTest.php

示例3: testExecuteWithoutQuantityArrayAndConfigurable

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testExecuteWithoutQuantityArrayAndConfigurable()
 {
     $itemId = 2;
     $wishlistId = 1;
     $qty = [];
     $productId = 4;
     $indexUrl = 'index_url';
     $configureUrl = 'configure_url';
     $options = [5 => 'option'];
     $params = ['item' => $itemId, 'qty' => $qty];
     $this->formKeyValidator->expects($this->once())->method('validate')->with($this->requestMock)->willReturn(true);
     $itemMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item')->disableOriginalConstructor()->setMethods(['load', 'getId', 'getWishlistId', 'setQty', 'setOptions', 'getBuyRequest', 'mergeBuyRequest', 'addToCart', 'getProduct', 'getProductId'])->getMock();
     $this->requestMock->expects($this->at(0))->method('getParam')->with('item', null)->willReturn($itemId);
     $this->itemFactoryMock->expects($this->once())->method('create')->willReturn($itemMock);
     $itemMock->expects($this->once())->method('load')->with($itemId, null)->willReturnSelf();
     $itemMock->expects($this->exactly(2))->method('getId')->willReturn($itemId);
     $itemMock->expects($this->once())->method('getWishlistId')->willReturn($wishlistId);
     $wishlistMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Wishlist')->disableOriginalConstructor()->getMock();
     $this->wishlistProviderMock->expects($this->once())->method('getWishlist')->with($wishlistId)->willReturn($wishlistMock);
     $this->requestMock->expects($this->at(1))->method('getParam')->with('qty', null)->willReturn($qty);
     $this->quantityProcessorMock->expects($this->once())->method('process')->with(1)->willReturnArgument(0);
     $itemMock->expects($this->once())->method('setQty')->with(1)->willReturnSelf();
     $this->urlMock->expects($this->at(0))->method('getUrl')->with('*/*', null)->willReturn($indexUrl);
     $itemMock->expects($this->once())->method('getProductId')->willReturn($productId);
     $this->urlMock->expects($this->at(1))->method('getUrl')->with('*/*/configure/', ['id' => $itemId, 'product_id' => $productId])->willReturn($configureUrl);
     $optionMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item\\Option')->disableOriginalConstructor()->getMock();
     $this->optionFactoryMock->expects($this->once())->method('create')->willReturn($optionMock);
     $optionsMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\ResourceModel\\Item\\Option\\Collection')->disableOriginalConstructor()->getMock();
     $optionMock->expects($this->once())->method('getCollection')->willReturn($optionsMock);
     $optionsMock->expects($this->once())->method('addItemFilter')->with([$itemId])->willReturnSelf();
     $optionsMock->expects($this->once())->method('getOptionsByItem')->with($itemId)->willReturn($options);
     $itemMock->expects($this->once())->method('setOptions')->with($options)->willReturnSelf();
     $this->requestMock->expects($this->once())->method('getParams')->willReturn($params);
     $buyRequestMock = $this->getMockBuilder('Magento\\Framework\\DataObject')->disableOriginalConstructor()->getMock();
     $itemMock->expects($this->once())->method('getBuyRequest')->willReturn($buyRequestMock);
     $this->productHelperMock->expects($this->once())->method('addParamsToBuyRequest')->with($params, ['current_config' => $buyRequestMock])->willReturn($buyRequestMock);
     $itemMock->expects($this->once())->method('mergeBuyRequest')->with($buyRequestMock)->willReturnSelf();
     $itemMock->expects($this->once())->method('addToCart')->with($this->checkoutCartMock, true)->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('message')));
     $this->messageManagerMock->expects($this->once())->method('addNotice')->with('message', null)->willReturnSelf();
     $this->helperMock->expects($this->once())->method('calculate')->willReturnSelf();
     $this->resultRedirectMock->expects($this->once())->method('setUrl')->with($configureUrl)->willReturnSelf();
     $this->assertSame($this->resultRedirectMock, $this->model->execute());
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:46,代码来源:CartTest.php

示例4: testGetWishlist

 public function testGetWishlist()
 {
     $wishlist = $this->getMock('\\Magento\\Wishlist\\Model\\Wishlist', [], [], '', false);
     $this->wishlistProvider->expects($this->once())->method('getWishlist')->will($this->returnValue($wishlist));
     $this->assertEquals($wishlist, $this->wishlistHelper->getWishlist());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:6,代码来源:DataTest.php


注:本文中的Magento\Wishlist\Controller\WishlistProviderInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。