示例#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 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);
 }
示例#3
0
 public static function getPhotoTag2()
 {
     static $photoTag;
     if (!isset($photoTag)) {
         $user2 = RsOpenFBDbTestUtils::getUser2();
         $photo1 = RsOpenFBDbTestUtils::getPhoto1();
         $photoTag = RsOpenFBDbTestUtils::getOnePhotoTag($photo1->pid, $user2->getId(), "t2", 2.1, 2.2);
     }
     return $photoTag;
 }
示例#4
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);
 }