public function __construct() { $debugOutput = false; $mongoDir = "/usr"; if (!file_exists($mongoDir . '/bin/mongod')) { throw new PHPUnit_Framework_SkippedTestError('mongo daemon not found'); } static $m; if (!isset($m)) { $port = Kwf_Util_Tcp::getFreePort(rand(27020, 30000)); $cmd = "php " . KWF_PATH . "/bootstrap.php test forward --controller=kwf_model_mongo_run-temp-mongo --port={$port}"; if ($debugOutput) { echo $cmd . "\n"; $descriptorspec = array(1 => STDOUT, 2 => STDOUT); } else { $cmd .= " 2>&1 >/dev/null"; $descriptorspec = array(1 => array('pipe', 'w'), 2 => STDOUT); } self::$_proc = new Kwf_Util_Proc($cmd, $descriptorspec); sleep(3); $m = new Mongo("mongodb://localhost:{$port}"); register_shutdown_function(array('Kwf_Model_Mongo_TestModel', 'shutDown')); } $db = $m->selectDB("modeltest"); $db->selectCollection($this->_collection)->drop(); $config = array('db' => $db); parent::__construct($config); }