MOBILE-4270 behat: Remove performance transforms
parent
ba1f469dfe
commit
345351cbd7
|
@ -54,8 +54,10 @@ class behat_performance extends behat_base {
|
||||||
*
|
*
|
||||||
* @Then /^"([^"]+)" should have taken (less than|more than|exactly) (\d+(?:\.\d+)? (?:seconds|milliseconds))$/
|
* @Then /^"([^"]+)" should have taken (less than|more than|exactly) (\d+(?:\.\d+)? (?:seconds|milliseconds))$/
|
||||||
*/
|
*/
|
||||||
public function timing_should_have_taken(string $measure, Closure $comparison, float $expectedtime) {
|
public function timing_should_have_taken(string $measure, string $comparison, string $expectedtime) {
|
||||||
$measuretiming = $this->get_performance_measure($measure);
|
$measuretiming = $this->get_performance_measure($measure);
|
||||||
|
$comparison = $this->parse_comparison($comparison);
|
||||||
|
$expectedtime = $this->parse_time($expectedtime);
|
||||||
|
|
||||||
if (!call_user_func($comparison, $measuretiming->duration, $expectedtime)) {
|
if (!call_user_func($comparison, $measuretiming->duration, $expectedtime)) {
|
||||||
throw new ExpectationException(
|
throw new ExpectationException(
|
||||||
|
@ -70,11 +72,10 @@ class behat_performance extends behat_base {
|
||||||
/**
|
/**
|
||||||
* Parse time.
|
* Parse time.
|
||||||
*
|
*
|
||||||
* @Transform /^\d+(?:\.\d+)? (?:seconds|milliseconds)$/
|
|
||||||
* @param string $text Time string.
|
* @param string $text Time string.
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function parse_time(string $text): float {
|
private function parse_time(string $text): float {
|
||||||
$spaceindex = strpos($text, ' ');
|
$spaceindex = strpos($text, ' ');
|
||||||
$value = floatval(substr($text, 0, $spaceindex));
|
$value = floatval(substr($text, 0, $spaceindex));
|
||||||
|
|
||||||
|
@ -88,11 +89,10 @@ class behat_performance extends behat_base {
|
||||||
/**
|
/**
|
||||||
* Parse a comparison function.
|
* Parse a comparison function.
|
||||||
*
|
*
|
||||||
* @Transform /^less than|more than|exactly$/
|
|
||||||
* @param string $text Comparison string.
|
* @param string $text Comparison string.
|
||||||
* @return Closure
|
* @return Closure
|
||||||
*/
|
*/
|
||||||
public function parse_comparison(string $text): Closure {
|
private function parse_comparison(string $text): Closure {
|
||||||
switch ($text) {
|
switch ($text) {
|
||||||
case 'less than':
|
case 'less than':
|
||||||
return function ($a, $b) {
|
return function ($a, $b) {
|
||||||
|
|
Loading…
Reference in New Issue