null,'Name'=>''); public static function find_one(\$p=array(),\$o=array()) { return null; } public static function find(\$p=array(),\$o=array()) { return array(); } }"); } if (!defined('ZM_PATH_SOCKS')) define('ZM_PATH_SOCKS', $tmp.'/socks'); if (!defined('ZM_PATH_BIN')) define('ZM_PATH_BIN', $tmp.'/bin'); // ZM_SERVER_ID left undefined so the method treats this as the local server. if (!function_exists('jsonEncode')) { function jsonEncode($value) { return json_encode($value); } } set_include_path($tmp.'/stub'.PATH_SEPARATOR.$root.'/web/includes'.PATH_SEPARATOR.get_include_path()); require_once($root.'/web/includes/Object.php'); require_once($monitorFile); // Case 1: stub exits 1, no socket -> command not delivered. file_put_contents($tmp.'/bin/zmcontrol.pl', "#!/bin/sh\nexit 1\n"); chmod($tmp.'/bin/zmcontrol.pl', 0755); $m = new ZM\Monitor(array('Id' => 1)); check('stub exits 1 -> sendControlCommand returns false', $m->sendControlCommand('--command=moveConUp'), false); // Case 2: stub exits 0 -> delivered. file_put_contents($tmp.'/bin/zmcontrol.pl', "#!/bin/sh\nexit 0\n"); chmod($tmp.'/bin/zmcontrol.pl', 0755); $m2 = new ZM\Monitor(array('Id' => 2)); check('stub exits 0 -> sendControlCommand returns true', $m2->sendControlCommand('--command=moveConUp'), true); @unlink($tmp.'/bin/zmcontrol.pl'); foreach (array('database.php','log_redact.php','Control.php','Group.php','Manufacturer.php','Model.php','Server.php','Storage.php','Zone.php') as $f) @unlink($tmp.'/stub/'.$f); @rmdir($tmp.'/stub'); @rmdir($tmp.'/socks'); @rmdir($tmp.'/bin'); @rmdir($tmp); echo "\n$passes passed, $failures failed\n"; exit($failures ? 1 : 0);