Exemple #1
0
 public function testCreateRequestWithRtm()
 {
     $rtm = new Rtm();
     $rtm->setApiKey('asjhdfskjdfs');
     $rtm->setSecret('1asdas534666');
     $rtm->setAuthToken('gfg77764g');
     $client = new Client();
     $client->setRtm($rtm);
     $request = $client->createRequest('test', array('param1' => 'foo', 'param2' => 'bar'));
     $this->assertInstanceOf('Rtm\\Request', $request);
     $this->assertEquals('test', $request->getParameter('method'));
     $this->assertEquals('json', $request->getParameter('format'));
     $this->assertEquals('foo', $request->getParameter('param1'));
     $this->assertEquals('bar', $request->getParameter('param2'));
     $this->assertEquals('asjhdfskjdfs', $request->getParameter('api_key'));
     $this->assertEquals('gfg77764g', $request->getParameter('auth_token'));
     $this->assertTrue($request->isSigned());
 }
Exemple #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());
 }
 /**
  * @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());
 }
Exemple #4
0
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * @author     Bartosz Maciaszek <*****@*****.**>
 * @copyright  2013 Bartosz Maciaszek.
 * @license    http://www.opensource.org/licenses/mit-license.php  MIT License
 */
require_once 'bootstrap.php';
use Rtm\Rtm;
$rtm = new Rtm();
$rtm->setApiKey(API_KEY);
$rtm->setSecret(SECRET);
$rtm->setAuthToken(isset($_SESSION['RTM_AUTH_TOKEN']) ? $_SESSION['RTM_AUTH_TOKEN'] : null);
try {
    // Check authentication token
    $rtm->getService(Rtm::SERVICE_AUTH)->checkToken();
} catch (Exception $e) {
    // No permissions, let's get them
    header('Location: rtm.php');
}
$lists = $rtm->getService(Rtm::SERVICE_LISTS)->getList();
if (isset($_GET['listId'])) {
    $tasks = $rtm->getService(Rtm::SERVICE_TASKS)->getList(null, $_GET['listId'])->getTaskseries();
}
$currentListId = isset($_GET['listId']) ? $_GET['listId'] : null;
Exemple #5
0
 public function testGetExistingService()
 {
     $rtm = new Rtm();
     $service = $rtm->getService(Rtm::SERVICE_TEST);
     $this->assertInstanceOf('Rtm\\Service\\AbstractService', $service);
     $this->assertInstanceOf('Rtm\\Service\\Test', $service);
 }
Exemple #6
0
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * @author     Bartosz Maciaszek <*****@*****.**>
 * @copyright  2013 Bartosz Maciaszek.
 * @license    http://www.opensource.org/licenses/mit-license.php  MIT License
 */
require_once 'bootstrap.php';
use Rtm\Rtm;
$rtm = new Rtm();
$rtm->setApiKey(API_KEY);
$rtm->setSecret(SECRET);
$rtm->setAuthToken(isset($_SESSION['RTM_AUTH_TOKEN']) ? $_SESSION['RTM_AUTH_TOKEN'] : null);
try {
    // Check authentication token
    $rtm->getService(Rtm::SERVICE_AUTH)->checkToken();
    // Successfully authenticated, redirect to app
    header('Location: index.php');
} catch (Exception $e) {
    // Authentication request is taking place?
    if (isset($_GET['frob'])) {
        try {
            // Set the frob parameter
            $rtm->setFrob($_GET['frob']);
            // Call the getToken method, to acquire the token