planetteamspeak / ts3phpframework

Modern use-at-will framework that provides individual components to manage TeamSpeak 3 Server instances
https://www.planetteamspeak.com
GNU General Public License v3.0
212 stars 59 forks source link

Add ServerQuery Reply tests and improve exception message #205

Closed Sebbo94BY closed 1 year ago

Sebbo94BY commented 1 year ago

Improves the ServerQueryException message to be better able to identify the actual root cause.

Before:

PlanetTeamSpeak\TeamSpeak3Framework\Exception\ServerQueryException^ {#3929 // app/Http/Controllers/TeamSpeak.php:65
  #message: "invalid parameter"
  #code: 1538
  #file: "./vendor/planetteamspeak/ts3-php-framework/src/Adapter/ServerQuery/Reply.php"
  #line: 206
  #raw_code: 1538
  #raw_mesg: "invalid parameter"
  #return_code: null
  trace: {
    ./vendor/planetteamspeak/ts3-php-framework/src/Adapter/ServerQuery/Reply.php:206 { …}
    ./vendor/planetteamspeak/ts3-php-framework/src/Node/Server.php:633 { …}
    ./app/Http/Controllers/TeamSpeak.php:63 {
      App\Http\Controllers\TeamSpeak->get_current_client_list(): array^
      › try {
      ›     $client_list = $this->virtualserver->clientList(["client_type" => 0]);
      › } catch (ServerQueryException $ex) {
      arguments: {
        $filter: array:1 [ …1]
      }
    }
    [...]

After:

PlanetTeamSpeak\TeamSpeak3Framework\Exception\ServerQueryException^ {#3929 // app/Http/Controllers/TeamSpeak.php:65
  #message: "invalid parameter. ident 'clid' does not exist in node '{"put_muted":0,"client_output_muted":0,"client_input_hardware":1,"client_output_hardware":1,"client_talk_power":70,"client_is_talker":0,"client_is_priority_speaker":0,"client_is_recording":0,"client_is_channel_commander":0,"client_unique_identifier":"zBbdjIImKqM\/v18taBCdXhmoN4A=","client_servergroups":"137,146,147,261","client_channel_group_id":13,"client_channel_group_inherited_channel_id":108,"client_version":"3.5.6 [Build: 1606312422]","client_platform":"Linux","client_idle_time":117403360,"client_created":1684050729,"client_icon_id":0,"client_country":"DE",_icon_id":0,"client_country":"DE","connection_client_ip":"fe80::9400:ff:fe2b::1","client_badges":null}'"
  #code: 1538
  #file: "./vendor/planetteamspeak/ts3-php-framework/src/Adapter/ServerQuery/Reply.php"
  #line: 206
  #raw_code: 1538
  #raw_mesg: "invalid parameter. ident 'clid' does not exist in node '{"put_muted":0,"client_output_muted":0,"client_input_hardware":1,"client_output_hardware":1,"client_talk_power":70,"client_is_talker":0,"client_is_priority_speaker":0,"client_is_recording":0,"client_is_channel_commander":0,"client_unique_identifier":"zBbdjIImKqM\/v18taBCdXhmoN4A=","client_servergroups":"137,146,147,261","client_channel_group_id":13,"client_channel_group_inherited_channel_id":108,"client_version":"3.5.6 [Build: 1606312422]","client_platform":"Linux","client_idle_time":117403360,"client_created":1684050729,"client_lastconnected":1691241638,"client_icon_id":0,"client_country":"DE","connection_client_ip":"fe80::9400:ff:fe2b::1","client_badges":null}'"
  #return_code: null
  trace: {
    ./vendor/planetteamspeak/ts3-php-framework/src/Adapter/ServerQuery/Reply.php:206 { …}
    ./vendor/planetteamspeak/ts3-php-framework/src/Node/Server.php:633 { …}
    ./app/Http/Controllers/TeamSpeak.php:63 {
      App\Http\Controllers\TeamSpeak->get_current_client_list(): array^
      › try {
      ›     $client_list = $this->virtualserver->clientList(["client_type" => 0]);
      › } catch (ServerQueryException $ex) {
      arguments: {
        $filter: array:1 [ …1]
      }
    }
    [...]

Adds some further PHPUnit tests.