/**
  * @dataProvider providerTestExecute
  */
 public function testExecute($userId, $params, $session)
 {
     try {
         $method = $this->initRest(new DataSetUserPreference(), $params, $userId, $session['app_id']);
         $response = $method->execute();
         $this->assertTrue(empty($response), "Method response should have been empty.");
         // Validate it was really set?
         $preference = Api_Dao_AppPrefs::getAppPrefsByAppIdAndUserId($session['app_id'], $userId);
         $prefs = json_decode($preference[0]->value, true);
         $value = $prefs[$params['pref_id']];
         if ($params['value'] == '0' || $params['value'] == '') {
             $this->assertTrue(empty($value), "Preference ({$params['pref_id']}) should have been empty!");
         } else {
             $this->assertEquals($params['value'], $value);
         }
     } catch (OpenFBAPIException $exception) {
         $this->fail("Exception not expected!" . $exception->getMessage());
     }
 }
Ejemplo n.º 2
0
 public function testBadGetPreferences()
 {
     $prefs = Api_Dao_AppPrefs::getAppPrefsByAppIdAndUserId(0, 0);
     $this->assertEquals(0, count($prefs));
 }
Ejemplo n.º 3
0
 /**
  * Checks to see if the user has App Prefs tied to this App.
  *
  * @param int $appId
  * @param int $userId
  * @return unknown
  */
 public static function hasAppPrefs($appId, $userId)
 {
     if (!isset($appId) || !isset($userId)) {
         throw new Exception("Parameter Missing!", 0);
     }
     $appPrefs = Api_Dao_AppPrefs::getAppPrefsByAppIdAndUserId($appId, $userId);
     if (count($appPrefs) > 0) {
         return true;
     }
     return false;
 }