Repository navigation
Expand file tree
/
Copy pathRespostaTest.php
More file actions
71 lines (66 loc) · 2.2 KB
/
Copy pathRespostaTest.php
File metadata and controls
71 lines (66 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
*
* @author Caio Lucena <caioflucena@gmail.com>
* @todo Usar questao de teste para teste de resposta
*/
class RespostaTest extends PHPUnit_Framework_TestCase
{
/**
* @var integer
*/
private $idQuestaoTest;
private $modelTable;
/**
*
*/
protected function setUp()
{
$respostaModel = new RespostaModel();
$reflection = new ReflectionObject($respostaModel);
$property = $reflection->getProperty('table');
$property->setAccessible(true);
$table = $property->getValue($respostaModel);
$select = $table->select()->setIntegrityCheck(false)->from('tbQuestao', 'idQuestao');
$questao = $table->fetchRow($select)->toArray();
$this->idQuestaoTest = $questao['idQuestao'];
}
/**
*
*/
protected function tearDown()
{
$respostaModel = new RespostaModel();
$result = $respostaModel->pesquisarPorTipoQuestao(null, $this->idQuestaoTest);
$reflection = new ReflectionObject($respostaModel);
$property = $reflection->getProperty('table');
$property->setAccessible(true);
$table = $property->getValue($respostaModel);
$select = $table->select()->setIntegrityCheck(false)->from('tbResposta', 'idResposta')->where('dsResposta like ?', 'Resposta Questao%');
$result = $table->fetchAll($select)->toArray();
foreach ($result as $resposta) {
$table->delete(array('idResposta = ?' => $resposta['idResposta']));
}
}
/**
*
*/
public function testCadastrarText()
{
$respostaModel = new RespostaModel(null, RespostaModel::TEXT, $this->idQuestaoTest, 'Resposta Questao text');
$resposta = $respostaModel->toStdClass();
$this->assertNull($resposta->resposta);
$respostaModel->cadastrar();
$resposta = $respostaModel->toStdClass();
$this->assertNotNull($resposta->resposta);
}
/**
* @expectedException Exception
* @expectedExceptionMessage Categoria inválida para cadastro de Guia.
*/
public function testCadastrarValidar()
{
$respostaTextModel = new RespostaTextModel();
$respostaTextModel->cadastrar();
}
}