Issues (2963)

tests/SnmpsimHelpers.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * ChecksSnmpsim.php
4
 *
5
 * -Description-
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
 *
20
 * @link       https://www.librenms.org
21
 *
22
 * @copyright  2018 Tony Murray
23
 * @author     Tony Murray <[email protected]>
24
 */
25
26
namespace LibreNMS\Tests;
27
28
use LibreNMS\Util\Snmpsim;
29
30
trait SnmpsimHelpers
31
{
32
    /** @var Snmpsim snmpsim instance */
33
    protected $snmpsim = null;
34
35
    public function requireSnmpsim()
36
    {
37
        if (! getenv('SNMPSIM')) {
38
            $this->markTestSkipped('Snmpsim required for this test.  Set SNMPSIM=1 to enable.');
0 ignored issues
show
It seems like markTestSkipped() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
            $this->/** @scrutinizer ignore-call */ 
39
                   markTestSkipped('Snmpsim required for this test.  Set SNMPSIM=1 to enable.');
Loading history...
39
        }
40
    }
41
42
    public function getSnmpsim()
43
    {
44
        if (! $this->snmpsim) {
45
            global $snmpsim;
46
            $this->snmpsim = $snmpsim;
47
        }
48
49
        return $this->snmpsim;
50
    }
51
}
52