Beispiel #1
0
 public function tearDown()
 {
     $this->doctrineContainer->getConnection()->close();
     $em = $this->doctrineContainer->getEntityManager();
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $tool->dropDatabase();
     parent::tearDown();
 }
Beispiel #2
0
 public function getProductApple()
 {
     $product = new ZF\Entity\Product();
     $product->name = "Apples";
     $product->amount = 2.66;
     $this->doctrineContainer->getEntityManager()->persist($product);
     return $product;
 }
Beispiel #3
0
 public function getOrange()
 {
     $orange = new ZC\Entity\Product();
     $orange->name = "Oranges";
     $orange->amount = 2.99;
     $this->doctrineContainer->getEntityManager()->persist($orange);
     return $orange;
 }
Beispiel #4
0
 protected function getUser()
 {
     $em = $this->doctrineContainer->getEntityManager();
     $this->user = $em->getRepository("ZF\\Entity\\UserAuth")->findOneBy(array('username' => $this->username));
     if ($this->user) {
         if ($this->user->password == $this->password) {
             return $this->user;
         }
         throw new Zend_Exception(1);
     } else {
         throw new Zend_Exception(2);
     }
 }
 public function createDatabase()
 {
     $em = $this->doctrineContainer->getEntityManager();
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $tool->dropDatabase();
     $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
     $usuario = new \Application\Entity\Usuario();
     $usuario->setNome('admin');
     $usuario->setEnergia(100);
     $usuario->setEnergiaMaxima(100);
     $usuario->setEmail('*****@*****.**');
     $usuario->setSenha('123');
     $em->persist($usuario);
     $em->flush();
     self::$created = true;
 }
Beispiel #6
0
 public function tearDown()
 {
     self::dropSchema($this->doctrineContainer->getConnection()->getParams());
     parent::tearDown();
 }