Esempio n. 1
0
 public function testOverrideDefaultClient()
 {
     $rtm = new Rtm();
     $rtm->setClient(new Mocks\EmptyClientMock());
     $this->assertTrue($rtm->getClient() instanceof Mocks\EmptyClientMock);
     $this->assertTrue($rtm->getClient() instanceof ClientInterface);
     $rtm = new Rtm(array('client' => new Mocks\EmptyClientMock()));
     $this->assertTrue($rtm->getClient() instanceof Mocks\EmptyClientMock);
     $this->assertTrue($rtm->getClient() instanceof ClientInterface);
 }
Esempio n. 2
0
 public function testPing()
 {
     $rtm = new Rtm();
     $rtm->setApiKey(self::API_KEY);
     $rtm->setSecret(self::SECRET);
     $rtm->setAuthToken(self::AUTH_TOKEN);
     $rtm->setClient(new ServiceTestClientMock());
     $response = $rtm->getService(Rtm::SERVICE_TEST)->ping();
     $this->assertEquals(Rtm::SERVICE_TEST, $response->__getService());
     $this->assertEquals(Rtm::METHOD_TEST_ECHO, $response->__getMethod());
     $this->assertEquals(array(), $response->__getParams());
 }
Esempio n. 3
0
 /**
  * @dataProvider getServiceMethodsMatrix
  */
 public function testServiceMethod($serviceName, $methodName, array $parameters, array $expectedParameters, $timeline = null)
 {
     $rtm = new Rtm();
     $rtm->setApiKey(self::API_KEY);
     $rtm->setSecret(self::SECRET);
     $rtm->setAuthToken(self::AUTH_TOKEN);
     $rtm->setFrob(self::FROB);
     $rtm->setClient(new ServiceTestClientMock());
     $service = $rtm->getService($serviceName);
     if (null !== $timeline) {
         $service->setTimeline($timeline);
     }
     $reflection = new \ReflectionObject($service);
     $method = $reflection->getMethod(preg_replace('/^[\\w\\.]+\\.(\\w+)$/', '\\1', $methodName));
     $response = $method->invokeArgs($service, $parameters);
     $this->assertEquals($serviceName, $response->__getService());
     $this->assertEquals($methodName, $response->__getMethod());
     $this->assertEquals($expectedParameters, $response->__getParams());
 }