Пример #1
0
 public function tearDown()
 {
     $this->doctrineContainer->getConnection()->close();
     $em = $this->doctrineContainer->getEntityManager();
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $tool->dropDatabase();
     parent::tearDown();
 }
Пример #2
0
 public function getProductApple()
 {
     $product = new ZF\Entity\Product();
     $product->name = "Apples";
     $product->amount = 2.66;
     $this->doctrineContainer->getEntityManager()->persist($product);
     return $product;
 }
Пример #3
0
 public function getOrange()
 {
     $orange = new ZC\Entity\Product();
     $orange->name = "Oranges";
     $orange->amount = 2.99;
     $this->doctrineContainer->getEntityManager()->persist($orange);
     return $orange;
 }
Пример #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);
     }
 }
Пример #5
0
 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;
 }
Пример #6
0
 public function tearDown()
 {
     self::dropSchema($this->doctrineContainer->getConnection()->getParams());
     parent::tearDown();
 }