public function testPriceCollectionAdd() { $priceCollection = new Collection(); $priceEntity = new Entity(['type' => Entity::TYPE_BOLETO, 'price' => 50.0, 'priceLomadee' => 0.0, 'installment' => 0, 'installmentValue' => 0]); $priceCollection->add($priceEntity); $priceEntity = new Entity(['type' => Entity::TYPE_CARTAO_AVISTA, 'price' => 50.0, 'priceLomadee' => 0.0, 'installment' => 1, 'installmentValue' => 45.0]); $priceCollection->add($priceEntity); $priceEntity = new Entity(['type' => Entity::TYPE_CARTAO_PARCELADO_SEM_JUROS, 'price' => 50.0, 'priceLomadee' => 0.0, 'installment' => 2, 'installmentValue' => 25.0]); $priceCollection->add($priceEntity); $expected = '[{"type":"boleto","price":50,"priceLomadee":0,"installment":0,"installmentValue":0},{"type":"cartao_avista","price":50,"priceLomadee":0,"installment":1,"installmentValue":45},{"type":"cartao_parcelado_sem_juros","price":50,"priceLomadee":0,"installment":2,"installmentValue":25}]'; $this->assertEquals($expected, json_encode($priceCollection)); }
public function testAddProduct() { $productCollection = new ProductCollection(); $priceCollection = new PriceCollection(); $priceAvista = new Product\Price(['type' => Product\Price::TYPE_BOLETO, 'price' => 99.98999999999999]); $priceCollection->add($priceAvista); $priceParcelado = new Product\Price(['type' => Product\Price::TYPE_CARTAO_PARCELADO_SEM_JUROS, 'price' => 99.98999999999999, 'installment' => 3, 'installmentValue' => 33.33]); $priceCollection->add($priceParcelado); $product1 = new Product(['sku' => 'unit', 'prices' => $priceCollection, 'quantity' => 1, 'category' => 'Unit > Test', 'description' => 'Test unit to product', 'images' => [['url' => 'http://image.com/teste1.jpg'], ['url' => 'http://image.com/teste2.jpg']], 'link' => 'http://link.com/unit', 'technicalSpecification' => [['key' => 'Unit', 'value' => 'Use'], ['key' => 'Another', 'value' => 'Unit']], 'sizeHeight' => 10, 'sizeLength' => 10, 'sizeWidth' => 10, 'weightValue' => 0, 'marketplace' => 'PHP Unit']); $productCollection->add($product1); $product2 = new Product(['sku' => 'unit101001', 'prices' => [['type' => Product\Price::TYPE_CARTAO_AVISTA, 'price' => 50.5], ['type' => Product\Price::TYPE_CARTAO_PARCELADO_SEM_JUROS, 'price' => 50.5, 'installment' => 2, 'installmentValue' => 25.25]], 'quantity' => 2, 'category' => 'Unit > Test', 'description' => 'Test unit to product<br>', 'images' => [['url' => 'http://image.com/teste3.jpg'], ['url' => 'http://image.com/teste4.jpg']], 'link' => 'http://link.com/unit2', 'technicalSpecification' => [['key' => 'Unit2', 'value' => 'Use'], ['key' => 'Another', 'value' => 'Unit2']], 'sizeHeight' => 9, 'sizeLength' => 8, 'sizeWidth' => 7, 'weightValue' => 6, 'marketplace' => 'PHP Unit', 'barcode' => '123']); $productCollection->add($product2); }