<?php

define('PHPUnit_MAIN_METHOD', 'Plugins_Fusioninventory_InventorySNMPModels::main');

if (!defined('GLPI_ROOT')) {
   define('GLPI_ROOT', '../../../..');

   require_once GLPI_ROOT."/inc/includes.php";
   $_SESSION['glpi_use_mode'] = 2;
   $_SESSION['glpiactiveprofile']['id'] = 4;

   ini_set('display_errors','On');
   error_reporting(E_ALL | E_STRICT);
   set_error_handler("userErrorHandler");

   // Backup present DB
   include_once("inc/backup.php");
   backupMySQL();

   $_SESSION["glpilanguage"] = 'fr_FR';

   // Install
   include_once("inc/installation.php");
   installGLPI();
   installFusionPlugins();

   loadLanguage();
   include_once(GLPI_ROOT."/locales/fr_FR.php");
   include_once(GLPI_ROOT."/plugins/fusinvsnmp/locales/fr_FR.php");
   $CFG_GLPI["root_doc"] = GLPI_ROOT;
}
include_once('emulatoragent.php');

/**
 * Test class for MyFile.
 * Generated by PHPUnit on 2010-08-06 at 12:05:09.
 */
class Plugins_Fusioninventory_InventorySNMPModels extends PHPUnit_Framework_TestCase {

    public static function main() {
        require_once 'PHPUnit/TextUI/TestRunner.php';

        $suite  = new PHPUnit_Framework_TestSuite('Plugins_Fusioninventory_InventorySNMPModels');
        $result = PHPUnit_TextUI_TestRunner::run($suite);

    }


   public function testModels() {
      global $DB;
      
      $pluginFusinvsnmpModel = new PluginFusinvsnmpModel();
      
      $xml = simplexml_load_file("../../../fusinvsnmp/tool/discovery.xml");

      foreach ($xml as $device) {
         if (isset($device->MODELSNMP) AND (string)$device->MODELSNMP != '') {
            $a_list = $pluginFusinvsnmpModel->find("`discovery_key`='".(string)$device->MODELSNMP."'");
            $this->assertEquals(count($a_list), '1', 'Discovery key not foudn 1 time ('.count($a_list).') :
                 '.(string)$device->MODELSNMP);
         }         
      }
   }

}

// Call Plugins_Fusioninventory_Discovery_Newdevices::main() if this source file is executed directly.
if (PHPUnit_MAIN_METHOD == 'Plugins_Fusioninventory_InventorySNMPModels::main') {
    Plugins_Fusioninventory_InventorySNMPModels::main();

}

?>
Add unit test for SNMP models
Add unit test for SNMP models
