Example #1
0
    public function testAllMethod()
    {
        $dump = <<<EOF
Stats: state = 0
Stats: state = 1
Stats: state != 2
Stats: sum execution_time
Stats: min execution_time
Stats: max execution_time
Stats: avg execution_time
Stats: std execution_time
Stats: suminv execution_time
Stats: avginv execution_time
StatsAnd: 1
StatsOr: 2
StatsNegate:

EOF;
        $mock = new Stats();
        $mock->set('state = 0')->equal('state', '1')->notEqual('state', '2')->sum('execution_time')->min('execution_time')->max('execution_time')->avg('execution_time')->std('execution_time')->suminv('execution_time')->avginv('execution_time')->operatorAnd(1)->operatorOr(2)->negate();
        $this->assertEquals($dump, join('', $mock->get()));
    }
Example #2
0
    public function testReadme16()
    {
        $lql = <<<EOF
GET services
Filter: host_groups >= windows
Filter: scheduled_downtime_depth = 0
Filter: host_scheduled_downtime_depth = 0
Filter: in_notification_period = 1
Stats: last_hard_state = 0
Stats: last_hard_state = 1
Stats: acknowledged = 0
StatsAnd: 2
Stats: last_hard_state = 1
Stats: acknowledged = 1
StatsAnd: 2
Stats: last_hard_state = 2
Stats: acknowledged = 0
StatsAnd: 2
Stats: last_hard_state = 2
Stats: acknowledged = 1
StatsAnd: 2
Stats: last_hard_state = 3
Stats: acknowledged = 0
StatsAnd: 2
Stats: last_hard_state = 3
Stats: acknowledged = 1
StatsAnd: 2
OutputFormat: json
ResponseHeader: fixed16


EOF;
        $stats = new Stats();
        $stats->equal('last_hard_state', '0')->equal('last_hard_state', '1')->equal('acknowledged', '0')->operatorAnd(2)->equal('last_hard_state', '1')->equal('acknowledged', '1')->operatorAnd(2)->equal('last_hard_state', '2')->equal('acknowledged', '0')->operatorAnd(2)->equal('last_hard_state', '2')->equal('acknowledged', '1')->operatorAnd(2)->equal('last_hard_state', '3')->equal('acknowledged', '0')->operatorAnd(2)->equal('last_hard_state', '3')->equal('acknowledged', '1')->operatorAnd(2);
        $filter = new Filter();
        $filter->greaterEqual('host_groups', 'windows')->equal('scheduled_downtime_depth', '0')->equal('host_scheduled_downtime_depth', '0')->equal('in_notification_period', '1');
        $mock = \TestMock::on(new Lql(Table::SERVICES));
        $mock->filter($filter)->stats($stats);
        $this->assertEquals($lql, $mock->build(), 'Combining with and/or.');
    }