diff --git a/tests/functional/backend/RemoteControlTest.php b/tests/functional/backend/RemoteControlTest.php new file mode 100644 index 00000000000..80f8058206a --- /dev/null +++ b/tests/functional/backend/RemoteControlTest.php @@ -0,0 +1,62 @@ +urlManager; + self::$tmpBaseUrl = $urlMan->getBaseUrl(); + $urlMan->setBaseUrl('http://' . self::$domain . '/index.php'); + //$serverUrl = App()->createAbsoluteUrl('/admin/remotecontrol'); + $serverUrl = $urlMan->createUrl('/admin/remotecontrol'); + + self::$tmpRPCType = Yii::app()->getConfig('RPCInterface'); + + if (self::$tmpRPCType === 'off') { + \SettingGlobal::setSetting('RPCInterface', 'json'); + $RPCType = 'json'; + } else { + $RPCType = self::$tmpRPCType; + } + + if ($RPCType == 'xml') { + $cur_path = get_include_path(); + set_include_path($cur_path . PATH_SEPARATOR . APPPATH . 'helpers'); + require_once('Zend/XmlRpc/Client.php'); + + self::$client = new \Zend_XmlRpc_Client($serverUrl); + } elseif ($RPCType == 'json') { + Yii::app()->loadLibrary('jsonRPCClient'); + self::$client = new \jsonRPCClient($serverUrl); + } + } + + public static function tearDownAfterClass(): void + { + parent::tearDownAfterClass(); + + $urlMan = Yii::app()->urlManager; + $urlMan->setBaseUrl(self::$tmpBaseUrl); + + \SettingGlobal::setSetting('RPCInterface', self::$tmpRPCType); + } + + public function testGetSessionKey() + { + $sessionKey = self::$client->call('get_session_key', ['admin', 'password']); + $this->assertIsNotArray($sessionKey); + + self::$client->call('release_session_key', [$sessionKey]); + } +}