Advertisement
Guest User

Login_model_test

a guest
May 23rd, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.93 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Kevin Van Meerbeek
  5. * Date: 18/05/2016
  6. * Time: 18:50
  7. */
  8.  
  9. class Tickets_model_test extends TestCase
  10. {
  11.  
  12. public function setup()
  13. {
  14. $this->resetInstance();
  15. $this->CI->load->model('Login_model');
  16. $this->model = $this->CI->Login_model;
  17. }
  18.  
  19. /* @Author: Kevin Van Meerbeek
  20. * Created on: 21/05/2016
  21. * Last modified: 22/05/2016
  22. * Test of de data die de user ingeeft uniek is en in de database wordt weggeschreven
  23. * */
  24.  
  25. public function test_loginModelRegistrationInsert()
  26. {
  27. $data = [
  28. 0 => (object)[ 'FIRST_NAME' => 'TEST', 'LAST_NAME' => 'DISPATCHER',
  29. 'EMAIL' => 'dispatcher@gmail.com', 'PASSWORD' => 'pxl'],
  30. ];
  31. $result = $this->model->registration_insert($data);
  32. for ($i = 0; $i < count($data); $i++) {
  33.  
  34. $expectedResult = 'correct';
  35. $this->assertEquals($result, $expectedResult);
  36. }
  37. }
  38.  
  39. /* @Author: Kevin Van Meerbeek
  40. * Created on: 21/05/2016
  41. * Last modified: 22/05/2016
  42. * Test of de user succesvol kan inloggen met zijn emailadres en wachtwoord
  43. * */
  44.  
  45. public function test_loginModelLogin()
  46. {
  47. $data = [
  48. 0 => (object)['EMAIL' => 'dispatcher@gmail.com', 'PASSWORD' => '098f6bcd4621d373cade4e832627b4f6' ],
  49. ];
  50. $result = $this->model->login($data);
  51. for ($i = 0; $i < count($data); $i++) {
  52.  
  53. $expectedResult = 'UserPassword';
  54. $this->assertEquals($result, $expectedResult);
  55. }
  56. }
  57.  
  58. /* @Author: Kevin Van Meerbeek
  59. * Created on: 21/05/2016
  60. * Last modified: 22/05/2016
  61. * Test of de gegevens van de user aan de hand van het emailadres kan worden opgehaald uit de database
  62. * */
  63.  
  64. public function test_loginModelReadUserInformation()
  65. {
  66. $expected = [
  67. 0 => (object)['ACCOUNT_ID' => 1, 'FIRST_NAME' => 'TEST', 'LAST_NAME' => 'DISPATCHER',
  68. 'EMAIL' => 'dispatcher@gmail.com', 'PASSWORD' => '098f6bcd4621d373cade4e832627b4f6', 'TYPE' => 1, 'BLOCKED' => 0],
  69. ];
  70.  
  71. $result = $this->model->read_user_information('dispatcher@gmail.com');
  72. for ($i = 0; $i < count($expected); $i++) {
  73. $this->assertEquals($result[$i]->ACCOUNT_ID, $expected[$i]->ACCOUNT_ID);
  74. $this->assertEquals($result[$i]->FIRST_NAME, $expected[$i]->FIRST_NAME);
  75. $this->assertEquals($result[$i]->LAST_NAME, $expected[$i]->LAST_NAME);
  76. $this->assertEquals($result[$i]->EMAIL, $expected[$i]->EMAIL);
  77. $this->assertEquals($result[$i]->PASSWORD, $expected[$i]->PASSWORD);
  78. $this->assertEquals($result[$i]->TYPE, $expected[$i]->TYPE);
  79. $this->assertEquals($result[$i]->BLOCKED, $expected[$i]->BLOCKED);
  80. }
  81. }
  82.  
  83. /* @Author: Kevin Van Meerbeek
  84. * Created on: 21/05/2016
  85. * Last modified: 22/05/2016
  86. * Test of de data die de user ingeeft uniek is en in de database wordt weggeschreven
  87. * */
  88.  
  89. public function test_loginModelReadEmailInformation()
  90. {
  91. $expected = [
  92. 0 => (object)['ACCOUNT_ID' => 1, 'FIRST_NAME' => 'TEST', 'LAST_NAME' => 'DISPATCHER',
  93. 'EMAIL' => 'dispatcher@gmail.com', 'PASSWORD' => '098f6bcd4621d373cade4e832627b4f6', 'TYPE' => 1, 'BLOCKED' => 0],
  94. ];
  95. $data = [0 => (object)['EMAIL' => 'dispatcher@gmail.com'],
  96. ];
  97.  
  98. $result = $this->model->read_email_information($data);
  99. for ($i = 0; $i < count($expected); $i++) {
  100. $this->assertEquals($result[$i]->ACCOUNT_ID, $expected[$i]->ACCOUNT_ID);
  101. $this->assertEquals($result[$i]->FIRST_NAME, $expected[$i]->FIRST_NAME);
  102. $this->assertEquals($result[$i]->LAST_NAME, $expected[$i]->LAST_NAME);
  103. $this->assertEquals($result[$i]->EMAIL, $expected[$i]->EMAIL);
  104. $this->assertEquals($result[$i]->PASSWORD, $expected[$i]->PASSWORD);
  105. $this->assertEquals($result[$i]->TYPE, $expected[$i]->TYPE);
  106. $this->assertEquals($result[$i]->BLOCKED, $expected[$i]->BLOCKED);
  107. }
  108. }
  109.  
  110. /* @Author: Kevin Van Meerbeek
  111. * Created on: 21/05/2016
  112. * Last modified: 22/05/2016
  113. * Checkt of het ingegeven emailadres overeen komt met het emailadres uit de database
  114. * */
  115.  
  116. public function test_loginModelCheckEmail()
  117. {
  118. $data = [
  119. 0 => (object)['EMAIL' => 'dispatcher@gmail.com'],
  120. ];
  121. $result = $this->model->check_email($data);
  122. $expectedResult = true;
  123. $this->assertEquals($result, $expectedResult);
  124. }
  125.  
  126. /* @Author: Kevin Van Meerbeek
  127. * Created on: 21/05/2016
  128. * Last modified: 22/05/2016
  129. * Checkt of het ingegeven wachtwoord overeen komt met het wachtwoord uit de database
  130. * */
  131.  
  132. public function test_loginModelCheckPassword()
  133. {
  134. $data = [
  135. 0 => (object)['PASSWORD' => '098f6bcd4621d373cade4e832627b4f6'],
  136. ];
  137.  
  138. $result = $this->model->check_password($data);
  139. $expectedResult = true;
  140. $this->assertEquals($result, $expectedResult);
  141. }
  142.  
  143. /* @Author: Kevin Van Meerbeek
  144. * Created on: 21/05/2016
  145. * Last modified: 22/05/2016
  146. * Test of het wachtwoord reset kan worden aan de hand van het ingegeven emailadres
  147. * */
  148.  
  149. public function test_loginModelResetPassword()
  150. {
  151. $expected = [
  152. 0 => (object)['EMAIL' => 'dispatcher@gmail.com'],
  153. ];
  154. $new_pass = 'ab642ce62f55b2ca05b4697f3bd7b53a';
  155. $this->model->reset_password($expected,$new_pass);
  156. }
  157.  
  158. /* @Author: Kevin Van Meerbeek
  159. * Created on: 21/05/2016
  160. * Last modified: 22/05/2016
  161. * Test of het oude wachtwoord gewijzigd wordt naar het nieuwe ingegeven wachtwoord
  162. * */
  163.  
  164. public function test_loginModelUpdatePassword()
  165. {
  166. $data = [
  167. 0 => (object)['PASSWORD' => '098f6bcd4621d373cade4e832627b4f6'],
  168. ];
  169. $new_pass = 'ab642ce62f55b2ca05b4697f3bd7b53a';
  170. $this->model->reset_password($data,$new_pass);
  171. }
  172.  
  173. /* @Author: Kevin Van Meerbeek
  174. * Created on: 21/05/2016
  175. * Last modified: 22/05/2016
  176. * Test of de gebruiker kan geblokkeerd worden aan de hand van het ingegeven emailadres
  177. * */
  178.  
  179. public function test_loginModelUpdateBlocked()
  180. {
  181. $data = [
  182. 0 => (object)['EMAIL' => 'dispatcher@gmail.com'],
  183. ];
  184. $this->model->update_blocked($data);
  185. }
  186.  
  187. /* @Author: Kevin Van Meerbeek
  188. * Created on: 21/05/2016
  189. * Last modified: 22/05/2016
  190. * Test of de gebruiker kan gedeblokkeerd worden aan de hand van het ingegeven emailadres
  191. * */
  192.  
  193. public function test_loginModelUpdateUnBlocked()
  194. {
  195. $data = [
  196. 0 => (object)['EMAIL' => 'dispatcher@gmail.com'],
  197. ];
  198. $this->model->update_blocked($data);
  199. }
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement