[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/tests/behat/ -> behat_hooks.php (summary)

Behat hooks steps definitions. This methods are used by Behat CLI command.

Copyright: 2012 David Monllaó
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 569 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 7 files
 lib/testing/classes/nasty_strings.php
 lib/behat/classes/util.php
 lib/behat/behat_base.php
 lib/behat/classes/behat_selectors.php
 lib/testing/classes/test_lock.php
 lib/behat/classes/behat_command.php
 lib/behat/classes/behat_context_helper.php

Defines 1 class

behat_hooks:: (14 methods):
  before_suite()
  before_scenario()
  before_step_javascript()
  after_step_javascript()
  after_step()
  get_run_faildump_dir()
  take_screenshot()
  take_contentdump()
  get_faildump_filename()
  wait_for_pending_js()
  i_look_for_exceptions()
  get_debug_text()
  is_first_scenario()
  throw_unknown_exception()


Class: behat_hooks  - X-Ref

Hooks to the behat process.

Behat accepts hooks after and before each
suite, feature, scenario and step.

They can not call other steps as part of their process
like regular steps definitions does.

Throws generic Exception because they are captured by Behat.

before_suite($event)   X-Ref
Gives access to moodle codebase, ensures all is ready and sets up the test lock.

Includes config.php to use moodle codebase with $CFG->behat_*
instead of $CFG->prefix and $CFG->dataroot, called once per suite.


before_scenario($event)   X-Ref
Resets the test environment.


before_step_javascript($event)   X-Ref
Wait for JS to complete before beginning interacting with the DOM.

Executed only when running against a real browser. We wrap it
all in a try & catch to forward the exception to i_look_for_exceptions
so the exception will be at scenario level, which causes a failure, by
default would be at framework level, which will stop the execution of
the run.


after_step_javascript($event)   X-Ref
Wait for JS to complete after finishing the step.

With this we ensure that there are not AJAX calls
still in progress.

Executed only when running against a real browser. We wrap it
all in a try & catch to forward the exception to i_look_for_exceptions
so the exception will be at scenario level, which causes a failure, by
default would be at framework level, which will stop the execution of
the run.


after_step($event)   X-Ref
Execute any steps required after the step has finished.

This includes creating an HTML dump of the content if there was a failure.


get_run_faildump_dir()   X-Ref
Getter for self::$faildumpdirname

return: string

take_screenshot(StepEvent $event)   X-Ref
Take screenshot when a step fails.

param: StepEvent $event

take_contentdump(StepEvent $event)   X-Ref
Take a dump of the page content when a step fails.

param: StepEvent $event

get_faildump_filename(StepEvent $event, $filetype)   X-Ref
Determine the full pathname to store a failure-related dump.

This is used for content such as the DOM, and screenshots.

param: StepEvent $event
param: String $filetype The file suffix to use. Limited to 4 chars.

wait_for_pending_js()   X-Ref
Waits for all the JS to be loaded.

return: bool True or false depending whether all the JS is loaded or not.

i_look_for_exceptions()   X-Ref
Internal step definition to find exceptions, debugging() messages and PHP debug messages.

Part of behat_hooks class as is part of the testing framework, is auto-executed
after each step so no features will splicitly use it.


get_debug_text($html)   X-Ref
Converts HTML tags to line breaks to display the info in CLI

param: string $html
return: string

is_first_scenario()   X-Ref
Returns whether the first scenario of the suite is running

return: bool

throw_unknown_exception(UnknownError $exception)   X-Ref
Throws an exception after appending an extra info text.

param: UnknownError $exception
return: void



Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1