PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/editor/atto/tests/behat/behat_editor_atto.php

https://bitbucket.org/moodle/moodle
PHP | 64 lines | 14 code | 9 blank | 41 comment | 2 complexity | 7bef0dfb1b3f8b14170a7b88dadcef21 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1, BSD-3-Clause, MIT, GPL-3.0
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Atto custom steps definitions.
  18. *
  19. * @package editor_atto
  20. * @category test
  21. * @copyright 2014 Damyon Wiese
  22. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23. */
  24. // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
  25. require_once(__DIR__ . '/../../../../behat/behat_base.php');
  26. /**
  27. * Steps definitions to deal with the atto text editor
  28. *
  29. * @package editor_atto
  30. * @category test
  31. * @copyright 2014 Damyon Wiese
  32. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33. */
  34. class behat_editor_atto extends behat_base {
  35. /**
  36. * Select the text in an Atto field.
  37. *
  38. * @Given /^I select the text in the "([^"]*)" Atto editor$/
  39. * @throws ElementNotFoundException Thrown by behat_base::find
  40. * @param string $field
  41. * @return void
  42. */
  43. public function select_the_text_in_the_atto_editor($fieldlocator) {
  44. if (!$this->running_javascript()) {
  45. throw new coding_exception('Selecting text requires javascript.');
  46. }
  47. // We delegate to behat_form_field class, it will
  48. // guess the type properly.
  49. $field = behat_field_manager::get_form_field_from_label($fieldlocator, $this);
  50. if (!method_exists($field, 'select_text')) {
  51. throw new coding_exception('Field does not support the select_text function.');
  52. }
  53. $field->select_text();
  54. }
  55. }