Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. <?php
  2.  
  3. use Behat\Behat\Context\Context;
  4. use Behat\Behat\Context\SnippetAcceptingContext;
  5. use Behat\Behat\Context\TranslatedContextInterface;
  6. use Behat\Gherkin\Node\PyStringNode;
  7. use Behat\Gherkin\Node\TableNode;
  8. use Behat\MinkExtension\Context\MinkContext;
  9. use Behat\Mink\Mink;
  10. use Behat\Mink\Driver\GoutteDriver;
  11. use behat\Mink\Session;
  12. /**
  13. * Defines application features from the specific context.
  14. */
  15. class FeatureContext extends MinkContext
  16. {
  17. protected $session;
  18. protected $typ;
  19. /**
  20. * Initializes context.
  21. *
  22. * Every scenario gets its own context instance.
  23. * You can also pass arbitrary arguments to the
  24. * context constructor through behat.yml.
  25. */
  26.  
  27. /**
  28. * @Given Wchodze na strone :arg1
  29. */
  30. public function wchodzeNaStrone($arg1)
  31. {
  32. // Choose a Mink driver.
  33.  
  34. $driver = new \Behat\Mink\Driver\GoutteDriver();
  35. $this->session = new \Behat\Mink\Session($driver);
  36.  
  37. // start the session
  38. $this->session->start();
  39.  
  40. $this->session->visit('http://examinechina.local/app_dev.php/');
  41.  
  42. }
  43.  
  44. /**
  45. * @When Wciskam przycisk :arg1
  46. */
  47. public function wciskamPrzycisk($arg1)
  48. {
  49. $bol=1;
  50. $bol=$this->session->getPage();
  51. $przycisk=$bol->find('css','.button-orange')->click();
  52. $sprawdzenie1 = $this->session->getCurrentUrl();
  53. $url="http://examinechina.local/app_dev.php/order-report";
  54. if($sprawdzenie1 !== $url){
  55. throw new exception("Nuuu ni kaak... U mnie jest: " . $sprawdzenie1);
  56. }
  57. }
  58. /**
  59. * @When Wypelniam pole company name :arg1
  60. */
  61. public function wypelniamPoleCompanyName($arg1)
  62. {
  63. $bol=1;
  64. //nazwa firmy chinskiej
  65. $bol=$this->session->getPage();
  66. $companyname = $bol->find('css','INPUT#client_reports_0_name');
  67. if($companyname===NULL){
  68. throw new exception("Nie ma pola company name");
  69. }else
  70. {
  71. $companyname->setValue($arg1);
  72. }
  73. }
  74. /**
  75. * @When Wybieram opcje :arg1
  76. */
  77. public function wybieramOpcje($arg1)
  78. {
  79. $str=1;
  80. $str=$this->session->getPage();
  81. if($arg1 === "1 One" || $arg1=== "72h" || $arg1=== "Dragon"){
  82. $szukamy = $str->find('css','INPUT#client_reports_0_speed')->setValue($arg1);
  83. echo "wybrano opcje cenowa: " . $arg1;
  84. }else{
  85. throw new exception("Nie ma takiej opcji cenowej jak: " . $arg1);
  86. }
  87.  
  88. }
  89. /**
  90. * @When Wypelniam pole name :arg1
  91. */
  92. public function wypelniamPoleName($arg1)
  93. {
  94. $bil=1;
  95. $bil=$this->session->getPage();
  96. //nazwa klienta
  97. $name = $bil->find('css', 'INPUT#client_name');
  98. if($name === null){
  99. throw new exception("Nie ma pola client name");
  100. }
  101. $name->setValue($arg1);
  102. }
  103. /**
  104. * @When Wypelniam pole phone :arg1
  105. */
  106. public function wypelniamPolePhone($arg1)
  107. {
  108. $bal=1;
  109. $bal=$this->session->getPage();
  110. //telefon
  111. $phone = $bal->find('css', 'INPUT#client_phone');
  112. if($phone ===null){
  113. throw new exception("Nie ma pola phone");
  114. }
  115. $phone->setValue($arg1);
  116. }
  117.  
  118. /**
  119. * @When wypelniam pole email :arg1
  120. */
  121. public function wypelniamPoleEmail($arg1)
  122. {
  123. $bsl=1;
  124. $bsl=$this->session->getPage();
  125. //email
  126. $email = $bsl->find('css', 'INPUT#client_email');
  127. if($email ===null){
  128. throw new exception("Nie ma pola email");
  129. }
  130. $email->setValue($arg1);
  131. }
  132. /**
  133. * @When Wybieram czy chce fakture :arg1
  134. */
  135. public function wybieramCzyChceFakture($arg1)
  136. {
  137. $omnom=1;
  138. $omnom=$this->session->getPage();
  139. $faktura=$omnom->find('css', 'INPUT#client_invoice');
  140. $faktura->getValue();
  141. if($arg1 ==="tak"){
  142. if($faktura->isChecked()){
  143. echo "wybrano fakture (domyslnie)";
  144. }
  145. else { $faktura->check();
  146. echo "wybrano fakture";}
  147. }
  148.  
  149. if($arg1==="nie"){
  150. if($faktura->isChecked()){
  151. $faktura->uncheck();
  152. echo "Nie chcesz fakturki? :<";
  153. }
  154. else{
  155. echo "Nie chcesz fakturki? :<<<";
  156. }
  157. }
  158. }
  159.  
  160. /**
  161. * @When Wybieram typ platnosci :arg1
  162. */
  163. public function wybieramTypPlatnosci($arg1)
  164. {
  165. return $this->typ=$arg1;
  166. }
  167. /**
  168. * @When naciskam przycisk :arg1
  169. */
  170. public function naciskamPrzycisk2($arg1)
  171. {
  172. //wcisniecie przycisku "order raport"
  173. $bzl=1;
  174. $bzl=$this->session->getPage();
  175. if($this->typ==="paypal"){
  176. $button= $bzl->find('css','#submit_paypal > button:nth-child(1)')->click();
  177. }
  178. if($this->typ==="przelew"){
  179. $button=$bzl->find('css','#submit_bank > button:nth-child(1)')->click();
  180. }
  181. }
  182.  
  183. /**
  184. * @Then Powinienem zobaczyc :arg1
  185. */
  186. public function powinienemZobaczyc($arg1)
  187. {
  188. $trytka=1;
  189. $trytka=$this->session->getCurrentUrl();
  190. echo $trytka;
  191. $text=$this->session->getPage()->find('xpath','//h3[text()="Thank you for ordering a credit report from ExamineChina."]');
  192. if($text===null){
  193. throw new exception("no nie udalo sie...");
  194. }
  195.  
  196.  
  197.  
  198.  
  199. }
  200.  
  201.  
  202.  
  203. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement