Skip to content

Commit

Permalink
[TEST] Add missing lt and lte test operators
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Jul 19, 2017
1 parent 776c865 commit 02adc14
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/Elasticsearch/Tests/YamlRunnerTest.php
Expand Up @@ -210,6 +210,14 @@ public function processOperation($operation, $lastOperationResult, &$context, $t
return $this->operationGreaterThan($operation->{$operationName}, $lastOperationResult, $context, $testName);
}

if ('lte' === $operationName) {
return $this->operationLessThanOrEqual($operation->{$operationName}, $lastOperationResult, $context, $testName);
}

if ('t' === $operationName) {
return $this->operationLessThan($operation->{$operationName}, $lastOperationResult, $context, $testName);
}

if ('length' === $operationName) {
return $this->operationLength($operation->{$operationName}, $lastOperationResult, $context, $testName);
}
Expand Down Expand Up @@ -538,6 +546,40 @@ public function operationGreaterThan($operation, $lastOperationResult, &$context
return $lastOperationResult;
}

/**
* Check if a field in the last operation is less than or equal a value
*
* @param $operation
* @param $lastOperationResult
* @param $testName
*/
public function operationLessThanOrEqual($operation, $lastOperationResult, &$context, $testName)
{
$value = $this->resolveValue($lastOperationResult, key($operation), $context);
$expected = current($operation);

static::assertLessThanOrEqual($expected, $value, 'Failed to lte in test ' . $testName);

return $lastOperationResult;
}

/**
* Check if a field in the last operation is less than a value
*
* @param $operation
* @param $lastOperationResult
* @param $testName
*/
public function operationLessThan($operation, $lastOperationResult, &$context, $testName)
{
$value = $this->resolveValue($lastOperationResult, key($operation), $context);
$expected = current($operation);

static::assertLessThan($expected, $value, 'Failed to lt in test ' . $testName);

return $lastOperationResult;
}

/**
* Check if a field in the last operation has length of a value
*
Expand Down

0 comments on commit 02adc14

Please sign in to comment.