/** * Testcase */ public function testMailShouldBePersisted() { $mail = new Mail(); $mail->fromArray($this->testData); $this->em->persist($mail); $this->em->flush(); $mailId = $mail->getId(); // remove mail from entity manager $this->em->detach($mail); unset($mail); $mail = $this->repo->find($mailId); foreach ($this->testData as $fieldname => $value) { if (substr($fieldname, 0, 2) == 'is') { $getMethod = $fieldname; } else { $getMethod = 'get' . ucfirst($fieldname); } $this->assertEquals($mail->{$getMethod}(), $value); } }
/** * Creates new mail */ public function createMailAction() { $params = $this->Request()->getParams(); $mail = new Mail(); $params['attribute'] = $params['attribute'][0]; $params['dirty'] = 1; $mail->fromArray($params); try { Shopware()->Models()->persist($mail); Shopware()->Models()->flush(); } catch (Exception $e) { $this->View()->assign(array('success' => false, 'message' => $e->getMessage())); return; } $data = $this->getMail($mail->getId()); $data = $data['data']; $this->View()->assign(array('success' => true, 'data' => $data)); }