public function testProvidesKeys() { $this->assertEquals(array(), $this->coll->getKeys()); $this->coll->merge(array('test1' => 'value1', 'test2' => 'value2')); $this->assertEquals(array('test1', 'test2'), $this->coll->getKeys()); // Returns the cached array previously returned $this->assertEquals(array('test1', 'test2'), $this->coll->getKeys()); $this->coll->remove('test1'); $this->assertEquals(array('test2'), $this->coll->getKeys()); $this->coll->add('test3', 'value3'); $this->assertEquals(array('test2', 'test3'), $this->coll->getKeys()); }
private function buildProduct($addVariations = false) { $product = new Collection(); $product->set('Title', 'ProductName'); $guid = self::getGUID(); $this->productGuids[] = $guid; $product->set('ForeignId', $guid); $product->set('StockAmount', 1); $product->set('Price', 1.23); $product->set('Description', 'Description'); $product->set('ShortDescription', 'ShortDescription'); $images = new Collection(); $image = new Collection(); $image->set('ForeignId', self::getGUID()); $image->set('ImageUrl', 'http://bilder.afterbuy.de/images/80694/3p0yhxug36592testartikel_1.jpg'); $image->set('Type', 2); $images->add(0, $image->toArray()); $product->add('Images', $images->toArray()); $specifics = new Collection(); $specific = new Collection(); $specific->set('ForeignId', self::getGUID()); $specific->set('Name', 'Marke'); $specific->set('Value', 'VIA-eBay'); $specifics->add(0, $specific->toArray()); $product->add('Specifics', $specifics->toArray()); $randomValue = mt_rand(); if ($randomValue & 1 && $addVariations == false || $addVariations == true) { $product->remove('StockAmount'); $product->remove('Price'); $variations = new Collection(); $variation = new Collection(); $variation->set('ForeignId', self::getGUID()); $variation->set('Price', 1.23); $variation->set('StockAmount', 1); $variation->set('Sku', self::getGUID()); $variationSpecifics = new Collection(); $variationSpecific = new Collection(); $variationSpecific->set('ForeignId', self::getGUID()); $variationSpecific->set('Name', 'Farbe'); $variationSpecific->set('Value', 'rot'); $variationSpecifics->add(0, $variationSpecific->toArray()); $variation->add('Specifics', $variationSpecifics->toArray()); $variations->add(0, $variation->toArray()); $product->add('Variations', $variations->toArray()); } return $product; }