public function initPhotoTags() { $dbCon = RsOpenFBDbTestUtils::getDbCon(); $user1 = RsOpenFBDbTestUtils::getUser1(); $user2 = RsOpenFBDbTestUtils::getUser2(); $photoTag1 = RsOpenFBDbTestUtils::getPhotoTag1(); $photoTag2 = RsOpenFBDbTestUtils::getPhotoTag2(); $photoTag3 = RsOpenFBDbTestUtils::getPhotoTag3(); }
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); }
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; }
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); }