public function testLoadFromString() { $xmlStr = '<?xml version="1.0" encoding="UTF-8"?><rootNode><node id="node1" param="attribute1"/><node id="node2" param="attribute2"/></rootNode>'; $xmldoc = new TXmlDocument(); self::assertTrue($xmldoc->loadFromString($xmlStr)); self::assertEquals('1.0', $xmldoc->getVersion()); self::assertEquals('UTF-8', $xmldoc->getEncoding()); }
public function setUp() { if (self::$app === null) { self::$app = new TApplication(dirname(__FILE__) . '/app'); prado::setPathofAlias('App', dirname(__FILE__)); } if (self::$mgr === null) { $config = new TXmlDocument('1.0', 'utf8'); $config->loadFromString('<users><user name="Joe" password="******"/><user name="John" password="******" /><role name="Administrator" users="John" /><role name="Writer" users="Joe,John" /></users>'); self::$mgr = new TUserManager(); self::$mgr->init($config); } }
public function setUp() { ini_set('session.use_cookies', 0); ini_set('session.cache_limiter', 'none'); if (self::$app === null) { self::$app = new TApplication(dirname(__FILE__) . '/app'); } // Make a fake user manager module if (self::$usrMgr === null) { self::$usrMgr = new TUserManager(); $config = new TXmlDocument('1.0', 'utf8'); $config->loadFromString('<users><user name="Joe" password="******"/><user name="John" password="******" /><role name="Administrator" users="John" /><role name="Writer" users="Joe,John" /></users>'); self::$usrMgr->init($config); self::$app->setModule('users', self::$usrMgr); } }
public function testRequestWithUrlMapping() { Prado::Using('System.Web.TUrlMapping'); $confstr = '<config><url ServiceId="testService" ServiceParameter="testServiceParam" pattern="test/{param}/?" parameters.param="\\w+"/></config>'; $config = new TXmlDocument('1.0', 'utf8'); $config->loadFromString($confstr); $module = new TUrlMapping(); self::$app->setModule('friendly-url', $module); if (isset($_GET['page'])) { unset($_GET['page']); } // Remove service from a previous test ! $_SERVER['REQUEST_URI'] = '/index.php/test/value2'; $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['PHP_SELF'] = '/index.php/test/value2'; $_SERVER['QUERY_STRING'] = ''; $_SERVER['PATH_INFO'] = '/test/value2'; $request = new THttpRequest(); $request->setUrlManager('friendly-url'); $request->setUrlFormat(THttpRequestUrlFormat::Path); $request->init(null); $module->init($config); self::assertEquals('testService', $request->resolveRequest(array('page', 'testService'))); }
/** * @param string $xml xml data of the tracking * @return string Return the database dump * @soapmethod */ public function syncTrackingTable($xml) { $doc = new TXmlDocument('1.0', 'utf-8'); $doc->loadFromString($xml); // mains tracking table $tableArray["hr_tracking"] = array(); $tableArray["hr_alarms"] = array(); $nreOfRecord = 0; $ids = ''; if ("trackingDump" == $doc->getTagName()) { if ($doc->getHasElement()) { if ($doc->getElements()->itemAt(0)->getHasElement()) { $tables = $doc->getElements()->itemAt(0)->getElements(); $tablesName = ""; foreach ($tables as $table) { if ($table->getHasElement()) { $tableName = $table->getTagName(); $records = $table->getElements()->itemAt(0)->getElements(); foreach ($records as $record) { if ($record->getHasElement()) { $fields = $record->getElements(); $recordArray = array(); foreach ($fields as $field) { $fieldName = $field->getTagName(); $fieldValue = $field->getValue(); $recordArray[$fieldName] = $fieldValue; } $tableArray[$tableName][] = $recordArray; } } } } $ids .= $this->syncAlarm($tableArray["hr_alarms"]); if ($ids != "") { $ids .= ","; } $ids .= $this->syncTracking($tableArray); return $ids; } else { return "0"; } } else { return "0"; } } else { return "0"; } }