예제 #1
1
파일: TAD.php 프로젝트: ahui/tad-php
 /**
  * Magic __call method overriding to define in runtime the methods should be called based on method invoked.
  * (Something like Ruby metaprogramming :-P). In this way, we decrease the number of methods required
  * (usually should be one method per SOAP or PHP_ZKLib command exposed).
  *
  * Note:
  *
  * Those methods that add, update o delete device information, call SOAP method <b><code>refresh_db()</code></b>
  * to properly update device database.
  *
  * @param string $command command to be invoked.
  * @param array $args commands args.
  * @return string device response in XML format.
  * @throws ConnectionError.
  * @throws UnrecognizedCommand.
  * @throws UnrecognizedArgument.
  */
 public function __call($command, array $args)
 {
     $command_args = count($args) === 0 ? [] : array_shift($args);
     $this->check_for_connection() && $this->check_for_valid_command($command) && $this->check_for_unrecognized_args($command_args);
     if (in_array($command, TADSoap::get_commands_available())) {
         $response = $this->execute_command_via_tad_soap($command, $command_args);
     } else {
         $response = $this->execute_command_via_zklib($command, $command_args);
     }
     $this->check_for_refresh_tad_db($command);
     return $response;
 }
예제 #2
0
 /**
  * @depends testBuildTADSoap
  */
 public function testBuildMultipleSoapRequest(TADSoap $tad_soap)
 {
     $args = array_fill_keys(TAD::get_valid_commands_args(), null);
     // We uses 'set_user_info' command defined in TADSoap class.
     // Maybe there is a better way to test this. :-P
     $soap_request = $tad_soap->build_soap_request('set_user_info', $args, 'iso8859-1');
     $this->assertInternalType('array', $soap_request);
 }