. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ /** * * @package gulliver.system * */ G::LoadSystem( 'ymlDomain' ); G::LoadSystem( 'ymlTestCases' ); G::LoadSystem( 'unitTest' ); class testTools { /** * importDB * * @param string $host * @param string $user * @param string $password * @param string $database * @param string $importFile * * @return none */ function importDB ($host, $user, $password, $database, $importFile) { exec( "mysql -h " . $host . " --user=" . $user . " --password=" . $password . " $database < $importFile" ); } /** * importLocalDB * * @param string $importFile * * @return none */ function importLocalDB ($importFile) { self::importDB( DB_HOST, DB_USER, DB_PASS, DB_NAME, $importFile ); } /** * callMethod * * @param string $methodFile * @param string $GET * @param string $POST * @param string $SESSION * * @return none */ function callMethod ($methodFile, $GET, $POST, $SESSION) { //TODO $_SERVER self::arrayDelete( $_GET ); self::arrayDelete( $_POST ); self::arrayDelete( $_SESSION ); self::arrayAppend( $_GET, $GET ); self::arrayAppend( $_POST, $POST ); self::arrayAppend( $_SESSION, $SESSION ); include (PATH_CORE . 'methods/' . $methodFile); } /** * arrayAppend * * @param string &$to * @param string $appendFrom * * @return boolean true */ function arrayAppend (&$to, $appendFrom) { foreach ($appendFrom as $appendItem) { $to[] = $appendItem; } return true; } /** * arrayDelete * * @param array &$array * * @return boolean true */ function arrayDelete (&$array) { foreach ($array as $key => $value) { unset( $array[$key] ); } return true; } /** * replaceVariables * * @param string $Fields * @param array $ExternalVariables * * @return array $Fields */ //@@ function replaceVariables ($Fields, $ExternalVariables = array()) { //TODO: Verify dependencies between fields foreach ($Fields as $key => $field) { if (is_string( $field )) { $mergedValues = G::array_merges( $Fields, $ExternalVariables ); $Fields[$key] = G::ReplaceDataField( $field, $mergedValues ); } } return $Fields; } // EXTRA TOOLS /** * findValue * * @param string $value * @param object &$obj * * @return (boolean | string) ((true | false) | $value) */ function findValue ($value, &$obj) { if (is_array( $obj )) { foreach ($obj as $key => $val) { if ($res = self::findValue( $value, $obj[$key] )) { if ($res == true) { return $key; } else { return $key . '.' . $res; } } } return false; } elseif (is_object( $obj )) { foreach ($obj as $key => $val) { if ($res = self::findValue( $value, $obj->$key )) { if ($res == true) { return $key; } else { return $key . '.' . $res; } } } return false; } else { return $obj == $value; } } } /* Some extra global functions */ /** * domain * * @param string $location * * @return object $result */ function domain ($location) { global $testDomain; $result = $testDomain->get( $location ); if (count( $result ) == 0) { trigger_error( "'$location' is an empty domain.", E_USER_WARNING ); } return $result; }