/** * @params Product $product * * @depends testRead */ public function testUpdate(Product $product) { $metaData = MetaDataQuery::create()->filterByMetaKey('test')->filterByElementKey(get_class($product))->filterByElementId($product->getId())->findOne(); $this->assertNotNull($metaData); $event = new MetaDataCreateOrUpdateEvent(); $event->setMetaKey($metaData->getMetaKey())->setElementKey($metaData->getElementKey())->setElementId($metaData->getElementId())->setValue(array("fr_FR" => "bonjour", "en_US" => "Hello"))->setDispatcher($this->dispatcher); $action = new MetaData(); $action->createOrUpdate($event); $updated = $event->getMetaData(); $this->assertInstanceOf('Thelia\\Model\\MetaData', $updated); $this->assertFalse($updated->isNew()); $this->assertEquals('test', $updated->getMetaKey()); $this->assertEquals(get_class($product), $updated->getElementKey()); $this->assertEquals($product->getId(), $updated->getElementId()); $this->assertEquals(array("fr_FR" => "bonjour", "en_US" => "Hello"), $updated->getValue()); $this->assertEquals(true, $updated->getIsSerialized()); return $product; }