Пример #1
0
 /**
  * @depends testCreate
  */
 public function testUpdate(ProductModel $product)
 {
     $event = new ProductUpdateEvent($product->getId());
     $defaultCategory = CategoryQuery::create()->select('id')->addAscendingOrderByColumn('RAND()')->findOne();
     $brandId = BrandQuery::create()->findOne()->getId();
     $event->setLocale('fr_FR')->setTitle('test MAJ titre en français')->setDescription('test description fr')->setChapo('test chapo fr')->setPostscriptum('test postscriptum fr')->setVisible(1)->setDefaultCategory($defaultCategory)->setBrandId($brandId)->setRef($product->getRef())->setDispatcher($this->getDispatcher());
     $action = new Product();
     $action->update($event);
     $updatedProduct = $event->getProduct();
     $this->assertInstanceOf('Thelia\\Model\\Product', $updatedProduct);
     $updatedProduct->setLocale('fr_FR');
     $this->assertEquals('test MAJ titre en français', $updatedProduct->getTitle());
     $this->assertEquals('test description fr', $updatedProduct->getDescription());
     $this->assertEquals('test chapo fr', $updatedProduct->getChapo());
     $this->assertEquals('test postscriptum fr', $updatedProduct->getPostscriptum());
     $this->assertEquals(1, $updatedProduct->getVisible());
     $this->assertEquals($defaultCategory, $updatedProduct->getDefaultCategoryId());
     $PSE = $updatedProduct->getProductSaleElementss();
     $this->assertEquals(1, count($PSE));
     return $updatedProduct;
 }