public function testGerenciaUpdate() { if (!$this->hasToken()) { return $this->markTestIncomplete('API Token ausente'); } $manager = new Manager($this->factoryClient()); foreach ($this->dataProviderProducts() as $array) { $data = current($array); $product = Factory::factoryProduct($data); $this->assertTrue($manager->save($product), $product); } }
/** * @depends testAcessoAListaDeSkus */ public function testAtualizaPrecoDoSkuInformado(Collection $data) { foreach ($data->getSkus() as $sku) { $client = $this->factoryClient(); $response = $client->get('/sku/' . $sku['id']); $info = $response->getData()->getPrice(); $price = Factory::factoryPrice($info); $this->assertSame($info['sellPrice'], $price->getSellPrice()); $newSellPrice = number_format($info['sellPrice'] * 0.99, 2, '.', ''); $price->setSellPrice($newSellPrice); $this->assertSame($newSellPrice, $price->getSellPrice()); $changeData = $client->put('/sku/' . $sku['id'] . '/price', $price->toJson()); $this->assertHttpStatusCodeSuccess($changeData->getHttpStatusCode()); $newResponse = $client->get('/sku/' . $sku['id']); $newPrice = Factory::factoryPrice($newResponse->getData()->getPrice()); $this->assertSame($newSellPrice, $newPrice->getSellPrice()); } }
protected function factory($data) { $product = Factory::factoryProduct($data); return $product; }