The version and encoding will be determined based on the parsing result.
public loadFromString ( $string ) : boolean | ||
return | boolean | whether the XML string is parsed successfully |
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'))); }