Example #1
0
 /**
  * @depends testCreateShouldBeSuccessful
  */
 public function testUpdateByNumberShouldBeSuccessful($id)
 {
     $this->resource->setResultMode(\Shopware\Components\Api\Resource\Article::HYDRATE_OBJECT);
     $article = $this->resource->getOne($id);
     $number = $article->getMainDetail()->getNumber();
     $testData = array('description' => 'Update description', 'descriptionLong' => 'Update descriptionLong', 'supplierId' => 3, 'categories' => array(array('id' => 16)), 'filterGroupId' => 1, 'propertyValues' => array(), 'similar' => array());
     $article = $this->resource->updateByNumber($number, $testData);
     $this->assertInstanceOf('\\Shopware\\Models\\Article\\Article', $article);
     $this->assertEquals($id, $article->getId());
     $this->assertEquals($article->getDescription(), $testData['description']);
     $this->assertEquals($article->getDescriptionLong(), $testData['descriptionLong']);
     $this->assertEquals($testData['supplierId'], $article->getSupplier()->getId());
     $propertyValues = $article->getPropertyValues()->getValues();
     $this->assertEquals(count($propertyValues), count($testData['propertyValues']));
     // Categories should be updated
     $this->assertEquals(1, count($article->getCategories()));
     // Related should be untouched
     $this->assertEquals(2, count($article->getRelated()));
     // Similar should be removed
     $this->assertEquals(0, count($article->getSimilar()));
     return $number;
 }