예제 #1
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 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());
     }
 }
예제 #2
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);
     }
 }