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


PHP DataObjectHelper::expects方法代码示例

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


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

示例1: 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

示例2: testGetChildren

 public function testGetChildren()
 {
     $productId = 'test';
     $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productTypeInstance = $this->getMockBuilder('Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable')->disableOriginalConstructor()->getMock();
     $product->expects($this->any())->method('getTypeId')->willReturn(Configurable::TYPE_CODE);
     $product->expects($this->any())->method('getStoreId')->willReturn(1);
     $product->expects($this->any())->method('getTypeInstance')->willReturn($productTypeInstance);
     $productTypeInstance->expects($this->once())->method('setStoreFilter')->with(1, $product);
     $childProduct = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productTypeInstance->expects($this->any())->method('getUsedProducts')->with($product)->willReturn([$childProduct]);
     $this->productRepository->expects($this->any())->method('get')->with($productId)->willReturn($product);
     $attribute = $this->getMock('\\Magento\\Eav\\Api\\Data\\AttributeInterface');
     $attribute->expects($this->once())->method('getAttributeCode')->willReturn('code');
     $childProduct->expects($this->once())->method('getDataUsingMethod')->with('code')->willReturn(false);
     $childProduct->expects($this->once())->method('getData')->with('code')->willReturn(10);
     $childProduct->expects($this->once())->method('getStoreId')->willReturn(1);
     $childProduct->expects($this->once())->method('getAttributes')->willReturn([$attribute]);
     $productMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductInterface');
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray')->with($productMock, ['store_id' => 1, 'code' => 10], '\\Magento\\Catalog\\Api\\Data\\ProductInterface')->willReturnSelf();
     $this->productFactory->expects($this->once())->method('create')->willReturn($productMock);
     $products = $this->object->getChildren($productId);
     $this->assertCount(1, $products);
     $this->assertEquals($productMock, $products[0]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:LinkManagementTest.php

示例3: testGetItems

 public function testGetItems()
 {
     $inputTypeMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Attribute\\Source\\Inputtype', [], [], '', false);
     $this->inputTypeFactoryMock->expects($this->once())->method('create')->willReturn($inputTypeMock);
     $inputTypeMock->expects($this->once())->method('toOptionArray')->willReturn(['option' => ['value']]);
     $attributeTypeMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductAttributeTypeInterface');
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray')->with($attributeTypeMock, ['value'], '\\Magento\\Catalog\\Api\\Data\\ProductAttributeTypeInterface')->willReturnSelf();
     $this->attributeTypeFactoryMock->expects($this->once())->method('create')->willReturn($attributeTypeMock);
     $this->assertEquals([$attributeTypeMock], $this->model->getItems());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:TypesListTest.php

示例4: testFindOneByDataIfFound

 public function testFindOneByDataIfFound()
 {
     $data = [['field1' => 'value1']];
     $row = ['row1'];
     $urlRewrite = ['urlRewrite1'];
     $this->storage->expects($this->once())->method('doFindOneByData')->with($data)->will($this->returnValue($row));
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($urlRewrite, $row, '\\Magento\\UrlRewrite\\Service\\V1\\Data\\UrlRewrite')->will($this->returnSelf());
     $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($urlRewrite));
     $this->assertEquals($urlRewrite, $this->storage->findOneByData($data));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:AbstractStorageTest.php

示例5: testFindOneByData

 public function testFindOneByData()
 {
     $data = ['col1' => 'val1', 'col2' => 'val2'];
     $this->select->expects($this->at(1))->method('where')->with('col1 IN (?)', 'val1');
     $this->select->expects($this->at(2))->method('where')->with('col2 IN (?)', 'val2');
     $this->adapter->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0));
     $this->adapter->expects($this->once())->method('fetchRow')->with($this->select)->will($this->returnValue(['row1']));
     $this->dataObjectHelper->expects($this->at(0))->method('populateWithArray')->with(['urlRewrite1'], ['row1'], '\\Magento\\UrlRewrite\\Service\\V1\\Data\\UrlRewrite')->will($this->returnSelf());
     $this->urlRewriteFactory->expects($this->at(0))->method('create')->will($this->returnValue(['urlRewrite1']));
     $this->assertEquals(['urlRewrite1'], $this->storage->findOneByData($data));
 }
开发者ID:opexsw,项目名称:magento2,代码行数:11,代码来源:DbStorageTest.php

示例6: testConvert

 public function testConvert()
 {
     $orderData = ['test' => 'test1'];
     $data = ['test' => 'beer'];
     /**
      * @var \Magento\Quote\Model\Quote\Address $object
      */
     $object = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', [], [], '', false);
     $this->objectCopyMock->expects($this->once())->method('getDataFromFieldset')->with('sales_convert_quote_address', 'to_order_address', $object)->willReturn($orderData);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($this->orderInterfaceMock, ['test' => 'beer'], '\\Magento\\Sales\\Api\\Data\\OrderAddressInterface')->willReturnSelf();
     $this->orderAddressRepositoryMock->expects($this->once())->method('create')->willReturn($this->orderInterfaceMock);
     $this->assertSame($this->orderInterfaceMock, $this->converter->convert($object, $data));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:ToOrderAddressTest.php

示例7: testGetTotals

 public function testGetTotals()
 {
     $cartId = 12;
     $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
     $this->quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($this->addressMock);
     $this->addressMock->expects($this->once())->method('getData')->willReturn(['addressData']);
     $this->quoteMock->expects($this->once())->method('getData')->willReturn(['quoteData']);
     $item = $this->getMock('Magento\\Quote\\Model\\Quote\\Item', [], [], '', false);
     $this->quoteMock->expects($this->once())->method('getAllItems')->will($this->returnValue([$item]));
     $totals = $this->getMock('Magento\\Quote\\Model\\Cart\\Totals', ['setItems'], [], '', false);
     $this->totalsFactoryMock->expects($this->once())->method('create')->willReturn($totals);
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray');
     $totals->expects($this->once())->method('setItems');
     $this->model->get($cartId);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:CartTotalRepositoryTest.php

示例8: testPrepareQuoteForNewCustomer

 public function testPrepareQuoteForNewCustomer()
 {
     $customerAddressMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->disableOriginalConstructor()->getMock();
     $this->addressMock->expects($this->any())->method('exportCustomerAddress')->willReturn($customerAddressMock);
     $this->addressMock->expects($this->any())->method('getData')->willReturn([]);
     $this->addressFactoryMock->expects($this->any())->method('create')->willReturn($this->addressMock);
     $this->quoteMock->expects($this->any())->method('isVirtual')->willReturn(false);
     $this->quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($this->addressMock);
     $this->quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($this->addressMock);
     $customerDataMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->disableOriginalConstructor()->getMock();
     $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerDataMock);
     $this->copyObjectMock->expects($this->any())->method('getDataFromFieldset')->willReturn([]);
     $this->dataObjectHelper->expects($this->any())->method('populateWithArray')->willReturnSelf();
     $this->assertInstanceOf('Magento\\Quote\\Model\\Quote', $this->quote->prepareQuoteForNewCustomer($this->quoteMock));
 }
开发者ID:nja78,项目名称:magento2,代码行数:15,代码来源:QuoteTest.php

示例9: testCalculateTax

 public function testCalculateTax()
 {
     $storeId = 3;
     $algorithm = 'algorithm';
     $customerId = 100;
     $taxClassId = 200;
     $taxDetailsData = [\Magento\Tax\Model\TaxDetails\TaxDetails::KEY_SUBTOTAL => 0.0, \Magento\Tax\Model\TaxDetails\TaxDetails::KEY_TAX_AMOUNT => 0.0, \Magento\Tax\Model\TaxDetails\TaxDetails::KEY_DISCOUNT_TAX_COMPENSATION_AMOUNT => 0.0, \Magento\Tax\Model\TaxDetails\TaxDetails::KEY_APPLIED_TAXES => [], \Magento\Tax\Model\TaxDetails\TaxDetails::KEY_ITEMS => []];
     $quoteDetailsMock = $this->getMock('\\Magento\\Tax\\Api\\Data\\QuoteDetailsInterface');
     $storeMock = $this->getMock('\\Magento\\Store\\Model\\Store', ['getStoreId'], [], '', false);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($storeMock);
     $storeMock->expects($this->once())->method('getStoreId')->willReturn($storeId);
     $billAddressMock = $this->getMock('Magento\\Customer\\Api\\Data\\AddressInterface', [], [], '', false);
     $shipAddressMock = $this->getMock('Magento\\Customer\\Api\\Data\\AddressInterface', [], [], '', false);
     $taxClassKeyMock = $this->getMock('\\Magento\\Tax\\Api\\Data\\TaxClassKeyInterface');
     $quoteDetailsItemMock = $this->getMock('\\Magento\\Tax\\Api\\Data\\QuoteDetailsItemInterface');
     $quoteDetailsMock->expects($this->once())->method('getItems')->willReturn([$quoteDetailsItemMock]);
     $quoteDetailsMock->expects($this->once())->method('getBillingAddress')->willReturn($billAddressMock);
     $quoteDetailsMock->expects($this->once())->method('getShippingAddress')->willReturn($shipAddressMock);
     $quoteDetailsMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
     $quoteDetailsMock->expects($this->once())->method('getCustomerTaxClassKey')->willReturn($taxClassKeyMock);
     $this->configMock->expects($this->once())->method('getAlgorithm')->with($storeId)->willReturn($algorithm);
     $this->taxClassManagementMock->expects($this->once())->method('getTaxClassId')->with($taxClassKeyMock, 'customer')->willReturn($taxClassId);
     $calculatorMock = $this->getMock('Magento\\Tax\\Model\\Calculation\\TotalBaseCalculator', [], [], '', false);
     $this->calculatorFactory->expects($this->once())->method('create')->with($algorithm, $storeId, $billAddressMock, $shipAddressMock, $taxClassId, $customerId)->willReturn($calculatorMock);
     $taxDetailsMock = $this->getMock('\\Magento\\Tax\\Api\\Data\\TaxDetailsItemInterface');
     $calculatorMock->expects($this->once())->method('calculate')->willReturn($taxDetailsMock);
     $taxDetailsMock = $this->getMock('\\Magento\\Tax\\Api\\Data\\TaxDetailsInterface');
     $this->taxDetailsDataObjectFactory->expects($this->once())->method('create')->willReturn($taxDetailsMock);
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray')->with($taxDetailsMock, $taxDetailsData)->willReturnSelf();
     $this->assertEquals($taxDetailsMock, $this->taxCalculationService->calculateTax($quoteDetailsMock));
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:31,代码来源:TaxCalculationTest.php

示例10: testSetAccountData

 public function testSetAccountData()
 {
     $taxClassId = 1;
     $attributes = [['email', 'user@example.com'], ['group_id', 1]];
     $attributeMocks = [];
     foreach ($attributes as $attribute) {
         $attributeMock = $this->getMock('Magento\\Customer\\Api\\Data\\AttributeMetadataInterface', [], [], '', false);
         $attributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attribute[0]));
         $attributeMocks[] = $attributeMock;
     }
     $customerGroupMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\GroupInterface', [], '', false, true, true, ['getTaxClassId']);
     $customerGroupMock->expects($this->once())->method('getTaxClassId')->will($this->returnValue($taxClassId));
     $customerFormMock = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false);
     $customerFormMock->expects($this->any())->method('getAttributes')->will($this->returnValue($attributeMocks));
     $customerFormMock->expects($this->any())->method('extractData')->will($this->returnValue([]));
     $customerFormMock->expects($this->any())->method('restoreData')->will($this->returnValue([]));
     $customerFormMock->expects($this->any())->method('prepareRequest')->will($this->returnValue($this->getMock('Magento\\Framework\\App\\RequestInterface')));
     $customerMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->customerMapper->expects($this->atLeastOnce())->method('toFlatArray')->willReturn(['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1]);
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock));
     $quoteMock->expects($this->once())->method('addData')->with(['customer_email' => $attributes[0][1], 'customer_group_id' => $attributes[1][1], 'customer_tax_class_id' => $taxClassId]);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($customerMock, ['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerFormMock));
     $this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
     $this->customerFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerMock));
     $this->groupRepositoryMock->expects($this->once())->method('getById')->will($this->returnValue($customerGroupMock));
     $this->adminOrderCreate->setAccountData([]);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:CreateTest.php

示例11: testGet

 /**
  * @param bool $isVirtual
  * @param string $getAddressType
  * @dataProvider getDataProvider
  */
 public function testGet($isVirtual, $getAddressType)
 {
     $cartId = 12;
     $itemsQty = 100;
     $coupon = 'coupon';
     $addressTotals = ['address' => 'totals'];
     $itemMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Item', [], [], '', false);
     $visibleItems = [11 => $itemMock];
     $itemArray = ['name' => 'item', 'options' => [4 => ['label' => 'justLabel']]];
     $currencyCode = 'US';
     $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId)->willReturn($this->quoteMock);
     $this->quoteMock->expects($this->once())->method('isVirtual')->willReturn($isVirtual);
     $this->quoteMock->expects($this->exactly(2))->method($getAddressType)->willReturn($this->addressMock);
     $this->quoteMock->expects($this->once())->method('getAllVisibleItems')->willReturn($visibleItems);
     $this->quoteMock->expects($this->once())->method('getBaseCurrencyCode')->willReturn($currencyCode);
     $this->quoteMock->expects($this->once())->method('getQuoteCurrencyCode')->willReturn($currencyCode);
     $this->quoteMock->expects($this->once())->method('getItemsQty')->willReturn($itemsQty);
     $this->addressMock->expects($this->any())->method('getData')->willReturn($addressTotals);
     $this->addressMock->expects($this->once())->method('getTotals')->willReturn($addressTotals);
     $totalsMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\TotalsInterface');
     $this->totalsFactoryMock->expects($this->once())->method('create')->willReturn($totalsMock);
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray');
     $this->converterMock->expects($this->once())->method('modelToDataObject')->with($itemMock)->willReturn($itemArray);
     $totalSegmentsMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\TotalSegmentInterface');
     $this->totalsConverterMock->expects($this->once())->method('process')->with($addressTotals)->willReturn($totalSegmentsMock);
     $this->couponServiceMock->expects($this->once())->method('get')->with($cartId)->willReturn($coupon);
     $totalsMock->expects($this->once())->method('setItems')->with([11 => $itemArray])->willReturnSelf();
     $totalsMock->expects($this->once())->method('setTotalSegments')->with($totalSegmentsMock)->willReturnSelf();
     $totalsMock->expects($this->once())->method('setCouponCode')->with($coupon)->willReturnSelf();
     $totalsMock->expects($this->once())->method('setGrandTotal')->willReturnSelf();
     $totalsMock->expects($this->once())->method('setItemsQty')->with($itemsQty)->willReturnSelf();
     $totalsMock->expects($this->once())->method('setBaseCurrencyCode')->with($currencyCode)->willReturnSelf();
     $totalsMock->expects($this->once())->method('setQuoteCurrencyCode')->with($currencyCode)->willReturnSelf();
     $this->assertEquals($totalsMock, $this->model->get($cartId));
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:40,代码来源:CartTotalRepositoryTest.php

示例12: testConvert

    public function testConvert()
    {
        $orderData = ['test' => 'test1'];
        $data = ['test' => 'beer'];
        $quoteId = 1;
        $storeId = 777;

        $object = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false);
        $quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false);
        $object->expects($this->exactly(5))->method('getQuote')->willReturn($quote);
        $quote->expects($this->once())->method('getId')->willReturn($quoteId);
        $quote->expects($this->once())->method('getStoreId')->willReturn($storeId);
        $this->objectCopyMock->expects($this->once())->method('getDataFromFieldset')->with(
            'quote_convert_address',
            'to_order',
            $object
        )->willReturn($orderData);
        $this->dataObjectHelper->expects($this->once())->method('populateWithArray')
            ->with($this->orderMock, ['test' => 'beer'], '\Magento\Sales\Api\Data\OrderInterface')
            ->willReturnSelf();
        $this->orderMock->expects($this->once())->method('setStoreId')->with($storeId)->willReturnSelf();
        $this->orderMock->expects($this->once())->method('setQuoteId')->with($quoteId)->willReturnSelf();
        $this->orderDataFactoryMock->expects($this->once())->method('create')->willReturn($this->orderMock);
        $this->eventManagerMock->expects($this->once())
            ->method('dispatch')
            ->with('sales_convert_quote_to_order', ['order' => $this->orderMock, 'quote' => $quote]);
        $this->assertSame($this->orderMock, $this->converter->convert($object, $data));
    }
开发者ID:razbakov,项目名称:magento2,代码行数:28,代码来源:ToOrderTest.php

示例13: prepareMocksForUpdateDefaultBilling

 protected function prepareMocksForUpdateDefaultBilling()
 {
     $this->prepareMocksForProcessAddressData();
     $addressData = ['postcode' => '07294', 'firstname' => 'Firstname', 'lastname' => 'Lastname'];
     $this->customerData->expects($this->once())->method('getAddresses')->willReturn([$this->address]);
     $this->address->expects($this->once())->method('isDefaultBilling')->willReturn(true);
     $this->dataObjectHelper->expects($this->at(0))->method('populateWithArray')->with($this->address, $addressData, '\\Magento\\Customer\\Api\\Data\\AddressInterface');
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:8,代码来源:InlineEditTest.php

示例14: testExtract

 public function testExtract()
 {
     $customerData = ['firstname' => 'firstname', 'lastname' => 'firstname', 'email' => 'email.example.com'];
     $this->formFactory->expects($this->once())->method('create')->with('customer', 'form-code')->willReturn($this->customerForm);
     $this->customerForm->expects($this->once())->method('extractData')->with($this->request)->willReturn($customerData);
     $this->customerForm->expects($this->once())->method('getAllowedAttributes')->willReturn(['group_id' => 'attribute object']);
     $this->customerFactory->expects($this->once())->method('create')->willReturn($this->customerData);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($this->customerData, $customerData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn($this->customerData);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($this->store);
     $this->store->expects($this->exactly(2))->method('getId')->willReturn(1);
     $this->customerGroupManagement->expects($this->once())->method('getDefaultGroup')->with(1)->willReturn($this->customerGroup);
     $this->customerGroup->expects($this->once())->method('getId')->willReturn(1);
     $this->customerData->expects($this->once())->method('setGroupId')->with(1);
     $this->store->expects($this->once())->method('getWebsiteId')->willReturn(1);
     $this->customerData->expects($this->once())->method('setWebsiteId')->with(1);
     $this->customerData->expects($this->once())->method('setStoreId')->with(1);
     $this->assertSame($this->customerData, $this->customerExtractor->extract('form-code', $this->request));
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:18,代码来源:CustomerExtractorTest.php

示例15: testGet

 public function testGet()
 {
     $cartId = 12;
     $itemMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Item', [], [], '', false);
     $visibleItems = [11 => $itemMock];
     $itemArray = ['name' => 'item', 'options' => [4 => ['label' => 'justLabel']]];
     $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
     $this->quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($this->addressMock);
     $this->addressMock->expects($this->once())->method('getData')->willReturn(['addressData']);
     $this->quoteMock->expects($this->once())->method('getData')->willReturn(['quoteData']);
     $this->quoteMock->expects($this->once())->method('getAllVisibleItems')->willReturn($visibleItems);
     $totalsMock = $this->getMock('Magento\\Quote\\Model\\Cart\\Totals', ['setItems'], [], '', false);
     $this->totalsFactoryMock->expects($this->once())->method('create')->willReturn($totalsMock);
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray');
     $this->converterMock->expects($this->once())->method('modelToDataObject')->with($itemMock)->willReturn($itemArray);
     //back in get()
     $totalsMock->expects($this->once())->method('setItems')->with([11 => $itemArray]);
     $this->assertEquals($totalsMock, $this->model->get($cartId));
 }
开发者ID:nja78,项目名称:magento2,代码行数:19,代码来源:CartTotalRepositoryTest.php


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