| @@ 49-56 (lines=8) @@ | ||
| 46 | * @throws \Exception |
|
| 47 | * If region or button within it cannot be found. |
|
| 48 | */ |
|
| 49 | public function assertRegionButton($button, $region) { |
|
| 50 | $regionObj = $this->getRegion($region); |
|
| 51 | ||
| 52 | $buttonObj = $regionObj->findButton($button); |
|
| 53 | if (empty($buttonObj)) { |
|
| 54 | throw new \Exception(sprintf("The button '%s' was not found in the region '%s' on the page %s", $button, $region, $this->getSession()->getCurrentUrl())); |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * @Then I( should) see the :tag element in the :region( region) |
|
| @@ 61-68 (lines=8) @@ | ||
| 58 | /** |
|
| 59 | * @Then I( should) see the :tag element in the :region( region) |
|
| 60 | */ |
|
| 61 | public function assertRegionElement($tag, $region) { |
|
| 62 | $regionObj = $this->getRegion($region); |
|
| 63 | $elements = $regionObj->findAll('css', $tag); |
|
| 64 | if (!empty($elements)) { |
|
| 65 | return; |
|
| 66 | } |
|
| 67 | throw new \Exception(sprintf('The element "%s" was not found in the "%s" region on the page %s', $tag, $region, $this->getSession()->getCurrentUrl())); |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * @Then I( should) not see the :tag element in the :region( region) |
|
| @@ 73-79 (lines=7) @@ | ||
| 70 | /** |
|
| 71 | * @Then I( should) not see the :tag element in the :region( region) |
|
| 72 | */ |
|
| 73 | public function assertNotRegionElement($tag, $region) { |
|
| 74 | $regionObj = $this->getRegion($region); |
|
| 75 | $result = $regionObj->findAll('css', $tag); |
|
| 76 | if (!empty($result)) { |
|
| 77 | throw new \Exception(sprintf('The element "%s" was found in the "%s" region on the page %s', $tag, $region, $this->getSession()->getCurrentUrl())); |
|
| 78 | } |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @Then I( should) not see :text in the :tag element in the :region( region) |
|
| @@ 25-33 (lines=9) @@ | ||
| 22 | * |
|
| 23 | * @todo this should be a trait when PHP 5.3 support is dropped. |
|
| 24 | */ |
|
| 25 | public function getRegion($region) { |
|
| 26 | $session = $this->getSession(); |
|
| 27 | $regionObj = $session->getPage()->find('region', $region); |
|
| 28 | if (!$regionObj) { |
|
| 29 | throw new \Exception(sprintf('No region "%s" found on the page %s.', $region, $session->getCurrentUrl())); |
|
| 30 | } |
|
| 31 | ||
| 32 | return $regionObj; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * Checks if a button with id|name|title|alt|value exists in a region |
|
| @@ 335-341 (lines=7) @@ | ||
| 332 | * @Then I (should ) see the button :button |
|
| 333 | * @Then I (should ) see the :button button |
|
| 334 | */ |
|
| 335 | public function assertButton($button) { |
|
| 336 | $element = $this->getSession()->getPage(); |
|
| 337 | $buttonObj = $element->findButton($button); |
|
| 338 | if (empty($buttonObj)) { |
|
| 339 | throw new \Exception(sprintf("The button '%s' was not found on the page %s", $button, $this->getSession()->getCurrentUrl())); |
|
| 340 | } |
|
| 341 | } |
|
| 342 | ||
| 343 | /** |
|
| 344 | * @Then I should not see the button :button |
|
| @@ 347-353 (lines=7) @@ | ||
| 344 | * @Then I should not see the button :button |
|
| 345 | * @Then I should not see the :button button |
|
| 346 | */ |
|
| 347 | public function assertNotButton($button) { |
|
| 348 | $element = $this->getSession()->getPage(); |
|
| 349 | $buttonObj = $element->findButton($button); |
|
| 350 | if (!empty($buttonObj)) { |
|
| 351 | throw new \Exception(sprintf("The button '%s' was found on the page %s", $button, $this->getSession()->getCurrentUrl())); |
|
| 352 | } |
|
| 353 | } |
|
| 354 | ||
| 355 | /** |
|
| 356 | * @When I follow/click :link in the :region( region) |
|
| @@ 361-370 (lines=10) @@ | ||
| 358 | * @throws \Exception |
|
| 359 | * If region or link within it cannot be found. |
|
| 360 | */ |
|
| 361 | public function assertRegionLinkFollow($link, $region) { |
|
| 362 | $regionObj = $this->getRegion($region); |
|
| 363 | ||
| 364 | // Find the link within the region |
|
| 365 | $linkObj = $regionObj->findLink($link); |
|
| 366 | if (empty($linkObj)) { |
|
| 367 | throw new \Exception(sprintf('The link "%s" was not found in the region "%s" on the page %s', $link, $region, $this->getSession()->getCurrentUrl())); |
|
| 368 | } |
|
| 369 | $linkObj->click(); |
|
| 370 | } |
|
| 371 | ||
| 372 | /** |
|
| 373 | * Checks, if a button with id|name|title|alt|value exists or not and pressess the same |
|
| @@ 385-393 (lines=9) @@ | ||
| 382 | * @throws \Exception |
|
| 383 | * If region or button within it cannot be found. |
|
| 384 | */ |
|
| 385 | public function assertRegionPressButton($button, $region) { |
|
| 386 | $regionObj = $this->getRegion($region); |
|
| 387 | ||
| 388 | $buttonObj = $regionObj->findButton($button); |
|
| 389 | if (empty($buttonObj)) { |
|
| 390 | throw new \Exception(sprintf("The button '%s' was not found in the region '%s' on the page %s", $button, $region, $this->getSession()->getCurrentUrl())); |
|
| 391 | } |
|
| 392 | $regionObj->pressButton($button); |
|
| 393 | } |
|
| 394 | ||
| 395 | /** |
|
| 396 | * Fills in a form field with id|name|title|alt|value in the specified region. |
|
| @@ 443-450 (lines=8) @@ | ||
| 440 | * @throws \Exception |
|
| 441 | * If region or link within it cannot be found. |
|
| 442 | */ |
|
| 443 | public function assertLinkRegion($link, $region) { |
|
| 444 | $regionObj = $this->getRegion($region); |
|
| 445 | ||
| 446 | $result = $regionObj->findLink($link); |
|
| 447 | if (empty($result)) { |
|
| 448 | throw new \Exception(sprintf('No link to "%s" in the "%s" region on the page %s', $link, $region, $this->getSession()->getCurrentUrl())); |
|
| 449 | } |
|
| 450 | } |
|
| 451 | ||
| 452 | /** |
|
| 453 | * @Then I should not see the link :link in the :region( region) |
|
| @@ 458-465 (lines=8) @@ | ||
| 455 | * @throws \Exception |
|
| 456 | * If region or link within it cannot be found. |
|
| 457 | */ |
|
| 458 | public function assertNotLinkRegion($link, $region) { |
|
| 459 | $regionObj = $this->getRegion($region); |
|
| 460 | ||
| 461 | $result = $regionObj->findLink($link); |
|
| 462 | if (!empty($result)) { |
|
| 463 | throw new \Exception(sprintf('Link to "%s" in the "%s" region on the page %s', $link, $region, $this->getSession()->getCurrentUrl())); |
|
| 464 | } |
|
| 465 | } |
|
| 466 | ||
| 467 | /** |
|
| 468 | * @Then I should see( the text) :text in the :region( region) |
|
| @@ 473-481 (lines=9) @@ | ||
| 470 | * @throws \Exception |
|
| 471 | * If region or text within it cannot be found. |
|
| 472 | */ |
|
| 473 | public function assertRegionText($text, $region) { |
|
| 474 | $regionObj = $this->getRegion($region); |
|
| 475 | ||
| 476 | // Find the text within the region |
|
| 477 | $regionText = $regionObj->getText(); |
|
| 478 | if (strpos($regionText, $text) === FALSE) { |
|
| 479 | throw new \Exception(sprintf("The text '%s' was not found in the region '%s' on the page %s", $text, $region, $this->getSession()->getCurrentUrl())); |
|
| 480 | } |
|
| 481 | } |
|
| 482 | ||
| 483 | /** |
|
| 484 | * @Then I should not see( the text) :text in the :region( region) |
|
| @@ 489-497 (lines=9) @@ | ||
| 486 | * @throws \Exception |
|
| 487 | * If region or text within it cannot be found. |
|
| 488 | */ |
|
| 489 | public function assertNotRegionText($text, $region) { |
|
| 490 | $regionObj = $this->getRegion($region); |
|
| 491 | ||
| 492 | // Find the text within the region. |
|
| 493 | $regionText = $regionObj->getText(); |
|
| 494 | if (strpos($regionText, $text) !== FALSE) { |
|
| 495 | throw new \Exception(sprintf('The text "%s" was found in the region "%s" on the page %s', $text, $region, $this->getSession()->getCurrentUrl())); |
|
| 496 | } |
|
| 497 | } |
|
| 498 | ||
| 499 | /** |
|
| 500 | * @Then I (should )see the text :text |
|