From 6d2c98a01fc4b1286b3c8cb1960f195f5efe4285 Mon Sep 17 00:00:00 2001 From: prinklov Date: Mon, 6 Jul 2020 01:24:56 +0300 Subject: [PATCH] add unit test for comparison expression --- .../Collections/Expr/ComparisonTest.php | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/Doctrine/Tests/Common/Collections/Expr/ComparisonTest.php diff --git a/tests/Doctrine/Tests/Common/Collections/Expr/ComparisonTest.php b/tests/Doctrine/Tests/Common/Collections/Expr/ComparisonTest.php new file mode 100644 index 000000000..17c26e0eb --- /dev/null +++ b/tests/Doctrine/Tests/Common/Collections/Expr/ComparisonTest.php @@ -0,0 +1,49 @@ +getField()); + self::assertEquals($operator, $comparisonExpression->getOperator()); + self::assertEquals($value, $comparisonExpression->getValue()->getValue()); + + $comparisonExpression = new Comparison($field, $operator, new Value($value)); + + self::assertEquals($value, $comparisonExpression->getValue()->getValue()); + } + + public function testVisitor() : void + { + $visitor = $this->getMockForAbstractClass(ExpressionVisitor::class); + $visitor + ->expects($this->once()) + ->method('walkComparison'); + + /** @var ExpressionVisitor $visitor */ + $field = 'id'; + $operator = Comparison::EQ; + $value = 'foo'; + + $comparisonExpression = new Comparison($field, $operator, $value); + $comparisonExpression->visit($visitor); + } +}