public function test_verifica_se_consegue_deletar_registro()
 {
     $class = new Task($this->getEm());
     $data = array('nome' => 'Tarefa', 'descricao' => 'Descricao tarefa', 'status' => true);
     $result = $class->insert($data);
     $result = $class->delete(1);
     $obj = $this->getEm()->getRepository('SON\\Entity\\Task')->find(1);
     $this->assertEquals(null, $obj);
 }
 public function test_indexAction()
 {
     $class = new Task($this->getEm());
     $data = array('nome' => 'Tarefa', 'descricao' => 'descricao', 'status' => true);
     $result = $class->insert($data);
     $data['nome'] = "Tarefa 2";
     $result = $class->insert($data);
     $this->routeMatch->setParam('action', 'index');
     $result = $this->controller->dispatch($this->request, $this->response);
     // testar o codigo 200
     $response = $this->controller->getResponse();
     $this->assertEquals(200, $response->getStatusCode());
     // verifica se esta retornando viewmodel
     $this->assertInstanceOf('Zend\\View\\Model\\ViewModel', $result);
     // testa variavel enviada na viewmodel
     $var = $result->getVariables();
     $this->assertArrayHasKey('tasks', $var);
     $cData = $var['tasks'];
     $this->assertEquals('Tarefa', $cData[0]->getNome());
     $this->assertEquals('Tarefa 2', $cData[1]->getNome());
 }
Ejemplo n.º 3
0
 public function test_verifica_retorno_metodo_delete()
 {
     $class = new Task($this->getEmMock());
     $result = $class->delete(1);
     $this->assertEquals(1, $result);
 }