Exemple #1
0
 public function testCookieMapper()
 {
     $mapper = new Application_Model_CookieMapper();
     $cookie = new Application_Model_Cookie();
     $cookie->setNick("testNick");
     $cookie->setEmail("*****@*****.**");
     $cookie->setDisplayMode(1);
     $cookie->setSaveName('testNickSave');
     $cookie->setPassword('testNickPass');
     $cookie->setTwitter('testNickTwit');
     $cookie->setFacebook('testNickFace');
     $cookie->setCCEmail('1');
     $mapper->save($cookie);
     $id = $cookie->getId();
     if (strlen($id) != 60) {
         $this->fail("Saving Cookie didn't create ID properly");
     }
     $cookie = null;
     $cookie = $mapper->find($id);
     if ($cookie == null) {
         $this->fail("Can't retrieve saved cookie");
     }
     if ($cookie->getId() != $id) {
         $this->fail("Saved Cookie Not Found");
     }
     $cookie = null;
     $cookie = $mapper->findFromPartial(substr($id, 0, 30));
     if ($cookie == null) {
         $this->fail("Can't retrieve saved cookie from partial");
     }
     if ($cookie->getId() != $id) {
         $this->fail("Saved Cookie Not Found From Partial");
     }
     $cookie = null;
     $cookie = $mapper->findFromPassword("*****@*****.**", "testNickPass");
     if ($cookie == null) {
         $this->fail("Can't retrieve saved cookie from password");
     }
     if ($cookie->getNick() != "testNick") {
         $this->fail("Saved Cookie Not Found From password");
     }
     $mapper->delete($cookie);
     $cookie = null;
     $cookie = $mapper->find($id);
     if ($cookie != null) {
         $this->fail("Failed to delete cookie with id '{$id}'");
     }
 }
Exemple #2
0
 public function duplicate($old)
 {
     $new = new Application_Model_Cookie();
     $new->setNick($old->getNick());
     $new->setEmail($old->getEmail());
     $new->setDisplayMode($old->getDisplayMode());
     $new->setSaveName($old->getSaveName());
     $new->setPassword($old->getPassword());
     $new->setTwitter($old->getTwitter());
     $new->setFacebook($old->getFacebook());
     $new->setCCEmail($old->getCCEmail());
     $new->setCreated($old->getCreated());
     $new->setUpdated($old->getUpdated());
     return $new;
 }