示例#1
0
 public function testExportContextData()
 {
     $info = [];
     $id = 1;
     $salesOrderId = 1;
     $sku = 'sku';
     $orderNr = 'order nr';
     $ventureOrderNr = 'venture order nr';
     $status = 'active';
     $reason = 'reason';
     $reasonDetail = 'reason detail';
     $price = 100.0;
     $items = [];
     $item = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Order\\Item', $this);
     $item->method('getId')->willReturn($salesOrderId);
     $item->method('getVentureId')->willReturn($salesOrderId);
     $item->method('getSku')->willReturn($sku);
     $item->method('getStatus')->willReturn($status);
     $item->method('getReason')->willReturn($reason);
     $item->method('getPrice')->willReturn($price);
     $item->method('getReasonDetail')->willReturn($reasonDetail);
     $exportedData = ['name' => 'gfg.dtomarketplace.context.venture.order.confirmorder', 'info' => $info, 'hash' => $this->context->getHash(), 'data_wrapper' => get_class($this->dw), 'data' => ['order_nr' => $orderNr, 'venture_order_nr' => $ventureOrderNr, 'status' => $status, 'reason' => $reason, 'reason_detail' => $reasonDetail, 'item_collection' => [['id' => $id, 'venture_id' => $salesOrderId, 'sku' => $sku, 'status' => $status, 'reason' => $reason, 'reason_detail' => $reasonDetail]]]];
     $this->dw->method('getOrderNr')->willReturn($orderNr);
     $this->dw->method('getVentureOrderNr')->willReturn($ventureOrderNr);
     $this->dw->method('getStatus')->willReturn($status);
     $this->dw->method('getReason')->willReturn($reason);
     $this->dw->method('getReasonDetail')->willReturn($reasonDetail);
     $this->dw->method('getItemCollection')->willReturn([$item]);
     $this->assertSame($exportedData, $this->context->exportContextData());
 }
示例#2
0
 public function testExportContextData()
 {
     $simple = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Catalog\\Simple', $this);
     $image = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Catalog\\Image', $this);
     //data
     $info = [];
     //config
     $sku = 'sku config';
     $skuSimple = 'sku simple';
     $name = 'name';
     $description = 'description';
     $brand = 'brand';
     $price = 100.0;
     $quantity = 1;
     $ean = 'ean';
     $url = 'http://site.com/image.jpg';
     $position = 1;
     $variation = 'variation';
     $specialPrice = 50.0;
     $specialFromDate = '2015-01-01';
     $specialToDate = '2015-02-01';
     $attributes = ['attribute1' => 'Attribute'];
     $skuSimple = 'sku simple';
     $variation = 'variation';
     $quantity = 2;
     $ean = 'ean';
     $attributeSet = 2;
     $imageCollection = [['url' => $url, 'position' => $position]];
     $simpleCollection = [['sku' => $skuSimple, 'partner_sku' => $skuSimple, 'variation' => $variation, 'quantity' => $quantity, 'ean' => $ean, 'attributes' => null]];
     //simple
     $exportedData = ['name' => 'gfg.dtomarketplace.context.venture.product.create', 'info' => $info, 'hash' => $this->context->getHash(), 'data_wrapper' => get_class($this->dw), 'data' => ['sku' => $sku, 'partner_sku' => $sku, 'name' => $name, 'description' => $description, 'brand' => $brand, 'price' => $price, 'special_price' => $specialPrice, 'special_from_date' => $specialFromDate, 'special_to_date' => $specialToDate, 'attributes' => $attributes, 'attribute_set' => $attributeSet, 'image_collection' => $imageCollection, 'simple_collection' => $simpleCollection]];
     $image->method('getUrl')->willReturn($url);
     $image->method('getPosition')->willReturn($position);
     $simple->method('getSku')->willReturn($skuSimple);
     $simple->method('getPartnerSku')->willReturn($skuSimple);
     $simple->method('getVariation')->willReturn($variation);
     $simple->method('getQuantity')->willReturn($quantity);
     $simple->method('getEan')->willReturn($ean);
     $this->dw->method('getSku')->willReturn($sku);
     $this->dw->method('getPartnerSku')->willReturn($sku);
     $this->dw->method('getName')->willReturn($name);
     $this->dw->method('getDescription')->willReturn($description);
     $this->dw->method('getbrand')->willReturn($brand);
     $this->dw->method('getPrice')->willReturn($price);
     $this->dw->method('getSpecialPrice')->willReturn($specialPrice);
     $this->dw->method('getSpecialFromDate')->willReturn($specialFromDate);
     $this->dw->method('getSpecialToDate')->willReturn($specialToDate);
     $this->dw->method('getAttributes')->willReturn($attributes);
     $this->dw->method('getAttributeSet')->willReturn($attributeSet);
     $this->dw->method('getSimpleCollection')->willReturn([$simple]);
     $this->dw->method('getImageCollection')->willReturn([$image]);
     $this->assertSame($exportedData, $this->context->exportContextData());
 }
示例#3
0
 public function testExportContextData()
 {
     $item = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\PostPayment\\Item', $this);
     $hash = 'hash';
     $info = [];
     $ventureOrderNr = 1234;
     $ventureOrderItemId = 321;
     $exportedData = ['name' => 'gfg.dtomarketplace.context.venture.postpayment.deliver', 'info' => $info, 'hash' => $this->context->getHash(), 'data_wrapper' => get_class($this->dw), 'data' => ['venture_order_nr' => $ventureOrderNr, 'order_nr' => null, 'item_collection' => [['venture_order_item_id' => $ventureOrderItemId, 'order_item_id' => null]]]];
     $item->method('getVentureOrderItemId')->willReturn($ventureOrderItemId);
     $this->dw->method('getVentureOrderNr')->willReturn($ventureOrderNr);
     $this->dw->method('getItemCollection')->willReturn([$item]);
     $this->assertSame($exportedData, $this->context->exportContextData());
 }
示例#4
0
 public function testExportContextData()
 {
     //dataWrappers
     $image = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Catalog\\Image', $this);
     $simple = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Catalog\\Simple', $this);
     //data
     $info = [];
     //config
     $sku = 'sku';
     $name = 'Product name';
     $description = 'Description';
     $brand = 'Brand';
     $attributes = ['attribute 1' => 1];
     $attributeSet = 2;
     $status = 'active';
     $shipmentType = '1';
     $supplierDeliveryTime = '100';
     //image
     $url = 'http://site.com/image.jpg';
     $position = 1;
     //simple
     $simpleSku = 'simple sku';
     $variation = 'variation';
     $ean = 'ean';
     $simpleStatus = 'inactive';
     $exportedData = ['name' => 'gfg.dtomarketplace.context.venture.product.update', 'info' => $info, 'hash' => $this->context->getHash(), 'data_wrapper' => get_class($this->dw), 'data' => ['sku' => $sku, 'partner_sku' => $sku, 'name' => $name, 'description' => $description, 'brand' => $brand, 'attributes' => $attributes, 'attribute_set' => $attributeSet, 'image_collection' => [['url' => $url, 'position' => $position]], 'simple_collection' => [['sku' => $simpleSku, 'partner_sku' => $simpleSku, 'variation' => $variation, 'ean' => $ean, 'attributes' => $attributes, 'status' => $simpleStatus]], 'supplier_delivery_time' => $supplierDeliveryTime, 'shipment_type' => $shipmentType, 'status' => $status]];
     $simple->method('getSku')->willReturn($simpleSku);
     $simple->method('getPartnerSku')->willReturn($simpleSku);
     $simple->method('getVariation')->willReturn($variation);
     $simple->method('getEan')->willReturn($ean);
     $simple->method('getAttributes')->willReturn($attributes);
     $simple->method('getStatus')->willReturn($simpleStatus);
     $image->method('getUrl')->willReturn($url);
     $image->method('getPosition')->willReturn($position);
     $this->dw->method('getSku')->willReturn($sku);
     $this->dw->method('getPartnerSku')->willReturn($sku);
     $this->dw->method('getName')->willReturn($name);
     $this->dw->method('getDescription')->willReturn($description);
     $this->dw->method('getBrand')->willReturn($brand);
     $this->dw->method('getAttributes')->willReturn($attributes);
     $this->dw->method('getAttributeSet')->willReturn($attributeSet);
     $this->dw->method('getStatus')->willReturn($status);
     $this->dw->method('getShipmentType')->willReturn($shipmentType);
     $this->dw->method('getSupplierDeliveryTime')->willReturn($supplierDeliveryTime);
     $this->dw->method('getImageCollection')->willReturn([$image]);
     $this->dw->method('getSimpleCollection')->willReturn([$simple]);
     $this->assertSame($exportedData, $this->context->exportContextData());
 }
示例#5
0
 public function testExportContextData()
 {
     $hash = 'hash';
     $info = [];
     $sku = 'sku';
     $partnerSku = 'partner sku';
     $simpleSku = 'simple sku';
     $partnerSimpleSku = 'partner simple sku';
     $simple = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Catalog\\Simple', $this);
     $simple->method('getSku')->willReturn($simpleSku);
     $simple->method('getPartnerSku')->willReturn($partnerSimpleSku);
     $this->dw->method('getSimpleCollection')->willReturn([$simple]);
     $this->dw->method('getSku')->willReturn($sku);
     $this->dw->method('getPartnerSku')->willReturn($partnerSku);
     $exportedData = ['name' => 'gfg.dtomarketplace.context.partner.product.confirmcreate', 'info' => $info, 'hash' => $this->context->getHash(), 'data_wrapper' => get_class($this->dw), 'data' => ['sku' => $sku, 'partner_sku' => $partnerSku, 'simple_collection' => [['sku' => $simpleSku, 'partner_sku' => $partnerSimpleSku]]]];
     $this->assertSame($exportedData, $this->context->exportContextData());
 }
示例#6
0
 public function testExportContextData()
 {
     $item = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\PostPayment\\Item', $this);
     //data
     $info = [];
     $deliveryType = 'delivery type';
     $shippingProvider = 'shipping provider';
     $trackingCode = 'tracking code';
     $trackingUrl = 'tracking url';
     $nfeKey = 'nfe key';
     $ventureOrderNr = 1234;
     $ventureOrderItemId = 321;
     $partnerCode = 'partner code';
     $exportedData = ['name' => 'gfg.dtomarketplace.context.venture.postpayment.ship', 'info' => $info, 'hash' => $this->context->getHash(), 'data_wrapper' => get_class($this->dw), 'data' => ['venture_order_nr' => $ventureOrderNr, 'order_nr' => null, 'item_collection' => [['tracking_code' => $trackingCode, 'tracking_url' => $trackingUrl, 'nfe_key' => $nfeKey, 'delivery_type' => $deliveryType, 'shipping_provider' => $shippingProvider, 'venture_order_item_id' => $ventureOrderItemId, 'order_item_id' => null]]]];
     $this->dw->method('getVentureOrderNr')->willReturn($ventureOrderNr);
     $this->dw->method('getItemCollection')->willReturn([$item]);
     $item->method('getTrackingCode')->willReturn($trackingCode);
     $item->method('getTrackingUrl')->willReturn($trackingUrl);
     $item->method('getNfeKey')->willReturn($nfeKey);
     $item->method('getDeliveryType')->willReturn($deliveryType);
     $item->method('getShippingProvider')->willReturn($shippingProvider);
     $item->method('getVentureOrderItemId')->willReturn($ventureOrderItemId);
     $this->assertSame($exportedData, $this->context->exportContextData());
 }
示例#7
0
 public function setup()
 {
     $this->dw = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Catalog\\Config', $this);
     $this->dwSimple = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Catalog\\Simple', $this);
     $this->context = new UpdateStock($this->dw);
 }
示例#8
0
 public function setup()
 {
     $this->dw = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Venture', $this);
     $this->context = new Create($this->dw);
 }
示例#9
0
 public function testExportContextData()
 {
     $hash = 'hash';
     $info = [];
     $orderNr = 123;
     $createdAt = '2016-01-01 00:00:01';
     $address = 'Rua Direita, 1';
     $freightCost = 10.0;
     $sku = 'simple sku';
     $id = 1;
     $price = 10.0;
     $unitPrice = 1;
     $taxAmount = 2;
     $taxPercent = 3;
     $idSalesOrderItem = 1;
     $supplierDeliveryTime = 321;
     $shipmentType = 222;
     $shipmentDate = 123214;
     $shipmentFee = 11211;
     $paymentMethod = 'braspag';
     $voucherCode = 'y';
     $giftOption = 'go';
     $giftMessage = 'gm';
     $sellerId = 'si';
     $skuSupplier = 'ss';
     $bobOrderId = 'champs';
     //items
     $item = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Order\\Item', $this);
     $item->method('getId')->willReturn($idSalesOrderItem);
     $item->method('getSku')->willReturn($sku);
     $item->method('getPrice')->willReturn($price);
     $item->method('getUnitPrice')->willReturn($unitPrice);
     $item->method('getTaxAmount')->willReturn($taxAmount);
     $item->method('getTaxPercent')->willReturn($taxPercent);
     $item->method('getShipmentType')->willReturn($shipmentType);
     $item->method('getShipmentDate')->willReturn($shipmentDate);
     $item->method('getShipmentFee')->willReturn($shipmentFee);
     $item->method('getSupplierDeliveryTime')->willReturn($supplierDeliveryTime);
     $item->method('getSellerId')->willReturn($sellerId);
     $item->method('getSkuSupplier')->willReturn($skuSupplier);
     $itemCollection = [$item];
     //addresses
     $street = 'Rua da Glória';
     $streetNumber = '1';
     $complement = 'Complemento';
     $city = 'São Paulo';
     $postCode = '04327-130';
     $neighborhood = 'Centro';
     $regionCode = 'SP';
     $phone = '99999-9999';
     $phone2 = '99999-9991';
     $shippingAddressDataWrapper = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Order\\Address', $this);
     $shippingAddressDataWrapper->method('getStreet')->willReturn($street);
     $shippingAddressDataWrapper->method('getNumber')->willReturn($streetNumber);
     $shippingAddressDataWrapper->method('getComplement')->willReturn($complement);
     $shippingAddressDataWrapper->method('getCity')->willReturn($city);
     $shippingAddressDataWrapper->method('getPostCode')->willReturn($postCode);
     $shippingAddressDataWrapper->method('getRegionCode')->willReturn($regionCode);
     $shippingAddressDataWrapper->method('getNeighborhood')->willReturn($neighborhood);
     $shippingAddressDataWrapper->method('getPhone')->willReturn($phone);
     $shippingAddressDataWrapper->method('getPhone2')->willReturn($phone2);
     $shippingAddress = ['street' => $street, 'number' => $streetNumber, 'complement' => $complement, 'city' => $city, 'postcode' => $postCode, 'neighborhood' => $neighborhood, 'region_code' => $regionCode, 'phone' => $phone, 'phone2' => $phone2];
     $billingAddressDataWrapper = Mock::create('GFG\\DTOMarketplace\\DataWrapper\\Order\\Address', $this);
     $billingAddressDataWrapper->method('getStreet')->willReturn($street);
     $billingAddressDataWrapper->method('getNumber')->willReturn($streetNumber);
     $billingAddressDataWrapper->method('getComplement')->willReturn($complement);
     $billingAddressDataWrapper->method('getCity')->willReturn($city);
     $billingAddressDataWrapper->method('getPostCode')->willReturn($postCode);
     $billingAddressDataWrapper->method('getRegionCode')->willReturn($regionCode);
     $billingAddressDataWrapper->method('getNeighborhood')->willReturn($neighborhood);
     $billingAddressDataWrapper->method('getPhone')->willReturn($phone);
     $billingAddressDataWrapper->method('getPhone2')->willReturn($phone2);
     $billingAddress = ['street' => $street, 'number' => $streetNumber, 'complement' => $complement, 'city' => $city, 'postcode' => $postCode, 'neighborhood' => $neighborhood, 'region_code' => $regionCode, 'phone' => $phone, 'phone2' => $phone2];
     //\addresses
     //customer
     $email = '*****@*****.**';
     $idCustomer = 1;
     $firstName = 'John';
     $lastName = 'Armless';
     $document = '810.857.546-00';
     $birthday = '01-01-1991';
     $customerDataWrapper = $this->getMockBuilder('GFG\\DTOMarketplace\\DataWrapper\\Customer')->disableOriginalConstructor()->setMethods(['getIdCustomer', 'getEmail', 'getFirstName', 'getLastName', 'getDocument', 'getBirthday'])->getMock();
     $customerDataWrapper->method('getIdCustomer')->willReturn($idCustomer);
     $customerDataWrapper->method('getEmail')->willReturn($email);
     $customerDataWrapper->method('getFirstName')->willReturn($firstName);
     $customerDataWrapper->method('getLastName')->willReturn($lastName);
     $customerDataWrapper->method('getDocument')->willReturn($document);
     $customerDataWrapper->method('getBirthday')->willReturn($birthday);
     $customer = ['email' => $email, 'first_name' => $firstName, 'last_name' => $lastName, 'document' => $document, 'birthday' => $birthday];
     //\customer
     $exportedData = ['name' => 'gfg.dtomarketplace.context.partner.order.create', 'info' => $info, 'hash' => $this->context->getHash(), 'data_wrapper' => get_class($this->dw), 'data' => ['order_nr' => $orderNr, 'bob_order_id' => $bobOrderId, 'payment_method' => $paymentMethod, 'voucher_code' => $voucherCode, 'gift_option' => $giftOption, 'gift_message' => $giftMessage, 'created_at' => $createdAt, 'freight_cost' => $freightCost, 'item_collection' => [0 => ['id' => $idSalesOrderItem, 'sku' => $sku, 'price' => $price, 'unit_price' => $unitPrice, 'tax_amount' => $taxAmount, 'tax_percent' => $taxPercent, 'shipment_type' => $shipmentType, 'shipment_date' => $shipmentDate, 'shipment_fee' => $shipmentFee, 'supplier_delivery_time' => $supplierDeliveryTime, 'seller_id' => $sellerId, 'sku_supplier' => $skuSupplier]], 'customer' => $customer, 'shipping_address' => $shippingAddress, 'billing_address' => $billingAddress]];
     $this->dw->method('getOrderNr')->willReturn($orderNr);
     $this->dw->method('getBobOrderId')->willReturn($bobOrderId);
     $this->dw->method('getPaymentMethod')->willReturn($paymentMethod);
     $this->dw->method('getVoucherCode')->willReturn($voucherCode);
     $this->dw->method('getGiftOption')->willReturn($giftOption);
     $this->dw->method('getGiftMessage')->willReturn($giftMessage);
     $this->dw->method('getCreatedAt')->willReturn($createdAt);
     $this->dw->method('getFreightCost')->willReturn($freightCost);
     $this->dw->method('getItemCollection')->willReturn($itemCollection);
     $this->dw->method('getCustomer')->willReturn($customerDataWrapper);
     $this->dw->method('getShippingAddress')->willReturn($shippingAddressDataWrapper);
     $this->dw->method('getBillingAddress')->willReturn($billingAddressDataWrapper);
     $this->assertSame($exportedData, $this->context->exportContextData());
 }
示例#10
0
 /**
  * @return \PHPUnit_Framework_MockObject_MockObject|\GFG\DTOMarketplace\DataWrapper\Order\Item
  */
 private function getItemMock()
 {
     return Mock::create('\\GFG\\DTOMarketplace\\DataWrapper\\Order\\Item', $this);
 }