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(); $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() { $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); }