Esempio n. 1
0
 public function testMove()
 {
     // 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);
     $testInitialNumberOfImages = 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';
     //getting the number of images in the root album
     $result = $db->query('SELECT * FROM imagesToAlbums WHERE albumId=1');
     $rootInitialNumberOfImages = mysql_num_rows($result);
     //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('albumId' => 1, 'id' => self::$testImageId);
     $_POST = array('newAlbumId' => self::$testAlbumId, 'imageId' => self::$testImageId, 'Move' => true);
     include dirname(__FILE__) . '/../pages/view/photoMoveRightClick.php';
     //getting the new number of images in the album "test"
     $testAlbumImages = $db->query('SELECT * FROM imagesToAlbums WHERE albumId=' . self::$testAlbumId);
     $this->assertEquals($testInitialNumberOfImages + 1, mysql_num_rows($testAlbumImages));
     //getting the new number of images in the root album
     $rootAlbumImages = $db->query('SELECT * FROM imagesToAlbums WHERE albumId=1');
     $this->assertEquals($rootInitialNumberOfImages - 1, mysql_num_rows($rootAlbumImages));
 }
Esempio n. 2
0
 public function testImageMove()
 {
     $test = new TestMovePhoto();
     $test->setUpBeforeClass();
     $test->testMove();
     $test->tearDownAfterClass();
 }