예제 #1
0
 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]);
 }
 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]);
 }
예제 #3
0
 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());
 }
 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));
 }
예제 #5
0
 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));
 }
 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));
 }
 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);
 }
예제 #8
0
 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));
 }
예제 #9
0
 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));
 }
예제 #10
0
 public function testSetAccountData()
 {
     $taxClassId = 1;
     $attributes = [['email', '*****@*****.**'], ['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' => '*****@*****.**', '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' => '*****@*****.**', '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([]);
 }
 /**
  * @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));
 }
예제 #12
0
    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));
    }
 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');
 }
예제 #14
0
 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));
 }
예제 #15
0
 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));
 }
예제 #16
0
 /**
  * @expectedException \Magento\Framework\Exception\InputException
  * @expectedExceptionMessage Cannot recognize image extension.
  */
 public function testSaveWithoutFileExtension()
 {
     $imageContent = $this->getMockBuilder('Magento\\Framework\\Api\\Data\\ImageContentInterface')->disableOriginalConstructor()->getMock();
     $imageContent->expects($this->once())->method('getBase64EncodedData')->willReturn('testImageData');
     $imageContent->expects($this->once())->method('getName')->willReturn('testFileName');
     $imageDataObject = $this->getMockBuilder('Magento\\Framework\\Api\\AttributeValue')->disableOriginalConstructor()->getMock();
     $imageDataObject->expects($this->once())->method('getValue')->willReturn($imageContent);
     $imageData = $this->getMockForAbstractClass('Magento\\Framework\\Api\\CustomAttributesDataInterface');
     $imageData->expects($this->once())->method('getCustomAttributes')->willReturn([]);
     $this->dataObjectHelperMock->expects($this->once())->method('getCustomAttributeValueByType')->willReturn([$imageDataObject]);
     $this->contentValidatorMock->expects($this->once())->method('isValid')->willReturn(true);
     $this->assertEquals($imageData, $this->imageProcessor->save($imageData, 'testEntityType'));
 }
예제 #17
0
 /**
  * @covers \Magento\Customer\Controller\Adminhtml\Index\Index::execute
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testExecuteWithNewCustomer()
 {
     $customerId = 22;
     $addressId = 11;
     $subscription = 'false';
     $postValue = ['customer' => ['coolness' => false, 'disable_auto_group_change' => 'false'], 'address' => ['_template_' => '_template_', $addressId => ['entity_id' => $addressId, 'default_billing' => 'false', 'default_shipping' => 'false', 'code' => 'value', 'coolness' => false, 'region' => 'region', 'region_id' => 'region_id']], 'subscription' => $subscription];
     $filteredData = ['coolness' => false, 'disable_auto_group_change' => 'false'];
     $addressFilteredData = ['entity_id' => $addressId, 'default_billing' => 'false', 'default_shipping' => 'false', 'code' => 'value', 'coolness' => false, 'region' => 'region', 'region_id' => 'region_id'];
     $mergedData = ['disable_auto_group_change' => 0, \Magento\Customer\Api\Data\CustomerInterface::DEFAULT_BILLING => null, \Magento\Customer\Api\Data\CustomerInterface::DEFAULT_SHIPPING => null, 'confirmation' => false];
     $mergedAddressData = ['entity_id' => $addressId, 'default_billing' => false, 'default_shipping' => false, 'code' => 'value', 'region' => ['region' => 'region', 'region_id' => 'region_id'], 'region_id' => 'region_id', 'id' => $addressId];
     /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $formMock */
     $attributeMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AttributeMetadataInterface')->disableOriginalConstructor()->getMock();
     $attributeMock->expects($this->exactly(2))->method('getAttributeCode')->willReturn('coolness');
     $attributeMock->expects($this->exactly(2))->method('getFrontendInput')->willReturn('int');
     $attributes = [$attributeMock];
     $this->requestMock->expects($this->exactly(3))->method('getPostValue')->willReturn($postValue);
     $this->requestMock->expects($this->exactly(3))->method('getPost')->willReturnMap([['customer', null, $postValue['customer']], ['address', null, $postValue['address']], ['subscription', null, $subscription]]);
     /** @var \Magento\Customer\Model\Metadata\Form|\PHPUnit_Framework_MockObject_MockObject $formMock */
     $formMock = $this->getMockBuilder('Magento\\Customer\\Model\\Metadata\\Form')->disableOriginalConstructor()->getMock();
     $this->formFactoryMock->expects($this->exactly(2))->method('create')->willReturnMap([[\Magento\Customer\Api\CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, 'adminhtml_customer', [], false, \Magento\Customer\Model\Metadata\Form::DONT_IGNORE_INVISIBLE, [], $formMock], [\Magento\Customer\Api\AddressMetadataInterface::ENTITY_TYPE_ADDRESS, 'adminhtml_customer_address', [], false, \Magento\Customer\Model\Metadata\Form::DONT_IGNORE_INVISIBLE, [], $formMock]]);
     $formMock->expects($this->exactly(2))->method('extractData')->willReturnMap([[$this->requestMock, 'customer', true, $filteredData], [$this->requestMock, 'address/' . $addressId, true, $addressFilteredData]]);
     /** @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject $objectMock */
     $objectMock = $this->getMockBuilder('Magento\\Framework\\DataObject')->disableOriginalConstructor()->getMock();
     $this->objectFactoryMock->expects($this->exactly(2))->method('create')->with(['data' => $postValue])->willReturn($objectMock);
     $objectMock->expects($this->exactly(2))->method('getData')->willReturnMap([['customer', null, $postValue['customer']], ['address/' . $addressId, null, $postValue['address'][$addressId]]]);
     $formMock->expects($this->exactly(2))->method('getAttributes')->willReturn($attributes);
     /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->disableOriginalConstructor()->getMock();
     $this->customerDataFactoryMock->expects($this->once())->method('create')->willReturn($customerMock);
     $addressMock = $this->getMockBuilder('\\Magento\\Customer\\Api\\Data\\AddressInterface')->disableOriginalConstructor()->getMock();
     $this->addressDataFactoryMock->expects($this->once())->method('create')->willReturn($addressMock);
     $this->dataHelperMock->expects($this->exactly(2))->method('populateWithArray')->willReturnMap([[$customerMock, $mergedData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface', $this->dataHelperMock], [$addressMock, $mergedAddressData, '\\Magento\\Customer\\Api\\Data\\AddressInterface', $this->dataHelperMock]]);
     $this->managementMock->expects($this->once())->method('createAccount')->with($customerMock, null, '')->willReturn($customerMock);
     $customerMock->expects($this->once())->method('getId')->willReturn($customerId);
     $this->authorizationMock->expects($this->once())->method('isAllowed')->with(null)->willReturn(true);
     /** @var \Magento\Newsletter\Model\Subscriber|\PHPUnit_Framework_MockObject_MockObject $subscriberMock */
     $subscriberMock = $this->getMockBuilder('Magento\\Newsletter\\Model\\Subscriber')->disableOriginalConstructor()->getMock();
     $this->subscriberFactoryMock->expects($this->once())->method('create')->with()->willReturn($subscriberMock);
     $subscriberMock->expects($this->once())->method('unsubscribeCustomerById')->with($customerId);
     $subscriberMock->expects($this->never())->method('subscribeCustomerById');
     $this->sessionMock->expects($this->once())->method('unsCustomerData');
     $this->registryMock->expects($this->once())->method('register')->with(\Magento\Customer\Controller\RegistryConstants::CURRENT_CUSTOMER_ID, $customerId);
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('You saved the customer.'))->willReturnSelf();
     $this->requestMock->expects($this->once())->method('getParam')->with('back', false)->willReturn(false);
     /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
     $redirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->redirectFactoryMock->expects($this->once())->method('create')->willReturn($redirectMock);
     $redirectMock->expects($this->once())->method('setPath')->with('customer/index', [])->willReturnSelf();
     $this->assertEquals($redirectMock, $this->model->execute());
 }
 public function testGet()
 {
     $productSku = 'testProduct';
     $imageId = 42;
     $images = [['value_id' => 42, 'types' => [], 'file' => 'file.jpg']];
     $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)->willReturn($this->productMock);
     $this->productMock->expects($this->once())->method('getMediaAttributes')->willReturn(['code' => 0]);
     $this->productMock->expects($this->once())->method('getData')->with('code')->willReturn('codeValue');
     $this->productMock->expects($this->once())->method('getMediaGallery')->with('images')->willReturn($images);
     $entryMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductAttributeMediaGalleryEntryInterface');
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray')->with($entryMock, $images[0], '\\Magento\\Catalog\\Api\\Data\\ProductAttributeMediaGalleryEntryInterface')->willReturnSelf();
     $this->entryFactoryMock->expects($this->once())->method('create')->willReturn($entryMock);
     $this->assertEquals($entryMock, $this->model->get($productSku, $imageId));
 }
예제 #19
0
 /**
  * Tests Convert method in payment to order payment converter
  */
 public function testConvert()
 {
     $methodInterface = $this->getMockForAbstractClass('Magento\\Payment\\Model\\MethodInterface');
     $paymentData = ['test' => 'test2'];
     $data = ['some_id' => 1];
     $paymentMethodTitle = 'TestTitle';
     $additionalInfo = ['token' => 'TOKEN-123'];
     $this->paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInterface);
     $methodInterface->expects($this->once())->method('getTitle')->willReturn($paymentMethodTitle);
     $this->objectCopyMock->expects($this->once())->method('getDataFromFieldset')->with('quote_convert_payment', 'to_order_payment', $this->paymentMock)->willReturn($paymentData);
     $this->paymentMock->expects($this->once())->method('getAdditionalInformation')->willReturn($additionalInfo);
     $ccNumber = 123456798;
     $ccCid = 1234;
     $this->paymentMock->expects($this->once())->method('getCcNumber')->willReturn($ccNumber);
     $this->paymentMock->expects($this->once())->method('getCcCid')->willReturn($ccCid);
     $orderPayment = $this->getMockForAbstractClass('Magento\\Sales\\Api\\Data\\OrderPaymentInterface', [], '', false, true, true, ['setCcNumber', 'setCcCid', 'setAdditionalInformation']);
     $orderPayment->expects($this->once())->method('setAdditionalInformation')->with(array_merge($additionalInfo, [Substitution::INFO_KEY_TITLE => $paymentMethodTitle]))->willReturnSelf();
     $orderPayment->expects($this->once())->method('setCcNumber')->willReturnSelf();
     $orderPayment->expects($this->once())->method('setCcCid')->willReturnSelf();
     $this->orderPaymentRepositoryMock->expects($this->once())->method('create')->willReturn($orderPayment);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($orderPayment, array_merge($paymentData, $data), '\\Magento\\Sales\\Api\\Data\\OrderPaymentInterface')->willReturnSelf();
     $this->assertSame($orderPayment, $this->converter->convert($this->paymentMock, $data));
 }
예제 #20
0
 public function testSetLayoutWithOwnAddressAndPostedData()
 {
     $addressId = 1;
     $customerId = 1;
     $title = __('Edit Address');
     $postedData = ['region_id' => 1, 'region' => 'region'];
     $newPostedData = $postedData;
     $newPostedData['region'] = $postedData;
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->getMock();
     $this->requestMock->expects($this->once())->method('getParam')->with('id', null)->willReturn($addressId);
     $addressMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->getMock();
     $this->addressRepositoryMock->expects($this->once())->method('getById')->with($addressId)->willReturn($addressMock);
     $addressMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
     $this->customerSessionMock->expects($this->at(0))->method('getCustomerId')->willReturn($customerId);
     $addressMock->expects($this->exactly(2))->method('getId')->willReturn($addressId);
     $pageTitleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($pageTitleMock);
     $pageTitleMock->expects($this->once())->method('set')->with($title)->willReturnSelf();
     $this->customerSessionMock->expects($this->at(1))->method('getAddressFormData')->with(true)->willReturn($postedData);
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray')->with($addressMock, $newPostedData, '\\Magento\\Customer\\Api\\Data\\AddressInterface')->willReturnSelf();
     $this->assertEquals($this->model, $this->model->setLayout($layoutMock));
     $this->assertEquals($layoutMock, $this->model->getLayout());
 }
예제 #21
0
파일: SaveTest.php 프로젝트: nja78/magento2
 /**
  * @covers \Magento\Customer\Controller\Adminhtml\Index\Index::execute
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testExecuteWithExistentCustomerAndNoAddresses()
 {
     $customerId = 22;
     $subscription = 'true';
     $postValue = ['customer' => ['entity_id' => $customerId, 'coolness' => false, 'disable_auto_group_change' => 'false'], 'subscription' => $subscription];
     $filteredData = ['entity_id' => $customerId, 'coolness' => false, 'disable_auto_group_change' => 'false'];
     $savedData = ['entity_id' => $customerId, 'darkness' => true, 'name' => 'Name'];
     $mergedData = ['entity_id' => $customerId, 'darkness' => true, 'name' => 'Name', 'disable_auto_group_change' => 0, \Magento\Customer\Api\Data\CustomerInterface::DEFAULT_BILLING => false, \Magento\Customer\Api\Data\CustomerInterface::DEFAULT_SHIPPING => false, 'confirmation' => false, 'sendemail' => false, 'id' => $customerId];
     /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $formMock */
     $attributeMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AttributeMetadataInterface')->disableOriginalConstructor()->getMock();
     $attributeMock->expects($this->once())->method('getAttributeCode')->willReturn('coolness');
     $attributeMock->expects($this->once())->method('getFrontendInput')->willReturn('int');
     $attributes = [$attributeMock];
     $this->requestMock->expects($this->exactly(2))->method('getPostValue')->willReturn($postValue);
     $this->requestMock->expects($this->exactly(3))->method('getPost')->willReturnMap([['customer', null, $postValue['customer']], ['address', null, null], ['subscription', null, $subscription]]);
     /** @var \Magento\Customer\Model\Metadata\Form|\PHPUnit_Framework_MockObject_MockObject $formMock */
     $formMock = $this->getMockBuilder('Magento\\Customer\\Model\\Metadata\\Form')->disableOriginalConstructor()->getMock();
     $this->formFactoryMock->expects($this->once())->method('create')->with(\Magento\Customer\Api\CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, 'adminhtml_customer', [], false, \Magento\Customer\Model\Metadata\Form::DONT_IGNORE_INVISIBLE)->willReturn($formMock);
     $formMock->expects($this->once())->method('extractData')->with($this->requestMock, 'customer')->willReturn($filteredData);
     /** @var \Magento\Framework\Object|\PHPUnit_Framework_MockObject_MockObject $objectMock */
     $objectMock = $this->getMockBuilder('Magento\\Framework\\Object')->disableOriginalConstructor()->getMock();
     $this->objectFactoryMock->expects($this->once())->method('create')->with(['data' => $postValue])->willReturn($objectMock);
     $objectMock->expects($this->once())->method('getData')->with('customer')->willReturn($postValue['customer']);
     $formMock->expects($this->once())->method('getAttributes')->willReturn($attributes);
     /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->disableOriginalConstructor()->getMock();
     $this->customerDataFactoryMock->expects($this->once())->method('create')->willReturn($customerMock);
     $this->customerRepositoryMock->expects($this->once())->method('getById')->with($customerId)->willReturn($customerMock);
     $this->customerMapperMock->expects($this->once())->method('toFlatArray')->with($customerMock)->willReturn($savedData);
     $this->dataHelperMock->expects($this->once())->method('populateWithArray')->with($customerMock, $mergedData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturnSelf();
     $this->customerRepositoryMock->expects($this->once())->method('save')->with($customerMock)->willReturnSelf();
     $this->authorizationMock->expects($this->once())->method('isAllowed')->with(null)->willReturn(true);
     /** @var \Magento\Newsletter\Model\Subscriber|\PHPUnit_Framework_MockObject_MockObject $subscriberMock */
     $subscriberMock = $this->getMockBuilder('Magento\\Newsletter\\Model\\Subscriber')->disableOriginalConstructor()->getMock();
     $this->subscriberFactoryMock->expects($this->once())->method('create')->with()->willReturn($subscriberMock);
     $subscriberMock->expects($this->once())->method('subscribeCustomerById')->with($customerId);
     $subscriberMock->expects($this->never())->method('unsubscribeCustomerById');
     $this->sessionMock->expects($this->once())->method('unsCustomerData');
     $this->registryMock->expects($this->once())->method('register')->with(\Magento\Customer\Controller\RegistryConstants::CURRENT_CUSTOMER_ID, $customerId);
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('You saved the customer.'))->willReturnSelf();
     $this->requestMock->expects($this->once())->method('getParam')->with('back', false)->willReturn(true);
     /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
     $redirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->redirectFactoryMock->expects($this->once())->method('create')->with([])->willReturn($redirectMock);
     $redirectMock->expects($this->once())->method('setPath')->with('customer/*/edit', ['id' => $customerId, '_current' => true])->willReturn(true);
     $this->assertEquals($redirectMock, $this->model->execute());
 }
예제 #22
0
 /**
  * @param $customerData
  * @param $isSingleStoreMode
  * @param $canModifyCustomer
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 private function _setupStoreMode($customerData, $isSingleStoreMode, $canModifyCustomer)
 {
     $backendSessionMock = $this->getMock('\\Magento\\Backend\\Model\\Session', ['getCustomerData'], [], '', false);
     $backendSessionMock->expects($this->any())->method('getCustomerData')->will($this->returnValue([]));
     $layoutMock = $this->getMock('\\Magento\\Framework\\View\\Layout\\Element\\Layout', ['createBlock'], [], '', false);
     $layoutMock->expects($this->at(0))->method('createBlock')->with('Magento\\Customer\\Block\\Adminhtml\\Edit\\Renderer\\Attribute\\Group')->will($this->returnValue($this->objectManagerHelper->getObject('Magento\\Customer\\Block\\Adminhtml\\Edit\\Renderer\\Attribute\\Group')));
     $layoutMock->expects($this->at(1))->method('createBlock')->with('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element')->will($this->returnValue($this->objectManagerHelper->getObject('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element')));
     if (empty($customerData['id'])) {
         $layoutMock->expects($this->at(2))->method('createBlock')->with('Magento\\Customer\\Block\\Adminhtml\\Edit\\Renderer\\Attribute\\Sendemail')->will($this->returnValue($this->objectManagerHelper->getObject('Magento\\Customer\\Block\\Adminhtml\\Edit\\Renderer\\Attribute\\Sendemail')));
     }
     $urlBuilderMock = $this->getMock('\\Magento\\Backend\\Model\\Url', ['getBaseUrl'], [], '', false);
     $urlBuilderMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('someUrl'));
     $storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false);
     $storeManagerMock->expects($this->any())->method('isSingleStoreMode')->will($this->returnValue($isSingleStoreMode));
     $customerObject = $this->getMock('\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     if (!empty($customerData['id'])) {
         $customerObject->expects($this->any())->method('getId')->will($this->returnValue($customerData['id']));
     }
     $fieldset = $this->getMockBuilder('\\Magento\\Framework\\Data\\Form\\Element\\Fieldset')->setMethods(['getForm', 'addField', 'removeField'])->disableOriginalConstructor()->getMock();
     $accountForm = $this->getMockBuilder('Magento\\Framework\\Data\\Form')->setMethods(['create', 'addFieldset', 'getElement', 'setValues'])->disableOriginalConstructor()->getMock();
     $accountForm->expects($this->any())->method('addFieldset')->with('base_fieldset')->will($this->returnValue($fieldset));
     $accountForm->expects($this->any())->method('setValues')->will($this->returnValue($accountForm));
     $fieldset->expects($this->any())->method('getForm')->will($this->returnValue($accountForm));
     $formElement = $this->getMockBuilder('\\Magento\\Framework\\Data\\Form\\Element\\Select')->setMethods(['setRenderer', 'addClass', 'setDisabled'])->disableOriginalConstructor()->getMock();
     $formElement->expects($this->any())->method('setRenderer')->will($this->returnValue(null));
     $formElement->expects($this->any())->method('addClass')->will($this->returnValue(null));
     $formElement->expects($this->any())->method('setDisabled')->will($this->returnValue(null));
     $accountForm->expects($this->any())->method('getElement')->withAnyParameters()->will($this->returnValue($formElement));
     $fieldset->expects($this->any())->method('addField')->will($this->returnValue($formElement));
     $customerForm = $this->getMock('\\Magento\\Customer\\Model\\Metadata\\Form', ['getAttributes'], [], '', false);
     $customerForm->expects($this->any())->method('getAttributes')->will($this->returnValue([]));
     $this->contextMock->expects($this->any())->method('getBackendSession')->will($this->returnValue($backendSessionMock));
     $this->contextMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->contextMock->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($urlBuilderMock));
     $this->contextMock->expects($this->any())->method('getStoreManager')->will($this->returnValue($storeManagerMock));
     $this->customerFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerObject));
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray');
     $this->options->expects($this->any())->method('getNamePrefixOptions')->will($this->returnValue(['Pref1', 'Pref2']));
     $this->options->expects($this->any())->method('getNameSuffixOptions')->will($this->returnValue(['Suf1', 'Suf2']));
     $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($accountForm));
     $this->extensibleDataObjectConverterMock->expects($this->any())->method('toFlatArray')->will($this->returnValue($customerData));
     $this->customerFormFactoryMock->expects($this->any())->method('create')->with('customer', 'adminhtml_customer', $this->extensibleDataObjectConverterMock->toFlatArray($customerObject, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface'))->will($this->returnValue($customerForm));
     $this->accountManagementMock->expects($this->any())->method('isReadOnly')->withAnyParameters()->will($this->returnValue(!$canModifyCustomer));
     $this->accountManagementMock->expects($this->any())->method('getConfirmationStatus')->withAnyParameters()->will($this->returnValue(AccountManagementInterface::ACCOUNT_CONFIRMED));
 }
 /**
  * @test
  */
 public function testGetList()
 {
     $field = 'name';
     $value = 'magento';
     $condition = 'eq';
     $total = 10;
     $currentPage = 3;
     $pageSize = 2;
     $sortField = 'id';
     $criteria = $this->getMockBuilder('Magento\\Framework\\Api\\SearchCriteriaInterface')->getMock();
     $filterGroup = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\FilterGroup')->getMock();
     $filter = $this->getMockBuilder('Magento\\Framework\\Api\\Filter')->getMock();
     $storeFilter = $this->getMockBuilder('Magento\\Framework\\Api\\Filter')->getMock();
     $sortOrder = $this->getMockBuilder('Magento\\Framework\\Api\\SortOrder')->getMock();
     $criteria->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroup]);
     $criteria->expects($this->once())->method('getSortOrders')->willReturn([$sortOrder]);
     $criteria->expects($this->once())->method('getCurrentPage')->willReturn($currentPage);
     $criteria->expects($this->once())->method('getPageSize')->willReturn($pageSize);
     $filterGroup->expects($this->once())->method('getFilters')->willReturn([$storeFilter, $filter]);
     $filter->expects($this->once())->method('getConditionType')->willReturn($condition);
     $filter->expects($this->any())->method('getField')->willReturn($field);
     $filter->expects($this->once())->method('getValue')->willReturn($value);
     $storeFilter->expects($this->any())->method('getField')->willReturn('store_id');
     $storeFilter->expects($this->once())->method('getValue')->willReturn(1);
     $sortOrder->expects($this->once())->method('getField')->willReturn($sortField);
     $sortOrder->expects($this->once())->method('getDirection')->willReturn(SortOrder::SORT_DESC);
     /** @var \Magento\Framework\Api\SearchCriteriaInterface $criteria */
     $this->collection->addItem($this->block);
     $this->blockSearchResult->expects($this->once())->method('setSearchCriteria')->with($criteria)->willReturnSelf();
     $this->collection->expects($this->once())->method('addFieldToFilter')->with($field, [$condition => $value])->willReturnSelf();
     $this->blockSearchResult->expects($this->once())->method('setTotalCount')->with($total)->willReturnSelf();
     $this->collection->expects($this->once())->method('getSize')->willReturn($total);
     $this->collection->expects($this->once())->method('setCurPage')->with($currentPage)->willReturnSelf();
     $this->collection->expects($this->once())->method('setPageSize')->with($pageSize)->willReturnSelf();
     $this->collection->expects($this->once())->method('addOrder')->with($sortField, 'DESC')->willReturnSelf();
     $this->block->expects($this->once())->method('getData')->willReturn(['data']);
     $this->blockSearchResult->expects($this->once())->method('setItems')->with(['someData'])->willReturnSelf();
     $this->dataHelper->expects($this->once())->method('populateWithArray')->with($this->blockData, ['data'], 'Magento\\Cms\\Api\\Data\\BlockInterface');
     $this->dataObjectProcessor->expects($this->once())->method('buildOutputDataArray')->with($this->blockData, 'Magento\\Cms\\Api\\Data\\BlockInterface')->willReturn('someData');
     $this->assertEquals($this->blockSearchResult, $this->repository->getList($criteria));
 }