MDL-58428 behat: Check parent themes for Behat override steps.

Behat will now look at the current themes' parents for Behat ovveride steps.
If found we will use the steps replacing the Moodle core steps.
This commit is contained in:
Andrew Nicols 2019-01-17 13:57:12 +08:00 committed by Mathew May
parent e3652936f3
commit 4aefaf653b
10 changed files with 110 additions and 131 deletions

View file

@ -34,16 +34,22 @@ use Behat\Mink\Exception\ExpectationException as ExpectationException,
/**
* Steps definitions to deal with the filemanager and filepicker overrides.
*
* @package theme_bootstrapbase
* @category test
* @copyright 2016 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_theme_bootstrapbase_behat_filepicker extends behat_theme_bootstrapbase_behat_files {
class behat_theme_bootstrapbase_behat_filepicker extends behat_filepicker {
use theme_bootstrapbase_behat_file_helper;
public function i_create_folder_in_filemanager($foldername, $filemanagerelement) {
$fieldnode = $this->get_filepicker_node($filemanagerelement);
// Looking for the create folder button inside the specified filemanager.
$exception = new ExpectationException('No folders can be created in "'.$filemanagerelement.'" filemanager',$this->getSession());
$exception = new ExpectationException('No folders can be created in "'.$filemanagerelement.'" filemanager',
$this->getSession());
$newfolder = $this->find('css', 'div.fp-btn-mkdir a', $exception, $fieldnode);
$newfolder->click();
@ -143,7 +149,8 @@ class behat_theme_bootstrapbase_behat_filepicker extends behat_theme_bootstrapba
$elements = $this->find_all('xpath', $xpath, false, $filemanagernode);
if (count($elements) != $elementscount) {
throw new ExpectationException('Found '.count($elements).' elements in filemanager instead of expected '.$elementscount, $this->getSession());
throw new ExpectationException('Found '.count($elements).
' elements in filemanager instead of expected '.$elementscount, $this->getSession());
}
}

View file

@ -26,6 +26,7 @@
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../../repository/upload/tests/behat/behat_repository_upload.php');
require_once(__DIR__ . '/theme_bootstrapbase_behat_file_helper.php');
use Behat\Mink\Exception\ExpectationException as ExpectationException,
Behat\Gherkin\Node\TableNode as TableNode;
@ -40,6 +41,8 @@ use Behat\Mink\Exception\ExpectationException as ExpectationException,
*/
class behat_theme_bootstrapbase_behat_repository_upload extends behat_repository_upload {
use theme_bootstrapbase_behat_file_helper;
protected function upload_file_to_filemanager($filepath, $filemanagerelement, TableNode $data, $overwriteaction = false) {
global $CFG;
@ -108,5 +111,4 @@ class behat_theme_bootstrapbase_behat_repository_upload extends behat_repository
}
}
}

View file

@ -25,7 +25,7 @@
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../../lib/behat/behat_files.php');
require_once(__DIR__ . '/../../../../lib/behat/core_behat_file_helper.php');
use Behat\Mink\Exception\ExpectationException as ExpectationException,
Behat\Mink\Element\NodeElement as NodeElement;
@ -38,7 +38,11 @@ use Behat\Mink\Exception\ExpectationException as ExpectationException,
* @copyright 2016 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_theme_bootstrapbase_behat_files extends behat_files {
trait theme_bootstrapbase_behat_file_helper {
use core_behat_file_helper {
core_behat_file_helper::get_filepicker_node as core_get_filepicker_node;
}
protected function get_filepicker_node($filepickerelement) {