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


PHP PageFactory::expects方法代码示例

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


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

示例1: testExecute

 public function testExecute()
 {
     $page = 'SamplePageObjectHere';
     $this->resultPageFactory->expects($this->once())->method('create')->willReturn($page);
     $result = $this->controller->execute();
     $this->assertEquals($page, $result);
 }
开发者ID:marcinNS,项目名称:magento2-samples,代码行数:7,代码来源:IndexTest.php

示例2: testExecuteOrderLoaded

 /**
  * @return void
  */
 public function testExecuteOrderLoaded()
 {
     $this->guestHelperMock->expects($this->once())->method('loadValidOrder')->with($this->requestMock)->willReturn(true);
     $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
     $this->guestHelperMock->expects($this->once())->method('getBreadcrumbs')->with($this->resultPageMock);
     $this->assertSame($this->resultPageMock, $this->viewController->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:ViewTest.php

示例3: testCreateActionRegistrationEnabled

 /**
  * @return void
  */
 public function testCreateActionRegistrationEnabled()
 {
     $this->customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->registrationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
     $this->redirectMock->expects($this->never())->method('redirect');
     $this->pageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
     $this->object->execute();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:CreateTest.php

示例4: testCreateActionRegistrationEnabled

 /**
  * @return void
  */
 public function testCreateActionRegistrationEnabled()
 {
     $this->customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->registrationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
     $this->redirectMock->expects($this->never())->method('redirect');
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
     $layoutMock->expects($this->once())->method('initMessages')->willReturnSelf();
     $this->pageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->object->execute();
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:14,代码来源:CreateTest.php

示例5: testExecute

 /**
  * @covers \Magento\Customer\Controller\Adminhtml\Index\Index::execute
  */
 public function testExecute()
 {
     $this->prepareExecute();
     $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Customer::customer_manage');
     $this->resultPageMock->expects($this->once())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->pageTitleMock->expects($this->once())->method('prepend')->with('Customers');
     $this->resultPageMock->expects($this->atLeastOnce())->method('addBreadcrumb')->withConsecutive(['Customers', 'Customers'], ['Manage Customers', 'Manage Customers']);
     $this->sessionMock->expects($this->once())->method('unsCustomerData');
     $this->assertInstanceOf('Magento\\Framework\\View\\Result\\Page', $this->indexController->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:IndexTest.php

示例6: setUp

 /**
  * test setup
  */
 public function setUp()
 {
     $this->pageConfig = $this->getMockBuilder('\\Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->setMethods(['set', 'getTitle'])->getMock();
     $this->resultPageFactory = $this->getMockBuilder('\\Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultPage = $this->getMockBuilder('\\Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $this->block = $this->getMockBuilder('\\Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMock();
     $this->pageLayout = $this->getMockBuilder('\\Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock();
     $this->resultPageFactory->expects($this->once())->method('create')->willReturn($this->resultPage);
     $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->pageLayout);
     $this->pageLayout->expects($this->any())->method('getBlock')->willReturn($this->block);
     $this->pageConfig->expects($this->once())->method('getTitle')->willReturnSelf();
     $this->resultPage->expects($this->any())->method('getConfig')->willReturn($this->pageConfig);
 }
开发者ID:nblair,项目名称:magescotch,代码行数:16,代码来源:IndexTest.php

示例7: testExecute

 /**
  * Test execute
  *
  * @return void
  */
 public function testExecute()
 {
     $orderId = 1;
     $invoiceData = ['comment_text' => 'test'];
     $response = 'test data';
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->will($this->returnValue($orderId));
     $this->requestMock->expects($this->at(1))->method('getParam')->with('invoice', [])->will($this->returnValue($invoiceData));
     $invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods([])->getMock();
     $invoiceMock->expects($this->once())->method('getTotalQty')->willReturn(2);
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['load', 'getId', 'canInvoice'])->getMock();
     $orderMock->expects($this->once())->method('load')->with($orderId)->willReturnSelf();
     $orderMock->expects($this->once())->method('getId')->willReturn($orderId);
     $orderMock->expects($this->once())->method('canInvoice')->willReturn(true);
     $this->invoiceServiceMock->expects($this->once())->method('prepareInvoice')->with($orderMock, [])->willReturn($invoiceMock);
     $this->objectManagerMock->expects($this->at(0))->method('create')->with('Magento\\Sales\\Model\\Order')->willReturn($orderMock);
     $blockItemMock = $this->getMockBuilder('Magento\\Sales\\Block\\Order\\Items')->disableOriginalConstructor()->setMethods([])->getMock();
     $blockItemMock->expects($this->once())->method('toHtml')->will($this->returnValue($response));
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->setMethods([])->getMock();
     $layoutMock->expects($this->once())->method('getBlock')->with('order_items')->will($this->returnValue($blockItemMock));
     $this->resultPageMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->resultPageMock->expects($this->once())->method('getConfig')->will($this->returnValue($this->pageConfigMock));
     $this->pageConfigMock->expects($this->once())->method('getTitle')->will($this->returnValue($this->titleMock));
     $this->resultPageFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->resultPageMock));
     $resultRaw = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Raw')->disableOriginalConstructor()->setMethods([])->getMock();
     $resultRaw->expects($this->once())->method('setContents')->with($response);
     $this->resultRawFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultRaw));
     $this->assertSame($resultRaw, $this->controller->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:33,代码来源:UpdateQtyTest.php

示例8: testExecute

 /**
  * Test execute
  *
  * @return void
  */
 public function testExecute()
 {
     $data = ['comment' => 'test comment'];
     $invoiceId = 2;
     $response = 'some result';
     $this->requestMock->expects($this->at(0))->method('getParam')->with('id')->willReturn($invoiceId);
     $this->requestMock->expects($this->at(1))->method('setParam');
     $this->requestMock->expects($this->at(2))->method('getPost')->with('comment')->willReturn($data);
     $this->requestMock->expects($this->at(3))->method('getParam')->with('invoice_id')->willReturn($invoiceId);
     $invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods([])->getMock();
     $invoiceMock->expects($this->once())->method('addComment')->with($data['comment'], false, false);
     $invoiceMock->expects($this->once())->method('save');
     $invoiceMock->expects($this->once())->method('load')->willReturnSelf();
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Sales\\Model\\Order\\Invoice')->willReturn($invoiceMock);
     $commentsBlockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Adminhtml\\Order\\Invoice\\View\\Comments')->disableOriginalConstructor()->setMethods([])->getMock();
     $commentsBlockMock->expects($this->once())->method('toHtml')->will($this->returnValue($response));
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->setMethods([])->getMock();
     $layoutMock->expects($this->once())->method('getBlock')->with('invoice_comments')->will($this->returnValue($commentsBlockMock));
     $this->resultPageFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->resultPageMock));
     $this->resultPageMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->commentSenderMock->expects($this->once())->method('send')->with($invoiceMock, false, $data['comment']);
     $resultRaw = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Raw')->disableOriginalConstructor()->setMethods([])->getMock();
     $resultRaw->expects($this->once())->method('setContents')->with($response);
     $this->resultRawFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultRaw));
     $this->assertSame($resultRaw, $this->controller->execute());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:31,代码来源:AddCommentTest.php

示例9: testExecute

    /**
     * Test execute
     *
     * @return void
     */
    public function testExecute()
    {
        $comment = 'Test comment';
        $data = ['comment' => $comment];
        $html = 'test output';

        $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo')
            ->disableOriginalConstructor()
            ->getMock();
        $commentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo\Comment')
            ->disableOriginalConstructor()
            ->getMock();
        $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout')
            ->disableOriginalConstructor()
            ->getMock();
        $blockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Creditmemo\View\Comments')
            ->disableOriginalConstructor()
            ->getMock();

        $this->requestMock->expects($this->once())
            ->method('getPost')
            ->with('comment')
            ->willReturn($data);
        $this->requestMock->expects($this->any())
            ->method('getParam')
            ->willReturnArgument(0);
        $creditmemoMock->expects($this->once())
            ->method('addComment')
            ->willReturn($commentMock);
        $this->loaderMock->expects($this->once())
            ->method('load')
            ->willReturn($creditmemoMock);
        $this->resultPageFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->resultPageMock);
        $this->resultPageMock->expects($this->atLeastOnce())
            ->method('getLayout')
            ->willReturn($layoutMock);
        $layoutMock->expects($this->once())
            ->method('getBlock')
            ->with('creditmemo_comments')
            ->willReturn($blockMock);
        $blockMock->expects($this->once())
            ->method('toHtml')
            ->willReturn($html);
        $this->resultRawFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->resultRawMock);
        $this->resultRawMock->expects($this->once())
            ->method('setContents')
            ->with($html)
            ->willReturnSelf();

        $this->assertInstanceOf(
            'Magento\Framework\Controller\Result\Raw',
            $this->controller->executeInternal()
        );
    }
开发者ID:nblair,项目名称:magescotch,代码行数:63,代码来源:AddCommentTest.php

示例10: testExecuteWithSession

 public function testExecuteWithSession()
 {
     $token = 'token';
     $customerId = '11';
     $this->requestMock->expects($this->exactly(2))->method('getParam')->willReturnMap([['token', null, null], ['id', null, $customerId]]);
     $this->sessionMock->expects($this->once())->method('getRpToken')->willReturn($token);
     $this->sessionMock->expects($this->once())->method('getRpCustomerId')->willReturn($customerId);
     $this->accountManagementMock->expects($this->once())->method('validateResetPasswordLinkToken')->with($customerId, $token)->willReturn(true);
     /** @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject $pageMock */
     $pageMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $this->pageFactoryMock->expects($this->once())->method('create')->with(false, [])->willReturn($pageMock);
     /** @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject $layoutMock */
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock();
     $pageMock->expects($this->once())->method('getLayout')->willReturn($layoutMock);
     /** @var \Magento\Customer\Block\Account\Resetpassword|\PHPUnit_Framework_MockObject_MockObject $layoutMock */
     $blockMock = $this->getMockBuilder('Magento\\Customer\\Block\\Account\\Resetpassword')->disableOriginalConstructor()->setMethods(['setCustomerId', 'setResetPasswordLinkToken'])->getMock();
     $layoutMock->expects($this->once())->method('getBlock')->with('resetPassword')->willReturn($blockMock);
     $blockMock->expects($this->once())->method('setCustomerId')->with($customerId)->willReturnSelf();
     $blockMock->expects($this->once())->method('setResetPasswordLinkToken')->with($token)->willReturnSelf();
     $this->assertEquals($pageMock, $this->model->executeInternal());
 }
开发者ID:nblair,项目名称:magescotch,代码行数:21,代码来源:CreatePasswordTest.php

示例11: testExecute

 /**
  * @dataProvider testExecuteDataProvider
  */
 public function testExecute($invoice)
 {
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock();
     $blockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Adminhtml\\Order\\Creditmemo\\View')->disableOriginalConstructor()->getMock();
     $this->requestMock->expects($this->any())->method('getParam')->withAnyParameters()->willReturnArgument(0);
     $this->loaderMock->expects($this->once())->method('load')->willReturn($this->creditmemoMock);
     $this->creditmemoMock->expects($this->any())->method('getInvoice')->willReturn($invoice);
     $layoutMock->expects($this->once())->method('getBlock')->with('sales_creditmemo_view')->willReturn($blockMock);
     $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($layoutMock);
     $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Sales::sales_creditmemo')->willReturnSelf();
     $this->resultPageMock->expects($this->atLeastOnce())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Page', $this->controller->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:17,代码来源:ViewTest.php

示例12: testExecute

 /**
  * Test execute
  *
  * @return void
  */
 public function testExecute()
 {
     $response = 'output';
     $this->requestMock->expects($this->any())->method('getParam')->withAnyParameters()->willReturnArgument(0);
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock();
     $blockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Order\\Items')->disableOriginalConstructor()->getMock();
     $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($layoutMock);
     $blockMock->expects($this->once())->method('toHtml')->willReturn($response);
     $layoutMock->expects($this->once())->method('getBlock')->with('order_items')->willReturn($blockMock);
     $this->resultRawFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRawMock);
     $this->resultRawMock->expects($this->once())->method('setContents')->with($response)->willReturnSelf();
     $this->assertInstanceOf('Magento\\Framework\\Controller\\Result\\Raw', $this->controller->execute());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:19,代码来源:UpdateQtyTest.php

示例13: testExecute

    /**
     * Run test execute method
     */
    public function testExecute()
    {
        $orderId = 1;
        $shipmentId = 1;
        $shipment = [];
        $tracking = [];
        $incrementId = '10000001';
        $comeFrom = true;

        $this->loadShipment($orderId, $shipmentId, $shipment, $tracking, $comeFrom, $this->shipmentMock);
        $this->shipmentMock->expects($this->once())->method('getIncrementId')->willReturn($incrementId);
        $this->resultPageFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->resultPageMock);

        $layoutMock = $this->getMock('Magento\Framework\View\Layout', ['getBlock', '__wakeup'], [], '', false);
        $this->resultPageMock->expects($this->once())
            ->method('getLayout')
            ->willReturn($layoutMock);
        $layoutMock->expects($this->once())
            ->method('getBlock')
            ->with('sales_shipment_view')
            ->willReturn($this->blockMock);
        $this->blockMock->expects($this->once())
            ->method('updateBackButtonUrl')
            ->with($comeFrom)
            ->willReturnSelf();

        $this->resultPageMock->expects($this->once())
            ->method('setActiveMenu')
            ->with('Magento_Sales::sales_shipment')
            ->willReturnSelf();
        $this->resultPageMock->expects($this->atLeastOnce())
            ->method('getConfig')
            ->willReturn($this->pageConfigMock);
        $this->pageConfigMock->expects($this->atLeastOnce())
            ->method('getTitle')
            ->willReturn($this->pageTitleMock);
        $this->pageTitleMock->expects($this->exactly(2))
            ->method('prepend')
            ->withConsecutive(
                ['Shipments'],
                ["#" . $incrementId]
            )
            ->willReturnSelf();

        $this->assertEquals($this->resultPageMock, $this->controller->executeInternal());
    }
开发者ID:nblair,项目名称:magescotch,代码行数:51,代码来源:ViewTest.php

示例14: testExecuteNonExistingTokenRedirect

 /**
  * Executes the controller action and asserts with redirects for non existing logic
  */
 public function testExecuteNonExistingTokenRedirect()
 {
     $objectManager = new ObjectManagerHelper($this);
     $phrase = new \Magento\Framework\Phrase('Credit card does not exist');
     $this->vault->expects($this->once())->method('storedCard')->willReturn(false);
     $this->request->expects($this->any())->method('getParam')->willReturn('token');
     $this->resultRedirectFactory->expects($this->once())->method('create')->willReturn($this->resultRedirect);
     $this->resultPageFactory->expects($this->never())->method('create')->willReturn($this->resultPage);
     $this->resultRedirect->expects($this->once())->method('setPath')->willReturnSelf();
     /**
      * @var \Magento\Framework\Message\ManagerInterface $messageManager
      */
     $messageManager = $this->getMockBuilder('\\Magento\\Framework\\Message\\ManagerInterface')->getMock();
     $messageManager->expects($this->once())->method('addError')->with($phrase);
     $notification = $objectManager->getObject('Magento\\Braintree\\Controller\\Creditcard\\Delete', ['request' => $this->request, 'resultPageFactory' => $this->resultPageFactory, 'resultRedirectFactory' => $this->resultRedirectFactory, 'vault' => $this->vault, 'messageManager' => $messageManager]);
     $this->assertSame($this->resultRedirect, $notification->execute());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:DeleteTest.php

示例15: initAction

 protected function initAction()
 {
     $this->resultPageFactoryMock->expects($this->once())
         ->method('create')
         ->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->once())
         ->method('setActiveMenu')
         ->with('Magento_Sales::sales_order')
         ->willReturnSelf();
     $this->resultPageMock->expects($this->exactly(2))
         ->method('addBreadcrumb')
         ->withConsecutive(
             ['Sales', 'Sales'],
             ['Orders', 'Orders']
         )
         ->willReturnSelf();
 }
开发者ID:nblair,项目名称:magescotch,代码行数:17,代码来源:ViewTest.php


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