public function delete(MetaDataDeleteEvent $event) { $metaData = MetaDataQuery::create()->filterByMetaKey($event->getMetaKey())->filterByElementKey($event->getElementKey())->filterByElementId($event->getElementId())->findOne(); $event->setMetaData($metaData); if (null !== $metaData) { $metaData->delete(); } }
/** * @params Product $product * * @depends testUpdate */ public function testDelete(Product $product) { $metaData = MetaDataQuery::create()->filterByMetaKey('test')->filterByElementKey(get_class($product))->filterByElementId($product->getId())->findOne(); $this->assertNotNull($metaData); $event = new MetaDataDeleteEvent('test', get_class($product), $product->getId()); $event->setDispatcher($this->dispatcher); $action = new MetaData(); $action->delete($event); $deleted = $event->getMetaData(); $this->assertInstanceOf('Thelia\\Model\\MetaData', $deleted); $this->assertTrue($deleted->isDeleted()); }