FeatureContext.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. use Behat\Behat\Context\ClosuredContextInterface,
  3. Behat\Behat\Context\TranslatedContextInterface,
  4. Behat\Behat\Context\BehatContext,
  5. Behat\Behat\Context\Step\Given,
  6. Behat\Behat\Exception\PendingException,
  7. Behat\Behat\Event\SuiteEvent;
  8. use Behat\Gherkin\Node\PyStringNode,
  9. Behat\Gherkin\Node\TableNode;
  10. use Behat\MinkExtension\Context\MinkContext;
  11. //
  12. // Require 3rd-party libraries here:
  13. //
  14. // require_once 'PHPUnit/Autoload.php';
  15. // require_once 'PHPUnit/Framework/Assert/Functions.php';
  16. //
  17. /**
  18. * Features context. (MinkContext extends BehatContext)
  19. */
  20. class FeatureContext extends MinkContext
  21. {
  22. /**
  23. * Initializes context.
  24. * Every scenario gets its own context object.
  25. *
  26. * @param array $parameters context parameters (set them up through behat.yml)
  27. */
  28. public function __construct(array $parameters)
  29. {
  30. // Initialize your context here
  31. }
  32. /**
  33. * @Given /^I am a platform administrator$/
  34. */
  35. public function iAmAPlatformAdministrator()
  36. {
  37. return array(
  38. new Given('I am on "/index.php?logout=logout"'),
  39. new Given('I am on homepage'),
  40. new Given('I fill in "login" with "admin"'),
  41. new Given('I fill in "password" with "admin"'),
  42. new Given('I press "submitAuth"')
  43. );
  44. }
  45. /**
  46. * @Given /^I am a session administrator$/
  47. */
  48. public function iAmASessionAdministrator()
  49. {
  50. return array(
  51. new Given('I am on "/index.php?logout=logout"'),
  52. new Given('I am on homepage'),
  53. new Given('I fill in "login" with "amaurichard"'),
  54. new Given('I fill in "password" with "amaurichard"'),
  55. new Given('I press "submitAuth"')
  56. );
  57. }
  58. /**
  59. * @Given /^I am a teacher$/
  60. */
  61. public function iAmATeacher()
  62. {
  63. return array(
  64. new Given('I am on "/index.php?logout=logout"'),
  65. new Given('I am on homepage'),
  66. new Given('I fill in "login" with "mmosquera"'),
  67. new Given('I fill in "password" with "mmosquera"'),
  68. new Given('I press "submitAuth"')
  69. );
  70. }
  71. /**
  72. * @Given /^I am a teacher in course "([^"]*)"$/
  73. * @Todo implement
  74. */
  75. public function iAmATeacherInCourse($course)
  76. {
  77. //$sql = "SELECT * FROM course_rel_user WHERE c_id = X AND user_id = ";
  78. //$result = ...
  79. //if ($result !== false) { ... }
  80. }
  81. /**
  82. * @Given /^I am a student$/
  83. */
  84. public function iAmAStudent()
  85. {
  86. return array(
  87. new Given('I am on "/index.php?logout=logout"'),
  88. new Given('I am on homepage'),
  89. new Given('I fill in "login" with "mbrandybuck"'),
  90. new Given('I fill in "password" with "mbrandybuck"'),
  91. new Given('I press "submitAuth"')
  92. );
  93. }
  94. /**
  95. * @Given /^I am an HR manager$/
  96. */
  97. public function iAmAnHR()
  98. {
  99. return array(
  100. new Given('I am on "/index.php?logout=logout"'),
  101. new Given('I am on homepage'),
  102. new Given('I fill in "login" with "ptook"'),
  103. new Given('I fill in "password" with "ptook"'),
  104. new Given('I press "submitAuth"')
  105. );
  106. }
  107. /**
  108. * @Given /^I am a student boss$/
  109. */
  110. public function iAmAStudentBoss()
  111. {
  112. return array(
  113. new Given('I am on "/index.php?logout=logout"'),
  114. new Given('I am on homepage'),
  115. new Given('I fill in "login" with "abaggins"'),
  116. new Given('I fill in "password" with "abaggins"'),
  117. new Given('I press "submitAuth"')
  118. );
  119. }
  120. /**
  121. * @Given /^I am an invitee$/
  122. */
  123. public function iAmAnInvitee()
  124. {
  125. return array(
  126. new Given('I am on "/index.php?logout=logout"'),
  127. new Given('I am on homepage'),
  128. new Given('I fill in "login" with "bproudfoot"'),
  129. new Given('I fill in "password" with "bproudfoot"'),
  130. new Given('I press "submitAuth"')
  131. );
  132. }
  133. /**
  134. * @Given /^course "([^"]*)" exists$/
  135. */
  136. public function courseExists($argument)
  137. {
  138. return array(
  139. new Given('I am a platform administrator'),
  140. new Given('I am on "/main/admin/course_list.php?keyword=' . $argument . '"'),
  141. new Given('I should see "' . $argument . '"'),
  142. );
  143. }
  144. /**
  145. * @Given /^course "([^"]*)" is deleted$/
  146. */
  147. public function courseIsDeleted($argument)
  148. {
  149. return array(
  150. new Given('I am a platform administrator'),
  151. new Given('I am on "/main/admin/course_list.php?keyword=' . $argument . '"'),
  152. new Given('I follow "Delete"')
  153. );
  154. }
  155. /**
  156. * @Given /^I am in course "([^"]*)"$/
  157. * @Todo redefine function to be different from I am on course TEMP homepage
  158. */
  159. public function iAmInCourse($argument)
  160. {
  161. return array(
  162. new Given('I am on "/main/course_home/course_home.php?cDir=' . $argument . '"'),
  163. new Given('I should not see an ".alert-danger" element')
  164. );
  165. }
  166. /**
  167. * @Given /^I am on course "([^"]*)" homepage$/
  168. */
  169. public function iAmOnCourseXHomepage($argument)
  170. {
  171. return array(
  172. new Given('I am on "/main/course_home/course_home.php?cDir=' . $argument . '"'),
  173. new Given('I should not see an ".alert-danger" element')
  174. );
  175. }
  176. }