Source
$quoted.'>0 and '.$unquoted.'>0 or '.$quoted.'>'.$unquoted.' and '.$quoted.'>0 and '.$unquoted.'>0 or '.
<?php declare(strict_types = 0);
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
use PHPUnit\Framework\TestCase;
class GetExpressionTreeTest extends TestCase {
private $expression_parser;
protected function setUp(): void {
$this->expression_parser = new CExpressionParser(['usermacros' => true]);
}
protected function tearDown(): void {
$this->expression_parser = null;
}
public function provider() {
// make sure logical operators aren't parsed within the context of user macros
$quoted = '{$USER_MACRO: "Logical operators - and or - should not be parsed"}';
$unquoted = '{$USER_MACRO: Logical operators - and or - should not be parsed}';
return [
// simple expressions
[
$quoted.'>0',
'E'
],
[
$unquoted.'>0',
'E'
],
[
$quoted.'>'.$unquoted,
'E'
],
// expressions with some simple logic
[
$quoted.'>0 and '.$unquoted.'>0',
'(E and E)'
],
[
$quoted.'>0 or '.$unquoted.'>0',
'(E or E)'