Beispiel #1
0
 public function initPhotos()
 {
     $dbCon = RsOpenFBDbTestUtils::getDbCon();
     $user1 = RsOpenFBDbTestUtils::getUser1();
     $album1 = RsOpenFBDbTestUtils::getAlbum1();
     $album2 = RsOpenFBDbTestUtils::getAlbum2();
     $photo1 = RsOpenFBDbTestUtils::getPhoto1();
     $photo2 = RsOpenFBDbTestUtils::getPhoto2();
     $photo3 = RsOpenFBDbTestUtils::getPhoto3();
 }
 public static function getPhoto2()
 {
     static $photo;
     if (!isset($photo)) {
         $user1 = RsOpenFBDbTestUtils::getUser1();
         $aid = RsOpenFBDbTestUtils::getAlbum1();
         $photo = RsOpenFBDbTestUtils::getOnePhoto(9999237, $aid, "cap 2", "link 2", $user1->getId(), "src 2", "src Big 2", "src Small 2");
     }
     return $photo;
 }
Beispiel #3
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);
 }
 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));
 }