PageRenderTime 56ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/sftGuardPlugin/test/lib/model/EdaDireccionesTest.php

https://github.com/juanda/symfonite
PHP | 302 lines | 173 code | 41 blank | 88 comment | 0 complexity | d38fd202626a62cd5f4cd22b301d0800 MD5 | raw file
  1. <?php
  2. require_once 'PHPUnit/Framework.php';
  3. require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
  4. /**
  5. * Test class for SftDireccion
  6. */
  7. class EdaDireccionesTest extends PHPUnit_Framework_TestCase {
  8. protected $object;
  9. protected $datos = array();
  10. protected $tipo_direccion;
  11. /**
  12. * Sets up the fixture, for example, opens a network connection.
  13. * This method is called before a test is executed.
  14. */
  15. protected function setUp() {
  16. $this->object = new SftDireccion();
  17. $this->tipo_direccion = new SftTipodireccion();
  18. $this->datos[0] = 777; //id direccion
  19. $this->datos[1] = 1; //id tipo direccion
  20. $this->datos[2] = 'tipo_via'; //tipo_via
  21. $this->datos[3] = 'domicilio'; //domicilio
  22. $this->datos[4] = 'numero'; // numero
  23. $this->datos[5] = 'escalera'; // escalera
  24. $this->datos[6] = 'piso'; // piso
  25. $this->datos[7] = 'letra'; // letra
  26. $this->datos[8] = 'municipio'; // municipio
  27. $this->datos[9] = 'provincia'; // num_login_fails
  28. $this->datos[10] = 'pais'; // pais
  29. $this->datos[11] = 'codigo postal'; //cp
  30. $this->datos[12] = null; //IdPersona
  31. $this->datos[13] = null; //IdOrganismo
  32. }
  33. /**
  34. * Tears down the fixture, for example, closes a network connection.
  35. * This method is called after a test is executed.
  36. */
  37. protected function tearDown() {
  38. }
  39. /**
  40. * testGetIdEmail()
  41. * Testing that getIdMail() returns the Id
  42. */
  43. public function testHasOnlyDefaultValues(){
  44. $this->assertTrue($this->object->hasOnlyDefaultValues());
  45. }
  46. /**
  47. * testGetIdDireccion()
  48. * Testing that getIdDireccion() returns the Id
  49. */
  50. public function testGetIdDireccion() {
  51. $this->assertEquals($this->object->getId(), $this->object->getIdDireccion());
  52. }
  53. /**
  54. * testSettersAndGetters()
  55. * Testing the setters and the getters of the class
  56. */
  57. public function testSettersAndGetters() {
  58. $this->object->setId($this->datos[0]);
  59. $this->object->setEdaTiposdireccion($this->tipo_direccion);
  60. $this->object->setTipovia($this->datos[2]);
  61. $this->object->setDomicilio($this->datos[3]);
  62. $this->object->setNumero($this->datos[4]);
  63. $this->object->setEscalera($this->datos[5]);
  64. $this->object->setPiso($this->datos[6]);
  65. $this->object->setLetra($this->datos[7]);
  66. $this->object->setMunicipio($this->datos[8]);
  67. $this->object->setProvincia($this->datos[9]);
  68. $this->object->setPais($this->datos[10]);
  69. $this->object->setCp($this->datos[11]);
  70. $this->object->setIdPersona($this->datos[12]);
  71. $this->object->setIdOrganismo($this->datos[13]);
  72. $this->assertEquals($this->datos[0], $this->object->getId());
  73. $this->assertType('integer',$this->object->getId());
  74. //$this->assertEquals($this->tipo_direccion, $this->object->getIdTipodireccion());
  75. $this->assertEquals($this->datos[2], $this->object->getTipovia());
  76. $this->assertType('string',$this->object->getTipovia());
  77. $this->assertEquals($this->datos[3], $this->object->getDomicilio());
  78. $this->assertType('string',$this->object->getDomicilio());
  79. $this->assertEquals($this->datos[4], $this->object->getNumero());
  80. $this->assertType('string',$this->object->getNumero());
  81. $this->assertEquals($this->datos[5], $this->object->getEscalera());
  82. $this->assertType('string',$this->object->getEscalera());
  83. $this->assertEquals($this->datos[6], $this->object->getPiso());
  84. $this->assertType('string',$this->object->getPiso());
  85. $this->assertEquals($this->datos[7], $this->object->getLetra());
  86. $this->assertType('string',$this->object->getLetra());
  87. $this->assertEquals($this->datos[8], $this->object->getMunicipio());
  88. $this->assertType('string',$this->object->getMunicipio());
  89. $this->assertEquals($this->datos[9], $this->object->getProvincia());
  90. $this->assertType('string',$this->object->getProvincia());
  91. $this->assertEquals($this->datos[10], $this->object->getPais());
  92. $this->assertType('string',$this->object->getPais());
  93. $this->assertEquals($this->datos[11], $this->object->getCp());
  94. $this->assertType('string',$this->object->getCp());
  95. $this->assertEquals($this->datos[12], $this->object->getIdPersona());
  96. $this->assertNull($this->object->getIdPersona());
  97. $this->assertNull($this->object->getIdOrganismo());
  98. }
  99. /**
  100. * testHydrate()
  101. * Testing the hydrate method of the class
  102. */
  103. public function testHydrate() {
  104. $object = new SftDireccion();
  105. try
  106. {
  107. $object->hydrate($this->datos);
  108. $this->assertEquals($this->datos[0], $object->getId());
  109. $this->assertType('integer',$object->getId());
  110. // $this->assertEquals($this->datos[1], $object->getIdTipodireccion());
  111. $this->assertEquals($this->datos[2], $object->getTipovia());
  112. $this->assertType('string',$object->getTipovia());
  113. $this->assertEquals($this->datos[3], $object->getDomicilio());
  114. $this->assertType('string',$object->getDomicilio());
  115. $this->assertEquals($this->datos[4], $object->getNumero());
  116. $this->assertType('string',$object->getNumero());
  117. $this->assertEquals($this->datos[5], $object->getEscalera());
  118. $this->assertType('string',$object->getEscalera());
  119. $this->assertEquals($this->datos[6], $object->getPiso());
  120. $this->assertType('string',$object->getPiso());
  121. $this->assertEquals($this->datos[7], $object->getLetra());
  122. $this->assertType('string',$object->getLetra());
  123. $this->assertEquals($this->datos[8], $object->getMunicipio());
  124. $this->assertType('string',$object->getMunicipio());
  125. $this->assertEquals($this->datos[9], $object->getProvincia());
  126. $this->assertType('string',$object->getProvincia());
  127. $this->assertEquals($this->datos[10], $object->getPais());
  128. $this->assertType('string',$object->getPais());
  129. $this->assertEquals($this->datos[11], $object->getCp());
  130. $this->assertType('string',$object->getCp());
  131. $this->assertEquals($this->datos[12], $object->getIdPersona());
  132. $this->assertNull($object->getIdPersona());
  133. $this->assertNull($object->getIdOrganismo());
  134. }catch (Exception $e)
  135. {
  136. throw $e;
  137. }
  138. }
  139. /**
  140. * testFromArray()
  141. * Testing the fromArray method of the class
  142. * @todo fix the password issue
  143. */
  144. public function testFromArray() {
  145. $object = new SftDireccion();
  146. try
  147. {
  148. $object->fromArray($this->datos,BasePeer::TYPE_NUM);
  149. $this->assertEquals($this->datos[0], $object->getId());
  150. $this->assertType('integer',$object->getId());
  151. $this->assertEquals($this->datos[1], $object->getIdTipodireccion());
  152. $this->assertEquals($this->datos[2], $object->getTipovia());
  153. $this->assertType('string',$object->getTipovia());
  154. $this->assertEquals($this->datos[3], $object->getDomicilio());
  155. $this->assertType('string',$object->getDomicilio());
  156. $this->assertEquals($this->datos[4], $object->getNumero());
  157. $this->assertType('string',$object->getNumero());
  158. $this->assertEquals($this->datos[5], $object->getEscalera());
  159. $this->assertType('string',$object->getEscalera());
  160. $this->assertEquals($this->datos[6], $object->getPiso());
  161. $this->assertType('string',$object->getPiso());
  162. $this->assertEquals($this->datos[7], $object->getLetra());
  163. $this->assertType('string',$object->getLetra());
  164. $this->assertEquals($this->datos[8], $object->getMunicipio());
  165. $this->assertType('string',$object->getMunicipio());
  166. $this->assertEquals($this->datos[9], $object->getProvincia());
  167. $this->assertType('string',$object->getProvincia());
  168. $this->assertEquals($this->datos[10], $object->getPais());
  169. $this->assertType('string',$object->getPais());
  170. $this->assertEquals($this->datos[11], $object->getCp());
  171. $this->assertType('string',$object->getCp());
  172. $this->assertEquals($this->datos[12], $object->getIdPersona());
  173. $this->assertNull($object->getIdPersona());
  174. $this->assertNull($object->getIdOrganismo());
  175. }catch (Exception $e)
  176. {
  177. throw $e;
  178. }
  179. }
  180. /**
  181. * testCopy()
  182. * Testing the copy method of the class
  183. * this method does not copy the Id
  184. */
  185. /*
  186. public function testCopy() {
  187. $object = new SftDireccion();
  188. try
  189. {
  190. $object->copy($this->object);
  191. $this->assertNull($object->getId()); //this method does not copy the Id
  192. //$this->assertType('integer',$object->getId());
  193. $this->assertNull($object->getIdTipodireccion());
  194. $this->assertEquals($this->datos[2], $object->getTipovia());
  195. $this->assertType('string',$object->getTipovia());
  196. $this->assertEquals($this->datos[3], $object->getDomicilio());
  197. $this->assertType('string',$object->getDomicilio());
  198. $this->assertEquals($this->datos[4], $object->getNumero());
  199. $this->assertType('string',$object->getNumero());
  200. $this->assertEquals($this->datos[5], $object->getEscalera());
  201. $this->assertType('string',$object->getEscalera());
  202. $this->assertEquals($this->datos[6], $object->getPiso());
  203. $this->assertType('string',$object->getPiso());
  204. $this->assertEquals($this->datos[7], $object->getLetra());
  205. $this->assertType('string',$object->getLetra());
  206. $this->assertEquals($this->datos[8], $object->getMunicipio());
  207. $this->assertType('string',$object->getMunicipio());
  208. $this->assertEquals($this->datos[9], $object->getProvincia());
  209. $this->assertType('string',$object->getProvincia());
  210. $this->assertEquals($this->datos[10], $object->getPais());
  211. $this->assertType('string',$object->getPais());
  212. $this->assertEquals($this->datos[11], $object->getCp());
  213. $this->assertType('string',$object->getCp());
  214. $this->assertEquals($this->datos[12], $object->getIdPersona());
  215. $this->assertType('integer',$object->getIdPersona());
  216. $this->assertEquals($this->datos[13], $object->getIdOrganismo());
  217. $this->assertType('integer',$object->getId());
  218. }catch (Exception $e)
  219. {
  220. throw $e;
  221. }
  222. }
  223. */
  224. /**
  225. * testSave()
  226. * Testing the save() method of the class
  227. */
  228. public function testSave() {
  229. try
  230. {
  231. $object3 = new SftDireccion();
  232. $tipo_direccion = new SftTipodireccion();
  233. $object3->setEdaTiposdireccion($tipo_direccion);
  234. $object3->setEdaOrganismos(null);
  235. $object3->setEdaPersonas(null);
  236. $object3->setDomicilio('Cuatro caminos');
  237. $object3->setTipovia($this->datos[2]);
  238. $object3->setDomicilio($this->datos[3]);
  239. $object3->setNumero($this->datos[4]);
  240. $object3->setEscalera($this->datos[5]);
  241. $object3->setPiso($this->datos[6]);
  242. $object3->setLetra($this->datos[7]);
  243. $object3->setMunicipio($this->datos[8]);
  244. $object3->setProvincia($this->datos[9]);
  245. $object3->setPais($this->datos[10]);
  246. $object3->setCp($this->datos[11]);
  247. $this->assertEquals(2, $object3->save()); /*devuelve 2???*/
  248. $this->assertNull($object3->delete());
  249. }catch (Exception $e)
  250. {
  251. throw $e;
  252. }
  253. }
  254. }
  255. ?>