Esempio n. 1
0
 /**
  * Реализует взаимодействие с внешним сервисом
  *
  * @param string $method Вызываемый метод
  * @param array  $args   Аргументы вызываемого метода
  *
  * @return Response
  * @throws InvalidParameterException
  */
 protected function implementation($method, array $args = array())
 {
     try {
         $raw = call_user_func_array(array($this->client, $method), $args);
         $raw = $this->map($method, $raw);
         return Response::success($raw);
     } catch (SoapFault $fault) {
         return Response::failure(null, $fault->getMessage(), $fault->faultcode);
     }
 }
Esempio n. 2
0
 public function testWhenDataInCacheThenReturnIt()
 {
     $service = $this->getMockService();
     $responseCached = Response::success('from cache');
     $method = 'foo';
     $args = array('bar', 'baz');
     $key = md5(serialize(array($method, $args)));
     $service->getCacher()->getItem($key)->set($responseCached, 60);
     /** @noinspection PhpUndefinedMethodInspection */
     $service->method('implementation')->will(self::returnValue($responseCached));
     $service->configure();
     /** @noinspection ImplicitMagicMethodCallInspection */
     $responseCalled = $service->__call($method, $args);
     self::assertEquals($responseCached, $responseCalled);
 }
Esempio n. 3
0
 /**
  * Реализует конкретное взаимодействие с внешним источником
  *
  * @param string $method Вызываемый метод
  * @param array  $args   Аргументы вызываемого метода
  *
  * @return Response
  */
 protected function implementation($method, array $args = array())
 {
     $this->logger->info(var_export($args, true));
     array_unshift($args, $this->client);
     try {
         $raw = call_user_func_array(sprintf('ldap_%s', $method), $args);
         return Response::success($raw);
     } catch (\Exception $e) {
         return Response::failure(null, $e->getMessage());
     }
 }