/**
  * Test save
  *
  * @author 	Eddie Jaoude
  * @param 	null
  * @return 	null
  *
  */
 public function testSaveAndRetrieve()
 {
     # save info
     $account = new Auth_Model_Account();
     $account->setName($this->data['name']);
     $account->setEmail($this->data['email']);
     $account->setPassword($this->data['password'], $this->appConfig->auth->hash);
     $date = new Zend_Date();
     $now = $date->toString('YYYY-MM-dd HH:mm:ss');
     $account->setCreated_at($now);
     $this->_em->persist($account);
     $this->_em->flush();
     # retrieve save info & clarify it is correct
     $accountDetails = $this->_em->find('Auth_Model_Account', $account->getId());
     $this->assertEquals($this->data['name'], $accountDetails->getName());
     $this->assertEquals($this->data['email'], $accountDetails->getEmail());
     $this->assertNotEquals($this->data['password'], $accountDetails->getPassword());
     $this->assertEquals($now, $accountDetails->getCreated_at());
 }
 /**
  * save method
  *
  * @param	void
  * @return	void
  */
 private function save($form)
 {
     $message = NULL;
     if ($this->_request->isPost()) {
         # get params
         $data = $this->_request->getPost();
         if ($form->isValid($data)) {
             # check for existing email
             $accountExist = $this->_em->getRepository('Auth_Model_Account')->findBy(array('email' => (string) $data['email']));
             if (count($accountExist) == 0) {
                 # register account
                 $account = new Auth_Model_Account();
                 $account->setName($data['name']);
                 $account->setEmail($data['email']);
                 $account->setPassword($data['password'], $this->_registry->config->auth->hash);
                 $date = new Zend_Date();
                 $account->setCreated_at($date->toString('YYYY-MM-dd HH:mm:ss'));
                 $this->_em->persist($account);
                 $this->_em->flush();
                 # send to login page
                 $this->_helper->redirector('successful', 'register', 'auth');
             } else {
                 $alert = array('Registration Failed: Email already exists');
                 // move to view
             }
         }
         # populate form
         $form->populate($data);
     }
     return array('form' => $form, 'alert' => empty($alert) ? NULL : $alert);
 }