Skip to content

Commit

Permalink
[auto-generated] Update plugin files
Browse files Browse the repository at this point in the history
Check out the commits that caused these changes: moodlehq/moodleapp@6553d20...6ac81d1
  • Loading branch information
github-actions[bot] committed May 13, 2024
1 parent 0da0421 commit e2019fb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
34 changes: 33 additions & 1 deletion tests/behat/behat_app.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
require_once(__DIR__ . '/behat_app_helper.php');

use Behat\Behat\Hook\Scope\ScenarioScope;
use Behat\Behat\Hook\Scope\AfterStepScope;
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Exception\DriverException;
use Behat\Mink\Exception\ExpectationException;
Expand All @@ -44,7 +45,10 @@ class behat_app extends behat_app_helper {
],
];

protected $featurepath = '';
protected $featurepath;
protected $coveragepath;
protected $scenarioslug;
protected $scenariolaststep;

/**
* @BeforeScenario
Expand All @@ -56,7 +60,35 @@ public function before_scenario(ScenarioScope $scope) {
return;
}

$steps = $scope->getScenario()->getSteps();

$this->scenarioslug = $this->get_scenario_slug($scope);
$this->scenariolaststep = $steps[count($steps) - 1];
$this->featurepath = dirname($feature->getFile());
$this->coveragepath = get_config('local_moodleappbehat', 'coverage_path') ?: ($this->featurepath . DIRECTORY_SEPARATOR . 'coverage' . DIRECTORY_SEPARATOR);
}

/**
* @AfterStep
*/
public function after_step(AfterStepScope $scope) {
$step = $scope->getStep();

if ($step !== $this->scenariolaststep || empty($this->coveragepath)) {
return;
}

if (!is_dir($this->coveragepath)) {
if (!@mkdir($this->coveragepath, 0777, true)) {
throw new Exception("Cannot create {$this->coveragepath} directory.");
}
}

$coverage = $this->runtime_js('getCoverage()');

if (!is_null($coverage)) {
file_put_contents($this->coveragepath . $this->scenarioslug . '.json', $coverage);
}
}

/**
Expand Down
19 changes: 18 additions & 1 deletion tests/behat/behat_app_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');

use Behat\Behat\Hook\Scope\ScenarioScope;
use Behat\Mink\Exception\DriverException;
use Behat\Mink\Exception\ExpectationException;
use Moodle\BehatExtension\Exception\SkippedException;
Expand Down Expand Up @@ -357,7 +358,7 @@ protected function notify_unload(): void {
* @return mixed Result.
*/
protected function runtime_js(string $script) {
return $this->evaluate_script("window.behat.$script");
return $this->evaluate_script("window.behat?.$script");
}

/**
Expand Down Expand Up @@ -472,6 +473,22 @@ function($context) use ($successXPath) {
$this->i_wait_the_app_to_restart();
}

/**
* Get scenario slug.
*
* @param ScenarioScope $scope Scenario scope.
* @return string Slug.
*/
protected function get_scenario_slug(ScenarioScope $scope): string {
$text = $scope->getFeature()->getTitle() . ' ' . $scope->getScenario()->getTitle();
$text = trim($text);
$text = strtolower($text);
$text = preg_replace('/\s+/', '-', $text);
$text = preg_replace('/[^a-z0-9-]/', '', $text);

return $text;
}

/**
* Returns the current mobile url scheme of the site.
*/
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2024041700;
$plugin->version = 2024051300;
$plugin->requires = 2016052300;
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '4.4.0';
Expand Down

0 comments on commit e2019fb

Please sign in to comment.