public function testToArray()
 {
     $collection = new AttributeCollection();
     $attribute1 = new Attribute('name1', 'value1');
     $collection->add($attribute1);
     $attribute2 = new Attribute('name2', 'value2');
     $collection->add($attribute2);
     $expected = ['name1' => 'value1', 'name2' => 'value2'];
     $this->assertEquals($expected, $collection->toArray());
 }
Пример #2
0
 public function testToArray()
 {
     $productData = new AttributeCollection();
     $productAttribute1 = new Attribute('attribute_one', 'value_one');
     $productAttribute2 = new Attribute('attribute_two', 'value_two');
     $productData->add($productAttribute1);
     $productData->add($productAttribute2);
     $product = new Product();
     $product->setSellerSku('MOB123456');
     $product->setProductData($productData);
     $product->setParentSku('ABC998877');
     $product->setStatus(StatusEnum::ACTIVE());
     $product->setName('Product Name');
     $product->setVariation('VariationX');
     $product->setPrimaryCategory(1);
     $product->setCategories('1,2,3');
     $product->setDescription('Product description goes here...');
     $product->setBrand('Major Brand');
     $product->setPrice(129.99);
     $product->setSalePrice(99.98999999999999);
     $product->setSaleStartDate(\DateTime::createFromFormat('Y-m-d H:i:s', '2015-01-01 10:00:00'));
     $product->setSaleEndDate(\DateTime::createFromFormat('Y-m-d H:i:s', '2015-01-10 23:59:59'));
     $product->setTaxClass(TaxClassEnum::DEFAULT_CLASS());
     $product->setShipmentType(ShipmentTypeEnum::DROPSHIPPING());
     $product->setProductId('78900112233');
     $product->setCondition(ConditionEnum::NEW_PRODUCT());
     $product->setQuantity(1);
     $product->setShopSku('12345SHOP');
     $product->setBrowseNodes('browse_nodes');
     $expected = ['SellerSku' => 'MOB123456', 'ParentSku' => 'ABC998877', 'Status' => 'active', 'Name' => 'Product Name', 'Variation' => 'VariationX', 'PrimaryCategory' => '1', 'Categories' => '1,2,3', 'Description' => 'Product description goes here...', 'Brand' => 'Major Brand', 'Price' => '129.99', 'SalePrice' => '99.99', 'SaleStartDate' => '2015-01-01T10:00:00+0000', 'SaleEndDate' => '2015-01-10T23:59:59+0000', 'TaxClass' => 'default', 'ShipmentType' => 'dropshipping', 'ProductId' => '78900112233', 'Condition' => 'new', 'ProductData' => ['attribute_one' => 'value_one', 'attribute_two' => 'value_two'], 'Quantity' => 1, 'ShopSku' => '12345SHOP', 'BrowseNodes' => 'browse_nodes'];
     $this->assertEquals($expected, $product->toArray());
 }