Example #1
0
 public function initPhotoTags()
 {
     $dbCon = RsOpenFBDbTestUtils::getDbCon();
     $user1 = RsOpenFBDbTestUtils::getUser1();
     $user2 = RsOpenFBDbTestUtils::getUser2();
     $photoTag1 = RsOpenFBDbTestUtils::getPhotoTag1();
     $photoTag2 = RsOpenFBDbTestUtils::getPhotoTag2();
     $photoTag3 = RsOpenFBDbTestUtils::getPhotoTag3();
 }
 public function testExecute()
 {
     $photo1 = RsOpenFBDbTestUtils::getPhoto1();
     $photo2 = RsOpenFBDbTestUtils::getPhoto2();
     $uid = 10001;
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['pids'] = 10001;
     $faf = $this->initRest(new PhotosGetTags(), $apiParams, $uid);
     $result = $faf->execute();
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['pids'] = $photo1->pid;
     $faf = $this->initRest(new PhotosGetTags(), $apiParams, $uid);
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO_TAG];
     $this->assertEquals(2, count($fi));
     $row = $fi[0];
     $this->assertPhotoTag($row, $photo1->pid, "10001", 1.1, 1.2, 11);
     $row = $fi[1];
     $this->assertPhotoTag($row, $photo1->pid, "10002", 2.1, 2.2, 22);
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['pids'] = $photo2->pid;
     $faf = $this->initRest(new PhotosGetTags(), $apiParams, $uid);
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO_TAG];
     $this->assertEquals(1, count($fi));
     $row = $fi[0];
     $this->assertPhotoTag($row, $photo2->pid, "10001", 3.1, 3.2, 33);
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['pids'] = $photo1->pid . ", " . $photo2->pid;
     $faf = $this->initRest(new PhotosGetTags(), $apiParams, $uid);
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO_TAG];
     $this->assertEquals(3, count($fi));
     $row = $fi[0];
     $this->assertPhotoTag($row, $photo1->pid, "10001", 1.1, 1.2, 11);
     $row = $fi[1];
     $this->assertPhotoTag($row, $photo1->pid, "10002", 2.1, 2.2, 22);
     $row = $fi[2];
     $this->assertPhotoTag($row, $photo2->pid, "10001", 3.1, 3.2, 33);
 }
Example #3
0
 public function testinsertIntoDbdeleteFromDb()
 {
     $dbCon = RsOpenFBDbTestUtils::getDbCon();
     $user = RsOpenFBDbTestUtils::getUser1();
     $app = RsOpenFBDbTestUtils::getApp1();
     try {
         $user->insertIntoDb($dbCon);
     } catch (Exception $exception) {
         // nothing on purpose
     }
     $appId = $app;
     $userId = $user->getId();
     $id = null;
     try {
         $this->assertEquals(0, $this->getNumUserApp($appId, $userId));
         $id = Api_Dao_UsersApp::createUsersApp($appId, $userId);
         $this->assertEquals(1, $this->getNumUserApp($appId, $userId));
         $row = $this->getUserApp($appId, $userId);
         $this->assertEquals($id, $row['id']);
     } catch (Exception $exception) {
         try {
             Api_Dao_UsersApp::deleteUserApp($id);
         } catch (Exception $exception) {
             // nothing on purpose
         }
         $this->deleteUserAndApp($id, $app);
         throw $exception;
     }
     try {
         Api_Dao_UsersApp::deleteUserApp($id);
         $this->assertEquals(0, $this->getNumUserApp($appId, $userId));
     } catch (Exception $exception) {
         $this->deleteUserAndApp($id, $app);
         throw $exception;
     }
     $this->deleteUserAndApp($id, $app);
 }
Example #4
0
 public static function getPhotoTag3()
 {
     static $photoTag;
     if (!isset($photoTag)) {
         $user1 = RsOpenFBDbTestUtils::getUser1();
         $photo2 = RsOpenFBDbTestUtils::getPhoto2();
         $photoTag = RsOpenFBDbTestUtils::getOnePhotoTag($photo2->pid, $user1->getId(), "t3", 3.1, 3.2);
     }
     return $photoTag;
 }
Example #5
0
 public function testExecute()
 {
     $photo1 = RsOpenFBDbTestUtils::getPhoto1();
     $photo2 = RsOpenFBDbTestUtils::getPhoto2();
     $photo3 = RsOpenFBDbTestUtils::getPhoto3();
     $user1 = RsOpenFBDbTestUtils::getUser1();
     $album1 = RsOpenFBDbTestUtils::getAlbum1();
     $album2 = RsOpenFBDbTestUtils::getAlbum2();
     // test by subj_id by itself
     $uid = 10001;
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['subj_id'] = $user1->getId();
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 2 photos
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(2, count($fi));
     $row = $fi[0];
     $this->assertPhoto1Photo2($row, $photo1, $photo2);
     $row = $fi[1];
     $this->assertPhoto1Photo2($row, $photo1, $photo2);
     // test pids all by itself
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['pids'] = $photo1->pid;
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 1 photo
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(1, count($fi));
     $row = $fi[0];
     $this->assertPhoto($row, $photo1);
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['pids'] = $photo2->pid;
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 1 photo
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(1, count($fi));
     $row = $fi[0];
     $this->assertPhoto($row, $photo2);
     // test aid all by itself
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['aid'] = $album1;
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 2 photos
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(2, count($fi));
     $row = $fi[0];
     $this->assertPhoto1Photo2($row, $photo1, $photo2);
     $row = $fi[1];
     $this->assertPhoto1Photo2($row, $photo1, $photo2);
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['aid'] = $album2;
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 1 photo
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(1, count($fi));
     $row = $fi[0];
     $this->assertPhoto($row, $photo3);
     // test subject id and pids
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['subj_id'] = $user1->getId();
     $apiParams['pids'] = $photo1->pid . ", " . $photo2->pid;
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 2 photos
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(2, count($fi));
     $row = $fi[0];
     $this->assertPhoto1Photo2($row, $photo1, $photo2);
     $row = $fi[1];
     $this->assertPhoto1Photo2($row, $photo1, $photo2);
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['subj_id'] = $user1->getId();
     $apiParams['pids'] = $photo1->pid;
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 1 photos
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(1, count($fi));
     $row = $fi[0];
     $this->assertPhoto($row, $photo1);
     // test aid and pids
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['aid'] = $album1;
     $apiParams['pids'] = $photo1->pid . ", " . $photo2->pid;
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 2 photos
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(2, count($fi));
     $row = $fi[0];
     $this->assertPhoto1Photo2($row, $photo1, $photo2);
     $row = $fi[1];
     $this->assertPhoto1Photo2($row, $photo1, $photo2);
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['aid'] = $album2;
     $apiParams['pids'] = $photo3->pid;
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 1 photo
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(1, count($fi));
     $row = $fi[0];
     $this->assertPhoto($row, $photo3);
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['aid'] = $album1;
     $apiParams['pids'] = $photo3->pid;
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 2 photos
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(0, count($fi));
     //test subject id, aid, and pids
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['subj_id'] = $user1->getId();
     $apiParams['aid'] = $album1;
     $apiParams['pids'] = $photo1->pid . ", " . $photo2->pid;
     $faf = $this->initRest(new PhotosGet(), $apiParams, $uid);
     // should get back 2 photos
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_PHOTO];
     $this->assertEquals(2, count($fi));
     $row = $fi[0];
     $this->assertPhoto1Photo2($row, $photo1, $photo2);
     $row = $fi[1];
     $this->assertPhoto1Photo2($row, $photo1, $photo2);
 }
Example #6
0
 public function testautoincrementIntoDb()
 {
     $dbCon = RsOpenFBDbTestUtils::getDbCon();
     $password = "******";
     $username = "******";
     $user = new Api_Dao_User();
     $user->setUsername($username);
     $user->setPassword($password);
     try {
         $numRows = $this->getNumAllUsers($dbCon);
         $this->assertNull($user->getId());
         $user->insertIntoDb($dbCon);
         $this->assertEquals($numRows + 1, $this->getNumAllUsers($dbCon));
         $this->assertNotNull($user->getId());
         $row = $this->getUser($dbCon, $user->getId());
         $this->assertEquals($user->getId(), $row[id]);
         $this->assertEquals($password, $row['password']);
         $this->assertEquals($username, $row['username']);
     } catch (Exception $exception) {
         $user->deleteFromDb($dbCon);
         throw $exception;
     }
     $user->deleteFromDb($dbCon);
     $this->assertEquals($numRows, $this->getNumAllUsers($dbCon));
 }
Example #7
0
 /**
  * @dataProvider providerIsAdmin
  */
 public function testIsAdmin($pageId, $uid, $expected)
 {
     $actual = Api_Dao_Pages::isAdmin($pageId, $uid, RsOpenFBDbTestUtils::getDbCon());
     $this->assertEquals($expected, $actual);
 }
 public function testExecute()
 {
     $albumId_1 = RsOpenFBDbTestUtils::getAlbum1();
     $albumId_2 = RsOpenFBDbTestUtils::getAlbum2();
     $uid = 10001;
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['uid'] = 10001;
     $faf = $this->initRest(new PhotosGetAlbums(), $apiParams, $uid);
     $result = $faf->execute();
     /* just aids
     		$apiParams = array();
     		$apiParams['api_key'] = "32";
     		$apiParams['aids'] = $albumId_1 . ", " . $albumId_2;
     		$faf = $this->initRest(new PhotosGetAlbums(), $apiParams, $uid);
     		$result = $faf->execute();
     		*/
     $fi = $result[FB_PHOTOS_ALBUM];
     $this->assertEquals(2, count($fi));
     $row = $fi[0];
     $this->assertAlbum($row, $row[FB_PHOTOS_AID], "10001", "pa 1", "desc 1", "loc 1", 2);
     $row = $fi[1];
     $this->assertAlbum($row, $row[FB_PHOTOS_AID], "10001", "pa 2", "desc 2", "loc 2", 1);
     // just uid
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['uid'] = 10001;
     $faf = $this->initRest(new PhotosGetAlbums(), $apiParams, $uid);
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_ALBUM];
     $this->assertEquals(2, count($fi));
     $row = $fi[0];
     $this->assertAlbum($row, $row[FB_PHOTOS_AID], "10001", "pa 1", "desc 1", "loc 1", 2);
     $row = $fi[1];
     $this->assertAlbum($row, $row[FB_PHOTOS_AID], "10001", "pa 2", "desc 2", "loc 2", 1);
     // both aids and uid
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['uid'] = 10001;
     $apiParams['aids'] = $albumId_1 . ", " . $albumId_2;
     $faf = $this->initRest(new PhotosGetAlbums(), $apiParams, $uid);
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_ALBUM];
     $this->assertEquals(2, count($fi));
     $row = $fi[0];
     $this->assertAlbum($row, $row[FB_PHOTOS_AID], "10001", "pa 1", "desc 1", "loc 1", 2);
     $row = $fi[1];
     $this->assertAlbum($row, $row[FB_PHOTOS_AID], "10001", "pa 2", "desc 2", "loc 2", 1);
     // both aids and uid
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['uid'] = 10001;
     $apiParams['aids'] = $albumId_1;
     $faf = $this->initRest(new PhotosGetAlbums(), $apiParams, $uid);
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_ALBUM];
     $this->assertEquals(1, count($fi));
     $row = $fi[0];
     $this->assertAlbum($row, $row[FB_PHOTOS_AID], "10001", "pa 1", "desc 1", "loc 1", 2);
     // both aids and uid
     $apiParams = array();
     $apiParams['api_key'] = "32";
     $apiParams['uid'] = 9999;
     $apiParams['aids'] = $albumId_1;
     $faf = $this->initRest(new PhotosGetAlbums(), $apiParams, $uid);
     $result = $faf->execute();
     $fi = $result[FB_PHOTOS_ALBUM];
     $this->assertEquals(0, count($fi));
 }
Example #9
0
 public function testautoincrementIntoDb()
 {
     $dbCon = RsOpenFBDbTestUtils::getDbCon();
     $apiKey = "apiKe";
     $callbackUrl = "dbUrl";
     $canvasUrl = "canUrl";
     $default = 1;
     $name = "name";
     $secretKey = "secKey";
     $sidenavUrl = "sideUrl";
     try {
         $numRows = $this->getNumAllApps($dbCon);
         $id = Api_Dao_App::createApp($apiKey, $callbackUrl, $canvasUrl, $name, $default, $secretKey, $sidenavUrl, null, null);
         $this->assertEquals($numRows + 1, $this->getNumAllApps($dbCon));
         $row = $this->getApp($dbCon, $id);
         $this->assertEquals($callbackUrl, $row['callback_url']);
         $this->assertEquals($canvasUrl, $row['canvas_url']);
         $this->assertEquals($default, $row['isdefault']);
         $this->assertEquals($id, $row['id']);
         $this->assertEquals($name, $row['name']);
         $this->assertEquals($sidenavUrl, $row['sidenav_url']);
     } catch (Exception $exception) {
         Api_Dao_App::deleteApp($id);
         throw $exception;
     }
     Api_Dao_App::deleteApp($id);
     $this->assertEquals($numRows, $this->getNumAllApps($dbCon));
 }
Example #10
0
 public function testExecute()
 {
     $photo = RsOpenFBDbTestUtils::getPhoto3();
     $uid = 10001;
     $pid = $photo->pid;
     $tags = '{"x":"30.0","y":"40.0","tag_uid":"1234567890"}, {"x":"70.0","y":"80.0","tag_text":"some person"}';
     $apiParams = array();
     $apiParams['pid'] = $pid;
     $apiParams['api_key'] = "21";
     $apiParams['tags'] = $tags;
     $faf = $this->initRest(new PhotosAddTag(), $apiParams, $uid);
     $res = $this->getNumPhotoTags($pid);
     $this->assertEquals(0, $res);
     try {
         $faf->execute();
         $res = $this->getNumPhotoTags($pid);
         $this->assertEquals(2, $res, 'The two objects are not equal!');
         $res = $this->getPhotoTags($pid);
         foreach ($res as $row) {
             if (strcmp("", $row['subject_id']) == 0) {
                 $this->assertNull($row['subject_id']);
                 $this->assertEquals('some person', $row['text'], "Expecting some person, but got: " . $row['text']);
                 $this->assertEquals(70.0, $row['xcoord']);
                 $this->assertEquals(80.0, $row['ycoord']);
             } else {
                 $this->assertEquals(1234567890, $row['subject_id']);
                 $this->assertNull($row['text']);
                 $this->assertEquals(30.0, $row['xcoord']);
                 $this->assertEquals(40.0, $row['ycoord']);
             }
         }
     } catch (Exception $exc) {
         try {
             $this->deletePhotoTags($pid);
         } catch (Exception $e2) {
         }
         throw $exc;
     }
     $this->deletePhotoTags($pid);
     $apiParams = array();
     $apiParams['pid'] = $pid;
     $apiParams['api_key'] = "21";
     $apiParams['tag_uid'] = 1234567890;
     $apiParams['x'] = 30.0;
     $apiParams['y'] = 40.0;
     $faf = $this->initRest(new PhotosAddTag(), $apiParams, $uid);
     $res = $this->getNumPhotoTags($pid);
     $this->assertEquals(0, $res);
     try {
         $faf->execute();
         $res = $this->getNumPhotoTags($pid);
         $this->assertEquals(1, $res);
         $ret = $this->getPhotoTags($pid);
         $row = $ret[0];
         $this->assertEquals(1234567890, $row['subject_id']);
         $this->assertNull($row['text']);
         $this->assertEquals(30.0, $row['xcoord']);
         $this->assertEquals(40.0, $row['ycoord']);
         //                    $this->assertNull( $row[ 'subject_id' ] );
         //                    $this->assertEquals( "some person", $row[ 'text' ] );
         //                    $this->assertEquals( 70.0, $row[ 'xcoord' ] );
         //                    $this->assertEquals( 80.0, $row[ 'ycoord' ] );
     } catch (Exception $exc) {
         try {
             $this->deletePhotoTags($pid);
         } catch (Exception $e2) {
         }
         throw $exc;
     }
     $this->deletePhotoTags($pid);
     $apiParams = array();
     $apiParams['pid'] = $pid;
     $apiParams['api_key'] = "21";
     $apiParams['tag_text'] = "some person";
     $apiParams['x'] = 70.0;
     $apiParams['y'] = 80.0;
     $faf = $this->initRest(new PhotosAddTag(), $apiParams, $uid);
     $res = $this->getNumPhotoTags($pid);
     $this->assertEquals(0, $res);
     try {
         $faf->execute();
         $res = $this->getNumPhotoTags($pid);
         $this->assertEquals(1, $res);
         $res = $this->getPhotoTags($pid);
         $row = $res[0];
         $this->assertNull($row['subject_id']);
         $this->assertEquals("some person", $row['text']);
         $this->assertEquals(70.0, $row['xcoord']);
         $this->assertEquals(80.0, $row['ycoord']);
     } catch (Exception $exc) {
         try {
             $this->deletePhotoTags($pid);
         } catch (Exception $e2) {
         }
         throw $exc;
     }
     $this->deletePhotoTags($pid);
 }