diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:31:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:31:28 +0000 |
commit | 067008c5f094ba9606daacbe540f6b929dc124ea (patch) | |
tree | 3092ce2cd8bf1ac6db6c97f4c98c7f71a51c6ac8 /test/php/library/X509/Model/Behavior/ExpressionInjectorTest.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-x509-320d936634e932a97c1dd20bc4e5f7ec61c66565.tar.xz icingaweb2-module-x509-320d936634e932a97c1dd20bc4e5f7ec61c66565.zip |
Adding upstream version 1:1.3.2.upstream/1%1.3.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/php/library/X509/Model/Behavior/ExpressionInjectorTest.php')
-rw-r--r-- | test/php/library/X509/Model/Behavior/ExpressionInjectorTest.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/php/library/X509/Model/Behavior/ExpressionInjectorTest.php b/test/php/library/X509/Model/Behavior/ExpressionInjectorTest.php new file mode 100644 index 0000000..5481ce9 --- /dev/null +++ b/test/php/library/X509/Model/Behavior/ExpressionInjectorTest.php @@ -0,0 +1,38 @@ +<?php + +/* Icinga Web 2 X.509 Module | (c) 2023 Icinga GmbH | GPLv2 */ + +namespace Tests\Icinga\Modules\X509\Model\Behavior; + +use Icinga\Module\X509\Model\Behavior\ExpressionInjector; +use ipl\Orm\Query; +use ipl\Sql\Connection; +use ipl\Stdlib\Filter\Equal; +use PHPUnit\Framework\TestCase; +use Tests\Icinga\Module\X509\Lib\TestModel; + +class ExpressionInjectorTest extends TestCase +{ + public function testRewriteConditionReplacesExpressionColumnByItsExpression() + { + $cond = new Equal('duration', 'FOOO'); + $cond->metaData()->set('columnName', 'duration'); + $this->assertSame('duration', $cond->getColumn()); + $this->assertSame('FOOO', $cond->getValue()); + + $this->behavior()->rewriteCondition($cond); + + $this->assertSame('FOOO', $cond->getValue()); + $this->assertSame(TestModel::EXPRESSION, $cond->getColumn()); + } + + protected function behavior(): ExpressionInjector + { + return (new ExpressionInjector('duration')) + ->setQuery( + (new Query()) + ->setDb(new Connection(['db' => 'mysql'])) + ->setModel(new TestModel()) + ); + } +} |