Skip to content

Commit 02adc14

Browse files
committed
[TEST] Add missing lt and lte test operators
1 parent 776c865 commit 02adc14

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/Elasticsearch/Tests/YamlRunnerTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ public function processOperation($operation, $lastOperationResult, &$context, $t
210210
return $this->operationGreaterThan($operation->{$operationName}, $lastOperationResult, $context, $testName);
211211
}
212212

213+
if ('lte' === $operationName) {
214+
return $this->operationLessThanOrEqual($operation->{$operationName}, $lastOperationResult, $context, $testName);
215+
}
216+
217+
if ('t' === $operationName) {
218+
return $this->operationLessThan($operation->{$operationName}, $lastOperationResult, $context, $testName);
219+
}
220+
213221
if ('length' === $operationName) {
214222
return $this->operationLength($operation->{$operationName}, $lastOperationResult, $context, $testName);
215223
}
@@ -538,6 +546,40 @@ public function operationGreaterThan($operation, $lastOperationResult, &$context
538546
return $lastOperationResult;
539547
}
540548

549+
/**
550+
* Check if a field in the last operation is less than or equal a value
551+
*
552+
* @param $operation
553+
* @param $lastOperationResult
554+
* @param $testName
555+
*/
556+
public function operationLessThanOrEqual($operation, $lastOperationResult, &$context, $testName)
557+
{
558+
$value = $this->resolveValue($lastOperationResult, key($operation), $context);
559+
$expected = current($operation);
560+
561+
static::assertLessThanOrEqual($expected, $value, 'Failed to lte in test ' . $testName);
562+
563+
return $lastOperationResult;
564+
}
565+
566+
/**
567+
* Check if a field in the last operation is less than a value
568+
*
569+
* @param $operation
570+
* @param $lastOperationResult
571+
* @param $testName
572+
*/
573+
public function operationLessThan($operation, $lastOperationResult, &$context, $testName)
574+
{
575+
$value = $this->resolveValue($lastOperationResult, key($operation), $context);
576+
$expected = current($operation);
577+
578+
static::assertLessThan($expected, $value, 'Failed to lt in test ' . $testName);
579+
580+
return $lastOperationResult;
581+
}
582+
541583
/**
542584
* Check if a field in the last operation has length of a value
543585
*

0 commit comments

Comments
 (0)