public function testExecute()
 {
     $appId = 1;
     $app_id = 1;
     $uid = 18032;
     $iid = "Test Item FBML";
     $alid = 2;
     $fbml = "Some fbml to test with!";
     $lid = null;
     $uids = null;
     $apiParams = array();
     $apiParams['iid'] = $iid;
     $apiParams['fbml'] = $fbml;
     $apiParams['alid'] = $alid;
     try {
         // Set the FBML
         $faf = $this->initRest(new FavoritesSetFBML(), $apiParams, $uid, $appId);
         $this->assertNotNull($faf, "FavoritesSet should not be null!");
         Api_Dao_Items::createItem($app_id, $iid, "", "", 0);
         CoreApiUtil::createFavorite($app_id, $uid, $iid, $alid, $lid);
         $result = $faf->execute();
         $this->assertEquals($result['result'], '1');
         $faf = $this->initRest(new FavoritesGetFBML(), $apiParams, $uid, $appId);
         $this->assertNotNull($faf, "FavoritesGetFBML should not be null!");
         $retVal = $faf->execute();
         $a = $retVal['favorite'][1];
         $this->assertEquals($fbml, $a['fbml']);
         // Now test passin in the UID
         $uids = "18032";
         $apiParams['uids'] = $uids;
         $faf = $this->initRest(new FavoritesGetFBML(), $apiParams, $uid, $appId);
         $this->assertNotNull($faf, "FavoritesGetFBML should not be null!");
         $retVal = $faf->execute();
         $a = $retVal['favorite'][1];
         $this->assertEquals($a['fbml'], $fbml);
     } catch (OpenFBAPIException $exception) {
         $this->fail($exception->getMessage() . "\n" . $exception->getTraceAsString());
     }
 }
 public function testExecute()
 {
     $appId = 10;
     $app_id = 10;
     $uid = 18066;
     $iid = "TestGetUsers1";
     $lid = null;
     $alid = 32;
     $uids = "18066";
     try {
         $apiParams = array();
         $apiParams['iid'] = $iid;
         $apiParams['uids'] = $uids;
         $apiParams['alid'] = $alid;
         $faf = $this->initRest(new FavoritesGetUsers(), $apiParams, $uid, $appId);
         $this->assertNotNull($faf, "FavoritesGetUsers should not be null!");
         Api_Dao_Items::createItem($app_id, $iid, "", "", 0);
         CoreApiUtil::createFavorite($app_id, $uid, $iid, $alid, $lid);
         $retVal = $faf->execute();
         $a = $retVal['user'][0];
         $this->assertEquals($uid, $a);
     } catch (OpenFBAPIException $exception) {
         $this->fail($exception->getMessage() . "\n" . $exception->getTraceAsString());
     }
 }
示例#3
0
 public function testExecute()
 {
     $appId = 1;
     $app_id = 1;
     $name = "Test User List";
     $uid = 18015;
     $iid = "Test Item Delete";
     $alid = 2;
     $lid = null;
     $apiParams = array();
     $apiParams['iid'] = $iid;
     $apiParams['alid'] = $alid;
     try {
         // Test alid
         $faf = $this->initRest(new FavoritesGet(), $apiParams, $uid, $appId);
         $this->assertNotNull($faf, "FavoritesGet should not be null!");
         Api_Dao_Items::createItem($app_id, $iid, "", "", 0);
         CoreApiUtil::createFavorite($app_id, $uid, $iid, $alid, $lid);
         $result = $faf->execute();
         $ret = $result['favorite'][0];
         $this->assertEquals($alid, $ret['alid']);
         $this->assertEquals($iid, $ret['iid']);
         // Now test lid
         $alid = null;
         $lid = 1001;
         $apiParams = array();
         $apiParams['iid'] = $iid;
         $lid = CoreApiUtil::createList($name, $app_id, $uid);
         $apiParams['lid'] = $lid;
         $cfRet = CoreApiUtil::createFavorite($app_id, $uid, $iid, null, $lid);
         $faf = $this->initRest(new FavoritesGet(), $apiParams, $uid, $appId);
         $this->assertNotNull($faf, "FavoritesDelete should not be null!");
         $result = $faf->execute();
         $ret = $result['favorite'][0];
         $this->assertEquals($lid, $ret['lid']);
         $this->assertEquals($iid, $ret['iid']);
     } catch (OpenFBAPIException $exception) {
         $this->fail($exception->getMessage() . "\n" . $exception->getTraceAsString());
     }
 }
 public function testExecute()
 {
     $appId = 1;
     $app_id = 1;
     $name = "Test User List";
     $uid = 18015;
     $iid = "Test Item Delete";
     $alid = 2;
     $lid = null;
     $uids = array("18015");
     $apiParams = array();
     $apiParams['iid'] = $iid;
     $apiParams['alid'] = $alid;
     try {
         // Test alid
         $faf = $this->initRest(new FavoritesDelete(), $apiParams, $uid, $appId);
         $this->assertNotNull($faf, "FavoritesDelete should not be null!");
         $this->assertTrue(Api_Dao_Items::createItem($app_id, $iid, "", "", 0) !== false);
         $this->assertTrue(CoreApiUtil::createFavorite($app_id, $uid, $iid, $alid, $lid) !== false);
         $this->assertTrue(CoreApiUtil::isFavorite($app_id, $iid, $alid, $lid, $uids), "Favorite should exist!");
         $result = $faf->execute();
         $this->assertEquals($result['result'], '1');
         $this->assertFalse(CoreApiUtil::isFavorite($app_id, $iid, $alid, $lid, $uids), "Favorite should no longer exist!");
         try {
             $alid = null;
             $lid = 1001;
             CoreApiUtil::createFavorite($app_id, $uid, $iid, $alid, $lid);
             $this->fail("Create should not work if the user list does not exist!");
         } catch (Exception $e) {
             // ignore
         }
         // Now test lid
         $apiParams = array();
         $apiParams['iid'] = $iid;
         $lid = CoreApiUtil::createList($name, $app_id, $uid);
         $apiParams['lid'] = $lid;
         CoreApiUtil::createFavorite($app_id, $uid, $iid, $alid, $lid);
         $faf = $this->initRest(new FavoritesDelete(), $apiParams, $uid, $appId);
         $this->assertNotNull($faf, "FavoritesDelete should not be null!");
         $this->assertTrue(CoreApiUtil::isFavorite($app_id, $iid, $alid, $lid, $uids), "Favorite should exist!");
         $result = $faf->execute();
         $this->assertEquals($result['result'], '1');
         $this->assertFalse(CoreApiUtil::isFavorite($app_id, $iid, $alid, $lid, $uids), "Favorite should no longer exist!");
     } catch (OpenFBAPIException $exception) {
         $this->fail($exception->getMessage() . "\n" . $exception->getTraceAsString());
     }
 }
示例#5
0
 public function testExecute()
 {
     $appId = 1;
     $app_id = 1;
     $name = "Test User List";
     $uid = 18015;
     $iid = "Test Item Delete";
     $alid = 2;
     $lid = null;
     $uids = array("18015");
     $apiParams = array();
     $apiParams['iid'] = $iid;
     $apiParams['alid'] = $alid;
     try {
         // Test alid
         $faf = $this->initRest(new FavoritesSet(), $apiParams, $uid, $appId);
         $this->assertNotNull($faf, "FavoritesSet should not be null!");
         Api_Dao_Items::createItem($appId, $iid, '', '', '0');
         $result = $faf->execute();
         $this->assertEquals($result['result'], '1');
         $this->assertTrue(CoreApiUtil::isFavorite($app_id, $iid, $alid, $lid, $uids), "Favorite should exist!");
         // Now test lid
         $alid = null;
         $apiParams = array();
         $apiParams['iid'] = $iid;
         $lid = CoreApiUtil::createList($name, $app_id, $uid);
         $apiParams['lid'] = $lid;
         $faf = $this->initRest(new FavoritesSet(), $apiParams, $uid, $appId);
         $this->assertNotNull($faf, "FavoritesSet should not be null!");
         $result = $faf->execute();
         $this->assertEquals($result['result'], '1');
         $this->assertTrue(CoreApiUtil::isFavorite($app_id, $iid, $alid, $lid, $uids), "Favorite should exist!");
     } catch (OpenFBAPIException $exception) {
         $this->fail($exception->getMessage() . "\n" . $exception);
     }
 }