/**
  * @dataProvider providerParser
  */
 public function testParser($string, $result)
 {
     global $config;
     // Add in custom interface groups for testing
     $config['int_groups'] = array('TestGroup1', 'TestGroup2');
     $this->assertSame($result, custom_port_parser(array('ifAlias' => $string)));
 }
Пример #2
0
         $log_event[] = $msg;
         if ($debug) {
             echo $msg . " ";
         } else {
             echo $oid . " ";
         }
     }
 }
 if ((bool) $log_event) {
     log_event('Interface changed: ' . implode('; ', $log_event), $device, 'port', $port);
 }
 // Parse description (usually ifAlias) if config option set
 if ($custom_port_parser) {
     $log_event = array();
     if ($custom_port_parser !== 'old') {
         $port_ifAlias = custom_port_parser($this_port);
     } else {
         $port_attribs = array('type', 'descr', 'circuit', 'speed', 'notes');
         include $config['install_dir'] . "/" . $config['port_descr_parser'];
     }
     foreach ($port_attribs as $attrib) {
         $attrib_key = "port_descr_" . $attrib;
         if ($port_ifAlias[$attrib] != $port[$attrib_key]) {
             if (isset($port_ifAlias[$attrib])) {
                 $port['update'][$attrib_key] = $port_ifAlias[$attrib];
                 $msg = "[{$attrib}] " . $port[$attrib_key] . " -> " . $port_ifAlias[$attrib];
             } else {
                 $port['update'][$attrib_key] = array('NULL');
                 $msg = "[{$attrib}] " . $port[$attrib_key] . " -> NULL";
             }
             $log_event[] = $msg;