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


PHP JsonFactory::expects方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     $this->productBuilder = $this->getMock('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Builder', ['build'], [], '', false);
     $this->product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['addData', 'getSku', 'getTypeId', 'getStoreId', '__sleep', '__wakeup', 'getAttributes', 'setAttributeSetId'])->getMock();
     $this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple'));
     $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1'));
     $this->product->expects($this->any())->method('getAttributes')->will($this->returnValue([]));
     $this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product));
     $this->resultPage = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $resultPageFactory = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
     $this->resultForward = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Forward')->disableOriginalConstructor()->getMock();
     $resultForwardFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $resultForwardFactory->expects($this->any())->method('create')->willReturn($this->resultForward);
     $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->layout);
     $this->resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->resultRedirect = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
     $this->initializationHelper = $this->getMock('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Initialization\\Helper', [], [], '', false);
     $this->productFactory = $this->getMockBuilder('Magento\\Catalog\\Model\\ProductFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->productFactory->expects($this->any())->method('create')->willReturn($this->product);
     $this->resultJson = $this->getMock('Magento\\Framework\\Controller\\Result\\Json', [], [], '', false);
     $this->resultJsonFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\JsonFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultJsonFactory->expects($this->any())->method('create')->willReturn($this->resultJson);
     $additionalParams = ['resultRedirectFactory' => $this->resultRedirectFactory];
     $this->action = (new ObjectManagerHelper($this))->getObject('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Validate', ['context' => $this->initContext($additionalParams), 'productBuilder' => $this->productBuilder, 'resultPageFactory' => $resultPageFactory, 'resultForwardFactory' => $resultForwardFactory, 'initializationHelper' => $this->initializationHelper, 'resultJsonFactory' => $this->resultJsonFactory, 'productFactory' => $this->productFactory]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:27,代码来源:ValidateTest.php

示例2: setUp

 public function setUp()
 {
     if (!function_exists('libxml_set_external_entity_loader')) {
         $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
     }
     $this->customer = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\CustomerInterface', [], '', false, true, true);
     $this->customer->expects($this->once())->method('getWebsiteId')->willReturn(2);
     $this->customerDataFactory = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory', ['create'], [], '', false);
     $this->customerDataFactory->expects($this->once())->method('create')->willReturn($this->customer);
     $this->form = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false);
     $this->request = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface', [], '', false, true, true, ['getPost']);
     $this->response = $this->getMockForAbstractClass('Magento\\Framework\\App\\ResponseInterface', [], '', false);
     $this->formFactory = $this->getMock('Magento\\Customer\\Model\\Metadata\\FormFactory', ['create'], [], '', false);
     $this->formFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->form);
     $this->extensibleDataObjectConverter = $this->getMock('Magento\\Framework\\Api\\ExtensibleDataObjectConverter', [], [], '', false);
     $this->dataObjectHelper = $this->getMock('Magento\\Framework\\Api\\DataObjectHelper', [], [], '', false);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray');
     $this->customerAccountManagement = $this->getMockForAbstractClass('Magento\\Customer\\Api\\AccountManagementInterface', [], '', false, true, true);
     $this->resultJson = $this->getMock('Magento\\Framework\\Controller\\Result\\Json', [], [], '', false);
     $this->resultJson->expects($this->once())->method('setData');
     $this->resultJsonFactory = $this->getMock('Magento\\Framework\\Controller\\Result\\JsonFactory', ['create'], [], '', false);
     $this->resultJsonFactory->expects($this->once())->method('create')->willReturn($this->resultJson);
     $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->controller = $objectHelper->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\Validate', ['request' => $this->request, 'response' => $this->response, 'customerDataFactory' => $this->customerDataFactory, 'formFactory' => $this->formFactory, 'extensibleDataObjectConverter' => $this->extensibleDataObjectConverter, 'customerAccountManagement' => $this->customerAccountManagement, 'resultJsonFactory' => $this->resultJsonFactory, 'dataObjectHelper' => $this->dataObjectHelper]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:ValidateTest.php

示例3: testExecuteWithoutData

 public function testExecuteWithoutData()
 {
     $this->request->expects($this->at(0))->method('getParam')->with('isAjax')->willReturn(true);
     $this->request->expects($this->at(1))->method('getParam')->with('items', [])->willReturn([]);
     $this->jsonFactory->expects($this->once())->method('create')->willReturn($this->resultJson);
     $this->resultJson->expects($this->once())->method('setData')->with(['messages' => ['Please correct the data sent.'], 'error' => true])->willReturnSelf();
     $this->controller->execute();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:8,代码来源:InlineEditTest.php

示例4: testExecute

 /**
  * @param bool $result
  * @dataProvider dataProviderTestExecute
  */
 public function testExecute($result)
 {
     $resultExpectation = ['isActive' => $result];
     $jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $this->sessionsManager->expects($this->any())->method('getCurrentSession')->willReturn($this->currentSession);
     $this->currentSession->expects($this->any())->method('isActive')->will($this->returnValue($result));
     $this->jsonFactory->expects($this->any())->method('create')->willReturn($jsonMock);
     $jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
     $this->assertEquals($jsonMock, $this->controller->execute());
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:14,代码来源:CheckTest.php

示例5: testExecute

 public function testExecute()
 {
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['frontend_label', null, 'test_frontend_label'], ['attribute_code', null, 'test_attribute_code'], ['new_attribute_set_name', null, 'test_attribute_set_name']]);
     $this->objectManagerMock->expects($this->exactly(2))->method('create')->willReturnMap([['Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], $this->attributeMock], ['Magento\\Eav\\Model\\Entity\\Attribute\\Set', [], $this->attributeSetMock]]);
     $this->attributeMock->expects($this->once())->method('loadByCode')->willReturnSelf();
     $this->requestMock->expects($this->once())->method('has')->with('new_attribute_set_name')->willReturn(true);
     $this->attributeSetMock->expects($this->once())->method('setEntityTypeId')->willReturnSelf();
     $this->attributeSetMock->expects($this->once())->method('load')->willReturnSelf();
     $this->attributeSetMock->expects($this->once())->method('getId')->willReturn(false);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($this->resultJson);
     $this->resultJson->expects($this->once())->method('setJsonData')->willReturnSelf();
     $this->assertInstanceOf(ResultJson::class, $this->getModel()->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:ValidateTest.php

示例6: testExecuteWithSuccessOrderSave

 /**
  * Test for execute method
  *
  * @return void
  */
 public function testExecuteWithSuccessOrderSave()
 {
     $testData = $this->getExecuteWithSuccessOrderSaveTestData();
     $redirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $paymentMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Payment')->disableOriginalConstructor()->getMock();
     $checkoutMock = $this->getMockBuilder('Magento\\Checkout\\Model\\Session')->disableOriginalConstructor()->setMethods(['getRedirectUrl'])->getMock();
     $resultJsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $redirectMock->expects($this->never())->method('setPath')->with('*/*/')->willReturn('redirect');
     $this->formKeyValidatorMock->expects($this->once())->method('validate')->with($this->requestMock)->willReturn(true);
     $this->resultRedirectFactoryMock->expects($this->never())->method('create')->willReturn($redirectMock);
     $this->objectManagerMock->expects($this->atLeastOnce())->method('get')->willReturnMap($testData['objectManager.get']);
     // call _expireAjax method
     $this->expireAjaxFlowHasItemsFalse();
     $this->requestMock->expects($this->atLeastOnce())->method('getPost')->willReturnMap($testData['request.getPost']);
     $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($testData['agreementsValidator.isValid'])->willReturn(true);
     $this->quoteMock->expects($this->atLeastOnce())->method('getPayment')->willReturn($paymentMock);
     $paymentMock->expects($this->once())->method('setQuote')->with($this->quoteMock);
     $paymentMock->expects($this->once())->method('importData')->with($testData['payment.importData']);
     $this->onepageMock->expects($this->once())->method('saveOrder');
     $this->onepageMock->expects($this->once())->method('getCheckout')->willReturn($checkoutMock);
     $checkoutMock->expects($this->once())->method('getRedirectUrl')->willReturn(null);
     $this->eventManagerMock->expects($this->once())->method('dispatch')->withConsecutive($this->equalTo('checkout_controller_onepage_saveOrder'), $this->countOf(2));
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($resultJsonMock);
     $resultJsonMock->expects($this->once())->method('setData')->with($testData['resultJson.setData'])->willReturnSelf();
     $this->assertEquals($resultJsonMock, $this->controller->execute());
 }
开发者ID:opexsw,项目名称:magento2,代码行数:31,代码来源:SaveOrderTest.php

示例7: testExecuteWithoutData

 public function testExecuteWithoutData()
 {
     $this->jsonFactory->expects($this->once())->method('create')->willReturn($this->resultJson);
     $this->request->expects($this->any())->method('getParam')->willReturnMap([['items', [], []], ['isAjax', null, true]]);
     $this->resultJson->expects($this->once())->method('setData')->with(['messages' => ['Please correct the data sent.'], 'error' => true])->willReturnSelf();
     $this->assertSame($this->resultJson, $this->controller->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:InlineEditTest.php

示例8: testExecuteException

    /**
     * Test execute exception
     *
     * @return void
     */
    public function testExecuteException()
    {
        $message = 'We can\'t update the item\'s quantity right now.';
        $e = new \Exception($message);
        $response = ['error' => true, 'message' => $message];

        $this->requestMock->expects($this->any())
            ->method('getParam')
            ->willReturnArgument(0);
        $this->loaderMock->expects($this->once())
            ->method('load')
            ->willThrowException($e);
        $this->resultJsonFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->resultJsonMock);
        $this->resultJsonMock->expects($this->once())
            ->method('setData')
            ->with($response)
            ->willReturnSelf();

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

示例9: testExecuteException

 /**
  * Test execute exception
  *
  * @return void
  */
 public function testExecuteException()
 {
     $response = ['error' => true, 'message' => 'Cannot add new comment.'];
     $e = new \Exception('test');
     $this->requestMock->expects($this->once())->method('getParam')->will($this->throwException($e));
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->resultJsonMock));
     $this->resultJsonMock->expects($this->once())->method('setData')->with($response);
     $this->assertSame($this->resultJsonMock, $this->controller->execute());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:AddCommentTest.php

示例10: testExecuteEmptyQuoteError

 public function testExecuteEmptyQuoteError()
 {
     $resultExpectation = ['success' => false, 'error' => true, 'error_messages' => __('Your payment has been declined. Please try again.')];
     $quoteMock = null;
     $jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $this->sessionManagerMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($quoteMock);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock);
     $jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
     $this->assertEquals($jsonMock, $this->controller->execute());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:RequestSecureTokenTest.php

示例11: testExecuteNoComment

 /**
  * Test execute no comment
  *
  * @return void
  */
 public function testExecuteNoComment()
 {
     $message = 'Please enter a comment.';
     $response = ['error' => true, 'message' => $message];
     $data = [];
     $this->requestMock->expects($this->once())->method('getPost')->with('comment')->willReturn($data);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($this->resultJsonMock);
     $this->resultJsonMock->expects($this->once())->method('setData')->with($response)->willReturnSelf();
     $this->assertInstanceOf('Magento\\Framework\\Controller\\Result\\Json', $this->controller->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:AddCommentTest.php

示例12: testExecuteException

 /**
  * Test execute exception
  *
  * @return void
  */
 public function testExecuteException()
 {
     $message = 'The order no longer exists.';
     $response = ['error' => true, 'message' => $message];
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['load', 'getId', 'canInvoice'])->getMock();
     $orderMock->expects($this->once())->method('load')->will($this->returnSelf());
     $orderMock->expects($this->once())->method('getId')->willReturn(null);
     $this->objectManagerMock->expects($this->at(0))->method('create')->with('Magento\\Sales\\Model\\Order')->willReturn($orderMock);
     $this->titleMock->expects($this->never())->method('prepend')->with('Invoices');
     /** @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */
     $resultJsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->setMethods([])->getMock();
     $resultJsonMock->expects($this->once())->method('setData')->with($response);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultJsonMock));
     $this->assertSame($resultJsonMock, $this->controller->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:20,代码来源:UpdateQtyTest.php

示例13: testExecute

 /**
  * Run test execute method
  *
  * @param array $result
  * @param array $resultExpectation
  *
  * @dataProvider executeDataProvider
  */
 public function testExecute(array $result, array $resultExpectation)
 {
     $quoteId = 99;
     $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
     $tokenMock = $this->getMockBuilder('Magento\\Framework\\Object')->setMethods(['getData', 'getSecuretoken'])->disableOriginalConstructor()->getMock();
     $jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
     $this->sessionManagerMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($quoteMock);
     $quoteMock->expects($this->once())->method('getId')->willReturn($quoteId);
     $this->sessionTransparentMock->expects($this->once())->method('setQuoteId')->with($quoteId);
     $this->secureTokenServiceMock->expects($this->once())->method('requestToken')->with($quoteMock)->willReturn($tokenMock);
     $this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
     $tokenMock->expects($this->once())->method('getData')->willReturn($result['transparent']['fields']);
     $tokenMock->expects($this->once())->method('getSecuretoken')->willReturn($result['success']);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock);
     $jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
     $this->assertEquals($jsonMock, $this->controller->execute());
 }
开发者ID:nja78,项目名称:magento2,代码行数:26,代码来源:RequestSecureTokenTest.php

示例14: testExecute

 /**
  * Run test execute method
  *
  * @param int|bool $categoryId
  * @param int $storeId
  * @param int|null $parentId
  * @return void
  *
  * @dataProvider dataProviderExecute
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testExecute($categoryId, $storeId, $parentId)
 {
     $rootCategoryId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
     $products = [['any_product']];
     $postData = ['general-data', 'parent' => $parentId, 'category_products' => json_encode($products)];
     if (isset($storeId)) {
         $postData['store_id'] = $storeId;
     }
     /**
      * @var \Magento\Backend\Model\View\Result\Redirect
      * |\PHPUnit_Framework_MockObject_MockObject $resultRedirectMock
      */
     $resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     /**
      * @var \Magento\Framework\View\Element\Messages
      * |\PHPUnit_Framework_MockObject_MockObject $blockMock
      */
     $blockMock = $this->getMock('Magento\\Framework\\View\\Element\\Messages', ['setMessages', 'getGroupedHtml'], [], '', false);
     /**
      * @var \Magento\Catalog\Model\Category
      * |\PHPUnit_Framework_MockObject_MockObject $categoryMock
      */
     $categoryMock = $this->getMock('Magento\\Catalog\\Model\\Category', ['setStoreId', 'load', 'getPath', 'getResource', 'setPath', 'setParentId', 'setData', 'addData', 'setAttributeSetId', 'getDefaultAttributeSetId', 'getProductsReadonly', 'setPostedProducts', 'getId', 'validate', 'unsetData', 'save', 'toArray'], [], '', false);
     /**
      * @var \Magento\Catalog\Model\Category
      * |\PHPUnit_Framework_MockObject_MockObject $parentCategoryMock
      */
     $parentCategoryMock = $this->getMock('Magento\\Catalog\\Model\\Category', ['setStoreId', 'load', 'getPath', 'setPath', 'setParentId', 'setData', 'addData', 'setAttributeSetId', 'getDefaultAttributeSetId', 'getProductsReadonly', 'setPostedProducts', 'getId'], [], '', false);
     /**
      * @var \Magento\Backend\Model\Auth\Session
      * |\PHPUnit_Framework_MockObject_MockObject $sessionMock
      */
     $sessionMock = $this->getMock('Magento\\Backend\\Model\\Auth\\Session', [], [], '', false);
     /**
      * @var \Magento\Framework\Registry
      * |\PHPUnit_Framework_MockObject_MockObject $registryMock
      */
     $registryMock = $this->getMock('Magento\\Framework\\Registry', ['register'], [], '', false);
     /**
      * @var \Magento\Cms\Model\Wysiwyg\Config
      * |\PHPUnit_Framework_MockObject_MockObject $wysiwygConfigMock
      */
     $wysiwygConfigMock = $this->getMock('Magento\\Cms\\Model\\Wysiwyg\\Config', ['setStoreId'], [], '', false);
     /**
      * @var \Magento\Store\Model\StoreManagerInterface
      * |\PHPUnit_Framework_MockObject_MockObject $storeManagerMock
      */
     $storeManagerMock = $this->getMockForAbstractClass('Magento\\Store\\Model\\StoreManagerInterface', [], '', false, true, true, ['getStore', 'getRootCategoryId']);
     /**
      * @var \Magento\Framework\View\Layout
      * |\PHPUnit_Framework_MockObject_MockObject $layoutMock
      */
     $layoutMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Layout', [], '', false, true, true, ['getMessagesBlock']);
     /**
      * @var \Magento\Framework\Controller\Result\Json
      * |\PHPUnit_Framework_MockObject_MockObject $resultJsonMock
      */
     $resultJsonMock = $this->getMock('Magento\\Cms\\Model\\Wysiwyg\\Config', ['setData'], [], '', false);
     /**
      * @var \Magento\Framework\Message\Collection
      * |\PHPUnit_Framework_MockObject_MockObject $messagesMock
      */
     $messagesMock = $this->getMock('Magento\\Framework\\Message\\Collection', [], [], '', false);
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultRedirectMock));
     $this->requestMock->expects($this->atLeastOnce())->method('getParam')->will($this->returnValueMap([['id', false, $categoryId], ['store', null, $storeId], ['parent', null, $parentId]]));
     $this->objectManagerMock->expects($this->atLeastOnce())->method('create')->will($this->returnValue($categoryMock));
     $this->objectManagerMock->expects($this->atLeastOnce())->method('get')->will($this->returnValueMap([['Magento\\Backend\\Model\\Auth\\Session', $sessionMock], ['Magento\\Framework\\Registry', $registryMock], ['Magento\\Cms\\Model\\Wysiwyg\\Config', $wysiwygConfigMock], ['Magento\\Store\\Model\\StoreManagerInterface', $storeManagerMock]]));
     $categoryMock->expects($this->once())->method('setStoreId')->with($storeId);
     $registryMock->expects($this->any())->method('register')->will($this->returnValueMap([['category', $categoryMock], ['current_category', $categoryMock]]));
     $wysiwygConfigMock->expects($this->once())->method('setStoreId')->with($storeId);
     $this->requestMock->expects($this->atLeastOnce())->method('getPost')->will($this->returnValueMap([['use_config', ['attribute']], ['use_default', ['default-attribute']], ['return_session_messages_only', true]]));
     $this->requestMock->expects($this->atLeastOnce())->method('getPostValue')->willReturn($postData);
     $categoryMock->expects($this->once())->method('addData')->with($postData);
     $categoryMock->expects($this->at(0))->method('getId')->will($this->returnValue($categoryId));
     if (!$parentId) {
         if ($storeId) {
             $storeManagerMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnSelf());
             $storeManagerMock->expects($this->once())->method('getRootCategoryId')->will($this->returnValue($rootCategoryId));
             $parentId = $rootCategoryId;
         }
     }
     $categoryMock->expects($this->any())->method('load')->will($this->returnValue($parentCategoryMock));
     $parentCategoryMock->expects($this->once())->method('getPath')->will($this->returnValue('parent_category_path'));
     $categoryMock->expects($this->once())->method('setPath')->with('parent_category_path');
     $categoryMock->expects($this->once())->method('setParentId')->with($parentId);
     $categoryMock->expects($this->atLeastOnce())->method('setData')->will($this->returnValueMap([['attribute', null, true], ['default-attribute', false, true], ['use_post_data_config', ['attribute'], true]]));
     $categoryMock->expects($this->once())->method('getDefaultAttributeSetId')->will($this->returnValue('default-attribute'));
     $categoryMock->expects($this->once())->method('setAttributeSetId')->with('default-attribute');
     $categoryMock->expects($this->once())->method('getProductsReadonly')->will($this->returnValue(false));
//.........这里部分代码省略.........
开发者ID:Zash22,项目名称:magento,代码行数:101,代码来源:SaveTest.php


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