Ejemplo n.º 1
0
 public function tearDown()
 {
     $this->doctrineContainer->getConnection()->close();
     $em = $this->doctrineContainer->getEntityManager();
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $tool->dropDatabase();
     parent::tearDown();
 }
Ejemplo n.º 2
0
 public function getProductApple()
 {
     $product = new ZF\Entity\Product();
     $product->name = "Apples";
     $product->amount = 2.66;
     $this->doctrineContainer->getEntityManager()->persist($product);
     return $product;
 }
Ejemplo n.º 3
0
 public function getOrange()
 {
     $orange = new ZC\Entity\Product();
     $orange->name = "Oranges";
     $orange->amount = 2.99;
     $this->doctrineContainer->getEntityManager()->persist($orange);
     return $orange;
 }
Ejemplo n.º 4
0
 public function setUp()
 {
     global $application;
     $application->bootstrap();
     $this->doctrineContainer = Zend_Registry::get('doctrine');
     self::dropSchema($this->doctrineContainer->getConnection()->getParams());
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->doctrineContainer->getEntityManager());
     $metas = $this->getClassMetas(APPLICATION_PATH . '/../library/ZC/Entity', 'ZC\\Entity\\');
     $tool->createSchema($metas);
     parent::setUp();
 }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 6
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;
 }