/** * @depends testCreate */ public function testUpdate($productId) { $image = new Image($this->config->appId, $this->config->appSecret); $images = $image->upload(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Image' . DIRECTORY_SEPARATOR . 'aa.jpg'); //未上架的 $product = new Product($this->http); $response = $product->update(function (ProductData $product) use($images) { $product->setBaseAttr($images, array($images, $images), null, '商品名', 536891949)->setDetail('text', 'text')->setDetail('img', $images); $testData = Yaml::parse(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Data.yml')); foreach ($testData['Overtrue\\Wechat\\Test\\Shop\\ProductTest']['testGetProperty'] as $value) { $product->setProperty($value['id'], $value['property_value'][0]['id']); } foreach ($testData['Overtrue\\Wechat\\Test\\Shop\\ProductTest']['testGetSku'] as $value) { foreach ($value['value_list'] as $key => $valueList) { //此判断仅是为了 让子序列少点,实际程序按照自身的逻辑来 if ($key % 5 == 0 && $key % 2 == 0) { $skuList[] = $valueList['id']; } } $skuInfo[] = array('id' => $value['id'], 'vid' => $skuList); $product->setSkuInfo($value['id'], $skuList); } foreach ($skuInfo[0]['vid'] as $vid) { foreach ($skuInfo[1]['vid'] as $vid1) { $product->setSkuList(100, 20, $images, 100, array(array($skuInfo[0]['id'], $vid), array($skuInfo[1]['id'], $vid1))); } } $product->setAttrext(0, 1, 1, 1)->setLocation('浙江省', '杭州市', '滨江区阿里园')->setDeliveryInfo(1, '400184224'); return $product; }, $productId); $this->assertTrue(is_string($response)); }
protected function setUp() { parent::setUp(); $img = new Image($this->config->appId, $this->config->appSecret); $this->url = $img->upload(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Image' . DIRECTORY_SEPARATOR . 'aa.jpg'); }