public function testInventario()
 {
     $this->_em = $this->doctrineContainer->getEntityManager();
     $usuario = $this->getUsuario();
     $usuario->setNome('Corrupto Inventario');
     $item = new Entity\Item();
     $item->setNome('Limosine');
     $this->_em->persist($item);
     $this->_em->persist($usuario);
     $this->_em->flush();
     $usuario->addItem($item);
     $this->_em->flush();
     $usuarioBanco = $this->_em->getRepository('Application\\Entity\\Usuario')->findOneByNome('Corrupto Inventario');
     $this->assertEquals(1, $usuarioBanco->getInventario()->count());
     $this->assertInstanceOf('Application\\Entity\\Inventario', $usuarioBanco->getInventario()->first());
     $this->assertEquals('Limosine', $usuarioBanco->getInventario()->first()->getItem()->getNome());
 }
 public function addAction()
 {
     $form = new Form_Item();
     $form->submit->setLabel('Add');
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $nome = $form->getValue('nome');
             $item = new Entity\Item();
             $item->setNome($nome);
             $this->_em->persist($item);
             $this->_em->flush();
             $this->_helper->FlashMessenger(array('success' => 'Item criado com sucesso'));
             return $this->_helper->redirector('index');
         } else {
             $form->populate($formData);
         }
     }
 }
 public function getNome()
 {
     $this->__load();
     return parent::getNome();
 }