public function save()
 {
     $values = $this->getValues();
     // TODO : find a better way to populate values.
     foreach ($values['sfAsset'] as $key => $value) {
         $sf_asset = new sfAsset();
         $sf_asset->fromArray($value);
         $sf_asset->setBinaryContent($value['binary_content']);
         $sf_asset->save();
     }
 }
예제 #2
0
 /**
  * save all assets
  * @param PropelPDO $con
  */
 protected function doSave($con = null)
 {
     if (null === $con) {
         $con = $this->getConnection();
     }
     for ($i = 1; $i <= $this->getOption('size'); $i++) {
         if ($file = $this->getValue('file_' . $i)) {
             $asset = new sfAsset();
             $asset->setFolderId($this->getValue('folder_id'));
             $asset->setDescription($file->getOriginalName());
             $asset->setAuthor($this->getOption('author'));
             $asset->setFilename($file->getOriginalName());
             $asset->create($file->getTempName());
             $asset->save();
             $this->assets[] = $asset;
         }
     }
 }
예제 #3
0
/**
 * Gives an image tag for an asset
 * 
 * @param sfAsset $asset
 * @param string $thumbnail_type
 * @param bool $file_system
 * @param array $options
 * @return string
 */
function asset_image_tag($asset, $thumbnail_type = 'full', $options = array(), $relative_path = null)
{
    $options = array_merge(array('alt' => $asset->getDescription() . ' ' . $asset->getCopyright(), 'title' => $asset->getDescription() . ' ' . $asset->getCopyright()), $options);
    if ($asset->isImage()) {
        $src = $asset->getUrl($thumbnail_type, $relative_path);
    } else {
        if ($thumbnail_type == 'full') {
            throw new sfAssetException('Impossible to render a non-image asset in an image tag');
        } else {
            switch ($asset->getType()) {
                case 'txt':
                    $src = '/sfAssetsLibraryPlugin/images/txt.png';
                    break;
                case 'xls':
                    $src = '/sfAssetsLibraryPlugin/images/xls.png';
                    break;
                case 'doc':
                    $src = '/sfAssetsLibraryPlugin/images/doc.png';
                    break;
                case 'pdf':
                    $src = '/sfAssetsLibraryPlugin/images/pdf.png';
                    break;
                case 'html':
                    $src = '/sfAssetsLibraryPlugin/images/html.png';
                    break;
                case 'archive':
                    $src = '/sfAssetsLibraryPlugin/images/archive.png';
                    break;
                case 'bin':
                    $src = '/sfAssetsLibraryPlugin/images/bin.png';
                    break;
                default:
                    $src = '/sfAssetsLibraryPlugin/images/unknown.png';
            }
        }
    }
    return image_tag($src, $options);
}
/**
 * @param  string  $text
 * @param  sfAsset $asset
 * @return string
 */
function link_to_asset_action($text, $asset)
{
    $user = sfContext::getInstance()->getUser();
    if ($user->hasAttribute('popup', 'sf_admin/sf_asset/navigation')) {
        switch ($user->getAttribute('popup', null, 'sf_admin/sf_asset/navigation')) {
            case 1:
                // popup called from a Rich Text Editor (ex: TinyMCE)
                #return link_to($text, '@sf_asset_library_tiny_config?id=' . $asset->getId(), 'title=' . $asset->getFilename());
                throw new sfAssetException('this option should be unused...');
            case 2:
                // popup called from a simple form input (or via input_sf_asset_tag)
                return link_to_function($text, "setImageField('" . $asset->getUrl() . "','" . $asset->getUrl('small') . "'," . $asset->getId() . ')');
            case 3:
                // popup called from a Rich Text Editor (ex: CK Editor)
                return link_to_function($text, "window.opener.CKEDITOR.tools.callFunction('" . $user->getAttribute('func', 1, 'sf_admin/sf_asset/navigation') . "', '" . $asset->getUrl() . "'); window.close()");
        }
    } else {
        // case : sf view (i.e. module sfAsset, view list)
        return link_to($text, '@sf_asset_library_edit?id=' . $asset->getId(), 'title=' . $asset->getFilename());
    }
}
예제 #5
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      sfAsset $value A sfAsset object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(sfAsset $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
예제 #6
0
 /**
  * Overrrides the parent synchronizeWith() method to add a fix when calling
  * insertAsLastChildOf($this->reload()) because $this->reload() doesn't return
  * $this.
  *
  * @see parent::synchronizeWith()
  */
 public function synchronizeWith($baseFolder, $verbose = true, $removeOrphanAssets = false, $removeOrphanFolders = false)
 {
     if (!is_dir($baseFolder)) {
         throw new sfAssetException(sprintf('%s is not a directory', $baseFolder));
     }
     $files = sfFinder::type('file')->maxdepth(0)->ignore_version_control()->in($baseFolder);
     $assets = $this->getAssetsWithFilenames();
     foreach ($files as $file) {
         if (!array_key_exists(basename($file), $assets)) {
             // File exists, asset does not exist: create asset
             $sfAsset = new sfAsset();
             $sfAsset->setFolderId($this->getId());
             $sfAsset->create($file, false);
             $sfAsset->save();
             if ($verbose) {
                 sfAssetsLibraryTools::log(sprintf("Importing file %s", $file), 'green');
             }
         } else {
             // File exists, asset exists: do nothing
             unset($assets[basename($file)]);
         }
     }
     foreach ($assets as $name => $asset) {
         if ($removeOrphanAssets) {
             // File does not exist, asset exists: delete asset
             $asset->delete();
             if ($verbose) {
                 sfAssetsLibraryTools::log(sprintf("Deleting asset %s", $asset->getUrl()), 'yellow');
             }
         } else {
             if ($verbose) {
                 sfAssetsLibraryTools::log(sprintf("Warning: No file for asset %s", $asset->getUrl()), 'red');
             }
         }
     }
     $dirs = sfFinder::type('dir')->maxdepth(0)->discard(sfConfig::get('app_sfAssetsLibrary_thumbnail_dir', 'thumbnail'))->ignore_version_control()->in($baseFolder);
     $folders = $this->getSubfoldersWithFolderNames();
     foreach ($dirs as $dir) {
         list(, $name) = sfAssetsLibraryTools::splitPath($dir);
         if (!array_key_exists($name, $folders)) {
             $this->reload();
             // dir exists in filesystem, not in database: create folder in database
             $sfAssetFolder = new sfAssetFolder();
             $sfAssetFolder->insertAsLastChildOf($this);
             $sfAssetFolder->setName($name);
             $sfAssetFolder->save();
             if ($verbose) {
                 sfAssetsLibraryTools::log(sprintf("Importing directory %s", $dir), 'green');
             }
         } else {
             // dir exists in filesystem and database: look inside
             $sfAssetFolder = $folders[$name];
             unset($folders[$name]);
         }
         $sfAssetFolder->synchronizeWith($dir, $verbose, $removeOrphanAssets, $removeOrphanFolders);
     }
     foreach ($folders as $name => $folder) {
         if ($removeOrphanFolders) {
             $folder->delete(null, true);
             if ($verbose) {
                 sfAssetsLibraryTools::log(sprintf("Deleting folder %s", $folder->getRelativePath()), 'yellow');
             }
         } else {
             if ($verbose) {
                 sfAssetsLibraryTools::log(sprintf("Warning: No directory for folder %s", $folder->getRelativePath()), 'red');
             }
         }
     }
 }
예제 #7
0
 public function addsfAsset(sfAsset $l)
 {
     $this->collsfAssets[] = $l;
     $l->setsfAssetFolder($this);
 }
 $sfAssetFolder3 = new sfAssetFolder();
 $sfAssetFolder3->insertAsFirstChildOf($sfAssetFolder2);
 $sfAssetFolder3->setName('Test_Sub-sub-directory');
 $sfAssetFolder3->save();
 $t->is($sfAssetFolder3->getRelativePath(), $sfAssetFolder2->getRelativePath() . '/' . $sfAssetFolder3->getName(), 'getRelativePath() returns the folder relative path, including its ancestors names');
 $id3 = $sfAssetFolder3->getId();
 # $sfAsset is /root/Test_Directory/Test_Sub-directory/raikkonen.jpg
 $assets_path = dirname(__FILE__) . '/../assets/';
 $test_asset = $assets_path . 'raikkonen.jpg';
 $sfAsset = new sfAsset();
 $sfAsset->setFolder($sfAssetFolder2);
 $sfAsset->create($test_asset, false);
 $sfAsset->save();
 $sf_asset_id = $sfAsset->getId();
 # $sfAsset2 is /root/Test_Directory/Test_Sub-directory/Test_Sub-sub-directory/toto
 $sfAsset2 = new sfAsset();
 $sfAsset2->setFolder($sfAssetFolder3);
 $sfAsset2->setFilename('toto');
 $sfAsset2->create($test_asset, false);
 $sfAsset2->save();
 $sf_asset2_id = $sfAsset2->getId();
 # So now we have:
 # root/
 #   Test_Directory/               sfAssetFolder
 #     Test_Sub-directory/         sfAssetFolder2
 #       Test_Sub-sub-directory/   sfAssetFolder3
 #         toto
 #       raikkonen.jpg
 $t->diag('sfAssetFolder::move()');
 # move $sfAssetFolder2 from /root/Test_Directory/Test_Sub-directory to /root/Test_Sub-directory
 $sfAssetFolder2->move($root);
예제 #9
0
<?php

$app = "frontend";
include dirname(__FILE__) . '/../../../../test/bootstrap/functional.php';
$browser = new sfTestBrowser();
$browser->initialize();
$con = Propel::getConnection();
$con->begin();
try {
    $t = new lime_test(5, new lime_output_color());
    $t->diag('sfAssetPeer');
    $con->begin();
    $t->is(sfAssetPeer::retrieveFromUrl(sfAssetFolderPeer::getRoot()->getRelativePath() . '/filename.jpg'), null, 'sfAssetPeer::retrieveFromUrl() returns null when a URL is not found');
    $t->is(sfAssetPeer::exists(sfAssetFolderPeer::getRoot()->getId(), 'filename.jpg'), false, 'sfAssetPeer::exists() returns false when an asset is not found');
    $sfAsset = new sfAsset();
    $sfAsset->setsfAssetFolder(sfAssetFolderPeer::getRoot());
    $sfAsset->setFilename('filename.jpg');
    $sfAsset->save($con);
    $t->is(sfAssetPeer::retrieveFromUrl(sfAssetFolderPeer::getRoot()->getRelativePath() . '/filename.jpg')->getId(), $sfAsset->getId(), 'sfAssetPeer::retrieveFromUrl() finds an asset from its URL');
    $t->is(sfAssetPeer::retrieveFromUrl($sfAsset->getUrl())->getId(), $sfAsset->getId(), 'sfAssetPeer::retrieveFromUrl() finds an asset from the result of `getUrl()`');
    $t->is(sfAssetPeer::exists(sfAssetFolderPeer::getRoot()->getId(), 'filename.jpg'), true, 'sfAssetPeer::exists() returns true when an asset is found');
} catch (Exception $e) {
    echo $e->getMessage();
}
// reset DB
$con->rollback();
 $t->diag('sfAsset::getFullPath()');
 $t->is($sfAsset->getFullPath(), sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_sfAssetsLibrary_upload_dir') . DIRECTORY_SEPARATOR . 'filename.jpg', 'getFullPath() returns the complete asset path on the disk');
 $t->is($sfAsset->getFullPath('small'), sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_sfAssetsLibrary_upload_dir') . DIRECTORY_SEPARATOR . 'thumbnail' . DIRECTORY_SEPARATOR . 'small_filename.jpg', 'getFullPath(\'small\') returns the complete small thumbnail path on the disk');
 $t->is($sfAsset->getFullPath('large'), sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_sfAssetsLibrary_upload_dir') . DIRECTORY_SEPARATOR . 'thumbnail' . DIRECTORY_SEPARATOR . 'large_filename.jpg', 'getFullPath(\'large\') returns the complete large thumbnail path on the disk');
 $t->diag('sfAsset::getUrl()');
 $t->is($sfAsset->getUrl(), '/' . sfConfig::get('app_sfAssetsLibrary_upload_dir') . DIRECTORY_SEPARATOR . 'filename.jpg', 'getUrl() returns the asset URL');
 $t->is($sfAsset->getUrl('small'), '/' . sfConfig::get('app_sfAssetsLibrary_upload_dir') . '/thumbnail/small_filename.jpg', 'getUrl(\'small\') returns the small thumbnail url');
 $t->is($sfAsset->getUrl('large'), '/' . sfConfig::get('app_sfAssetsLibrary_upload_dir') . '/thumbnail/large_filename.jpg', 'getUrl(\'large\') returns the large thumbnail url');
 $t->diag('sfAsset::create()');
 $assets_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR;
 $test_asset = $assets_path . 'raikkonen.jpg';
 $folder1 = new sfAssetFolder();
 $folder1->getNode()->insertAsFirstChildOf($root);
 $folder1->setName('Test_Directory');
 $folder1->save();
 $asset1 = new sfAsset();
 $asset1->setFolder($folder1);
 $asset1->create($test_asset, false);
 $asset_file_size = (int) (filesize($test_asset) / 1024);
 $t->is($asset1->getFilename(), 'raikkonen.jpg', 'create() sets the object filename according to the given asset');
 $t->is($asset1->getFilesize(), 18, 'create() sets the object filesize according to the given asset');
 $t->ok($asset1->isImage(), 'create() sets the object type according to the given asset');
 $t->is($asset1->getUrl(), $folder1->getUrl() . '/' . $asset1->getFilename(), 'create() sets the object url according to the given asset and folder object');
 $t->ok(is_file($asset1->getFullPath()), 'create() physically copies asset');
 $t->ok(is_file($asset1->getFullPath('large')), 'create() physically creates thumbnail');
 $t->diag('sfAsset::move()');
 $old_path = $asset1->getFullPath();
 $old_thumb_path = $asset1->getFullPath('large');
 $asset1->move($root, 'raikkonen2.jpg');
 $t->is($asset1->getFilename(), 'raikkonen2.jpg', 'move() changes filename');
 $t->is($asset1->getUrl(), $root->getUrl() . '/' . $asset1->getFilename(), 'move() changes the object url according to the new folder');
예제 #11
0
 $t->is($sfAssetFolder2->getRelativePath(), $sfAssetFolder->getRelativePath() . '/' . $sfAssetFolder2->getName(), 'getRelativePath() is updated on save for subfolders');
 $assets_path = dirname(__FILE__) . '/../assets/';
 $test_asset = $assets_path . 'raikkonen.jpg';
 $t->ok(is_file($test_asset), 'test asset found');
 $sfAsset = new sfAsset();
 $sfAsset->setsfAssetFolder($sfAssetFolder2);
 $sfAsset->create($test_asset, false);
 $sfAsset->save();
 $t->ok(is_file($sfAsset->getFullPath()), 'asset found');
 $sf_asset_id = $sfAsset->getId();
 $sfAssetFolder3 = new sfAssetFolder();
 $sfAssetFolder3->insertAsFirstChildOf($sfAssetFolder2);
 $sfAssetFolder3->setName('Test_Sub-sub-directory');
 $sfAssetFolder3->save();
 $t->is($sfAssetFolder3->getRelativePath(), $sfAssetFolder2->getRelativePath() . '/' . $sfAssetFolder3->getName(), 'getRelativePath() is updated on save for subfolders');
 $sfAsset2 = new sfAsset();
 $sfAsset2->setsfAssetFolder($sfAssetFolder3);
 $sfAsset2->setFilename('toto');
 $sfAsset2->create($test_asset, false);
 $sfAsset2->save();
 $t->ok(is_file($sfAsset2->getFullPath()), 'asset2 found');
 $sf_asset2_id = $sfAsset2->getId();
 $id3 = $sfAssetFolder3->getId();
 $sfAssetFolder2->move($root);
 $sfAssetFolder3 = sfAssetFolderPeer::retrieveByPk($id3);
 $t->is($sfAssetFolder2->getParent()->getId(), $root->getId(), 'move() gives the correct parent');
 $t->is($sfAssetFolder3->getParent()->getParent()->getId(), $root->getId(), 'move() changes descendants grandparents');
 $t->is($sfAssetFolder2->getRelativePath(), $root->getRelativePath() . '/' . $sfAssetFolder2->getName(), 'move() changes descendants relative paths');
 $t->is($sfAssetFolder3->getRelativePath(), $sfAssetFolder2->getRelativePath() . '/' . $sfAssetFolder3->getName(), 'move() changes descendants relative paths');
 $sfAsset = sfAssetPeer::retrieveByPk($sf_asset_id);
 $sfAsset2 = sfAssetPeer::retrieveByPk($sf_asset2_id);
예제 #12
0
 public function executeMassUpload()
 {
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         $folder = sfAssetFolderPeer::retrieveByPath($this->getRequestParameter('parent_folder'));
         $this->forward404Unless($folder);
         try {
             $nbFiles = 0;
             for ($i = 1; $i <= sfConfig::get('app_sfAssetsLibrary_mass_upload_size', 5); $i++) {
                 if ($filename = $this->getRequest()->getFileName('files[' . $i . ']')) {
                     $asset = new sfAsset();
                     $asset->setsfAssetFolder($folder);
                     $asset->setDescription($filename);
                     try {
                         $asset->setAuthor($this->getUser()->getUsername());
                     } catch (sfException $e) {
                         // no getUsername() method in sfUser, all right: do nothing
                     }
                     $asset->setFilename($filename);
                     $asset->create($this->getRequest()->getFilePath('files[' . $i . ']'));
                     $asset->save();
                     $nbFiles++;
                 }
             }
         } catch (sfAssetException $e) {
             $this->setFlash('warning_message', $e->getMessage());
             $this->setFlash('warning_params', $e->getMessageParams());
             $this->redirectToPath('sfAsset/list?dir=' . $folder->getRelativePath());
         }
         $this->setFlash('notice', 'Files successfully uploaded');
         $this->redirectToPath('sfAsset/list?dir=' . $folder->getRelativePath());
     }
 }
 /**
  * upload many assets
  * @param sfWebRequest $request
  */
 public function executeMassUpload(sfWebRequest $request)
 {
     $this->form = new sfAssetsForm(null, array('size' => sfConfig::get('app_sfAssetsLibrary_mass_upload_size', 5)));
     if ($request->getMethod() == sfRequest::POST) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             $folder = sfAssetFolderPeer::retrieveByPK($this->form->getValue('folder_id'));
             $this->forward404Unless($folder, 'folder not found');
             try {
                 $nbFiles = 0;
                 for ($i = 1; $i <= sfConfig::get('app_sfAssetsLibrary_mass_upload_size', 5); $i++) {
                     if ($file = $this->form->getValue('file_' . $i)) {
                         $asset = new sfAsset();
                         $asset->setsfAssetFolder($folder);
                         $asset->setDescription($file->getOriginalName());
                         try {
                             $asset->setAuthor($this->getUser()->getUsername());
                         } catch (sfException $e) {
                             // no getUsername() method in sfUser, all right: do nothing
                         }
                         $asset->setFilename($file->getOriginalName());
                         $asset->create($file->getTempName());
                         $asset->save();
                         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $asset)));
                         $nbFiles++;
                     }
                 }
             } catch (sfAssetException $e) {
                 $this->getUser()->setFlash('warning_message', $e->getMessage());
                 $this->getUser()->setFlash('warning_params', $e->getMessageParams());
                 $this->redirectToPath('@sf_asset_library_dir?dir=' . $folder->getRelativePath());
             }
             $this->getUser()->setFlash('notice', 'Files successfully uploaded');
             $this->redirectToPath('@sf_asset_library_dir?dir=' . $folder->getRelativePath());
         }
     }
 }
/**
 * Gives an image tag for an asset
 * 
 * @param sfAsset $asset
 * @param string $thumbnail_type
 * @param bool $file_system
 * @param array $options
 * @return string
 */
function asset_image_tag($asset, $thumbnail_type = 'full', $options = array(), $relative_path = null)
{
    $options = array_merge(array('alt' => $asset->getDescription() . ' ' . $asset->getCopyright(), 'title' => $asset->getDescription() . ' ' . $asset->getCopyright()), $options);
    $src = $asset->getImageSrc($thumbnail_type, $relative_path);
    return image_tag($src, $options);
}
예제 #15
0
 $t->diag('sfAsset');
 $sfAsset = new sfAsset();
 $sfAsset->setsfAssetFolder(sfAssetFolderPeer::getRoot());
 $t->isa_ok($sfAsset->getsfAssetFolder(), 'sfAssetFolder', 'sfAsset can have root as folder');
 $sfAsset->setFilename('filename.jpg');
 $t->is($sfAsset->getRelativePath(), sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media') . DIRECTORY_SEPARATOR . 'filename.jpg', 'getRelativePath() gives correct result');
 //  sfConfig::set('sf_web_dir', 'var/www/myproject');
 sfConfig::set('app_sfAssetsLibrary_upload_dir', 'medias');
 $t->is($sfAsset->getFullPath(), sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media') . DIRECTORY_SEPARATOR . 'filename.jpg', 'getFullPath() gives complete path');
 $t->is($sfAsset->getFullPath('large'), sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media') . DIRECTORY_SEPARATOR . 'thumbnail/large_filename.jpg', 'getFullPath() gives correct thumbnail path');
 $t->is($sfAsset->getUrl(), DIRECTORY_SEPARATOR . sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media') . DIRECTORY_SEPARATOR . 'filename.jpg', 'getUrl() gives correct url');
 $t->is($sfAsset->getUrl('small'), DIRECTORY_SEPARATOR . sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media') . DIRECTORY_SEPARATOR . 'thumbnail/small_filename.jpg', 'getUrl() gives correctthumbnail url');
 $assets_path = dirname(__FILE__) . '/../assets/';
 $test_asset = $assets_path . 'raikkonen.jpg';
 $t->ok(is_file($test_asset), 'test asset found');
 $sfAsset = new sfAsset();
 $sfAsset->setsfAssetFolder(sfAssetFolderPeer::getRoot());
 $sfAsset->create($test_asset, false);
 $t->is($sfAsset->getFilename(), 'raikkonen.jpg', 'create() gives correct filename');
 $t->is($sfAsset->getFilesize(), 18, 'create() gives correct size');
 $t->ok($sfAsset->isImage(), 'create() gives correct type');
 $t->ok(is_file($sfAsset->getFullPath()), 'create() physically copies asset');
 $t->ok(is_file($sfAsset->getFullPath('large')), 'create() physically creates thumbnail');
 $old_path = $sfAsset->getFullPath();
 $old_thumb_path = $sfAsset->getFullPath('large');
 $sfAsset->move(sfAssetFolderPeer::getRoot(), 'raikkonen2.jpg');
 $t->is($sfAsset->getFilename(), 'raikkonen2.jpg', 'move() changes filename');
 $t->ok(is_file($sfAsset->getFullPath()), 'move() physically moves asset');
 $t->ok(!is_file($old_path), 'move() physically moves asset');
 $t->ok(is_file($sfAsset->getFullPath('large')), 'move() physically moves thumbnail');
 $t->ok(!is_file($old_thumb_path), 'move() physically moves thumbnail');
 $t->diag('sfAsset');
 $sfAsset = new sfAsset();
 $sfAsset->setsfAssetFolder(sfAssetFolderTable::getRoot());
 $t->isa_ok($sfAsset->getsfAssetFolder(), 'sfAssetFolder', 'sfAsset can have root as folder');
 $sfAsset->setFilename('filename.jpg');
 $t->is($sfAsset->getRelativePath(), sfConfig::get('app_sfDoctrineAssetsLibrary_upload_dir', 'media') . DIRECTORY_SEPARATOR . 'filename.jpg', 'getRelativePath() gives correct result');
 sfConfig::set('sf_web_dir', '/tmp');
 sfConfig::set('app_sfDoctrineAssetsLibrary_upload_dir', 'media');
 $t->is($sfAsset->getFullPath(), sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_sfDoctrineAssetsLibrary_upload_dir', 'media') . DIRECTORY_SEPARATOR . 'filename.jpg', 'getFullPath() gives complete path');
 $t->is($sfAsset->getFullPath('large'), sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_sfDoctrineAssetsLibrary_upload_dir', 'media') . DIRECTORY_SEPARATOR . 'thumbnail/large_filename.jpg', 'getFullPath() gives correct thumbnail path');
 $t->is($sfAsset->getUrl(), DIRECTORY_SEPARATOR . sfConfig::get('app_sfDoctrineAssetsLibrary_upload_dir', 'media') . DIRECTORY_SEPARATOR . 'filename.jpg', 'getUrl() gives correct url');
 $t->is($sfAsset->getUrl('small'), DIRECTORY_SEPARATOR . sfConfig::get('app_sfDoctrineAssetsLibrary_upload_dir', 'media') . DIRECTORY_SEPARATOR . 'thumbnail/small_filename.jpg', 'getUrl() gives correct thumbnail url');
 $assets_path = dirname(__FILE__) . '/../assets/';
 $test_asset = $assets_path . 'raikkonen.jpg';
 $t->ok(is_file($test_asset), 'test asset found');
 $sfAsset = new sfAsset();
 $sfAsset->setsfAssetFolder(sfAssetFolderTable::getRoot());
 $sfAsset->createAsset($test_asset, false);
 $t->is($sfAsset->getFilename(), 'raikkonen.jpg', 'create() gives correct filename');
 $t->is((int) $sfAsset->getFilesize(), 18, 'create() gives correct size');
 $t->ok($sfAsset->isImage(), 'create() gives correct type');
 $t->ok(is_file($sfAsset->getFullPath()), 'create() physically copies asset');
 if ($sfAsset->supportsThumbnails()) {
     $t->ok(is_file($sfAsset->getFullPath('large')), 'create() physically creates thumbnail');
 } else {
     $t->diag('please activate thumbnails support');
 }
 $old_path = $sfAsset->getFullPath();
 $old_thumb_path = $sfAsset->getFullPath('large');
 $sfAsset->save($doctrine_conn);
 $sfAsset->setFilename('raikkonen2.jpg');