Example #1
0
 public function testCopy()
 {
     // Initialization
     $_SESSION['id'] = 1;
     $_GET = array('parentId' => '');
     $phpunit = array('isTest' => true);
     include dirname(__FILE__) . '/../index.php';
     //determining the id of the currently created album
     $album = $db->query('SELECT id FROM albums WHERE name="test"');
     if (mysql_num_rows($album) > 0) {
         //getting the id of the last added album with the name "test"
         while ($row = mysql_fetch_assoc($album)) {
             self::$testAlbumId = $row["id"];
         }
     }
     //getting the number of images in the newly created album
     $result = $db->query('SELECT * FROM imagesToAlbums WHERE albumId=' . self::$testAlbumId);
     $initialNumberOfImages = mysql_num_rows($result);
     //upload photo to the root album
     $_FILES = array('file' => array('name' => 'flamingos.jpg', 'type' => 'image/jpeg', 'size' => 542, 'tmp_name' => dirname(__FILE__) . '/data/uploadTest/flamingos.jpg', 'error' => 0));
     $_GET = array('page' => 'upload/upload.php');
     $_POST = array('albumId' => 1);
     include dirname(__FILE__) . '/../index.php';
     //copy the added photo from the root album to the testAlbum
     $image = $db->query('SELECT * FROM images WHERE filename="flamingos"');
     if (mysql_num_rows($image) > 0) {
         //getting the id of the last added album with the name "test"
         while ($row = mysql_fetch_assoc($image)) {
             self::$testImageId = $row["id"];
         }
     }
     $_GET = array('id' => self::$testImageId);
     $_POST = array('albumId' => self::$testAlbumId, 'imageId' => self::$testImageId, 'Copy' => true);
     include dirname(__FILE__) . '/../pages/view/photoCopy.php';
     //getting the new number of images in the album "test"
     $testAlbumImages = $db->query('SELECT imageId FROM imagesToAlbums WHERE albumId=' . self::$testAlbumId);
     $this->assertEquals($initialNumberOfImages + 1, mysql_num_rows($testAlbumImages));
 }
Example #2
0
 public function testImageCopy()
 {
     $test = new TestCopyPhoto();
     $test->setUpBeforeClass();
     $test->testCopy();
     $test->tearDownAfterClass();
 }