Author: garak
Date: 2010-04-26 18:28:52 +0200 (Mon, 26 Apr 2010)
New Revision: 29265

Modified:
   
plugins/sfAssetsLibraryPlugin/branches/1.3/lib/form/sfAssetReplaceForm.class.php
   plugins/sfAssetsLibraryPlugin/branches/1.3/lib/helper/sfAssetHelper.php
   plugins/sfAssetsLibraryPlugin/branches/1.3/lib/model/sfAsset.php
   plugins/sfAssetsLibraryPlugin/branches/1.3/lib/sfAssetRouting.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/lib/BasesfAssetActions.class.php
   
plugins/sfAssetsLibraryPlugin/branches/1.3/test/functional/sfAssetActionsTest.php
Log:
[sfAssetsLibraryPlugin] fixed some regressions; added more tests


Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/lib/form/sfAssetReplaceForm.class.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/lib/form/sfAssetReplaceForm.class.php
    2010-04-26 15:24:30 UTC (rev 29264)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/lib/form/sfAssetReplaceForm.class.php
    2010-04-26 16:28:52 UTC (rev 29265)
@@ -11,14 +11,13 @@
 {
   public function configure()
   {
+    // remove unneeded fields
+    $this->useFields(array('id'));
+
     // new file
     $this->widgetSchema['file'] = new sfWidgetFormInputFile();
     $this->validatorSchema['file'] = new sfValidatorFile();
 
-    // remove unneeded fields
-    unset($this['folder_id'], $this['filename'], $this['description'], 
$this['author'],
-          $this['copyright'], $this['type'], $this['filesize'], 
$this['created_at']);
-
     // avoid id conflict for id
     $this->widgetSchema['id']->setIdFormat('replace_%s');
   }

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/lib/helper/sfAssetHelper.php
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/lib/helper/sfAssetHelper.php     
2010-04-26 15:24:30 UTC (rev 29264)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/lib/helper/sfAssetHelper.php     
2010-04-26 16:28:52 UTC (rev 29265)
@@ -99,14 +99,14 @@
   use_helper('JavascriptBase');
   use_javascript('/sfAssetsLibraryPlugin/js/main', 'last');
 
-  echo 
javascript_tag('sfAssetsLibrary.init(\''.url_for('@sf_asset_library_list?popup=2').'\')');
+  echo javascript_tag('sfAssetsLibrary.init(\'' . 
url_for('@sf_asset_library_list?popup=2') . '\')');
 }
 
 function init_assets_library_popup()
 {
   use_javascript('/sfAssetsLibraryPlugin/js/main', 'last');
 
-  return 
javascript_tag('sfAssetsLibrary.init(\''.url_for('@sf_asset_library_list').'?popup=2'.'\')');
+  return javascript_tag('sfAssetsLibrary.init(\'' . 
url_for('@sf_asset_library_list?popup=2') . '\')');
 }
 
 function assets_library_breadcrumb($path, $linkLast = false, $action = '')
@@ -154,10 +154,10 @@
     $options['id'] = get_id_from_name($name);
   }
 
-  $form_name = 'this.previousSibling.previousSibling.form.name';
+  $formName = 'this.previousSibling.previousSibling.form.name';
   if (isset($options['form_name']))
   {
-    $form_name = "'".$options['form_name']."'";
+    $formName = "'" . $options['form_name'] . "'";
     unset($options['form_name']);
   }
 
@@ -167,13 +167,13 @@
     'alt' => __('Insert Image'),
     'style' => 'cursor: pointer; vertical-align: middle',
     'onclick' => "
-      initialDir = 
document.getElementById('".$options['id']."').value.replace(/\/[^\/]*$/, '');
-      if(!initialDir) initialDir = 
'".sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media')."';
+      initialDir = document.getElementById('" . $options['id'] . 
"').value.replace(/\/[^\/]*$/, '');
+      if(!initialDir) initialDir = '" . 
sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media') . "';
       sfAssetsLibrary.openWindow({
-        form_name: ".$form_name.",
-        field_name: '".$name."',
-        type: '".$type."',
-        url: 
'".url_for('@sf_asset_library_list?dir=PLACEHOLDER')."?popup=2'.replace('PLACEHOLDER',
 initialDir),
+        form_name: " . $formName . ",
+        field_name: '" . $name . "',
+        type: '" . $type . "',
+        url: '" . url_for('@sf_asset_library_list?dir=PLACEHOLDER&popup=2') . 
"'.replace('PLACEHOLDER', initialDir),
         scrollbars: 'yes'
       });"
   ));

Modified: plugins/sfAssetsLibraryPlugin/branches/1.3/lib/model/sfAsset.php
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/lib/model/sfAsset.php    
2010-04-26 15:24:30 UTC (rev 29264)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/lib/model/sfAsset.php    
2010-04-26 16:28:52 UTC (rev 29265)
@@ -47,12 +47,13 @@
   /**
    * Gives the URL for the given thumbnail
    *
-   * @param string $thumbnail_type
+   * @param  string $thumbnail_type
+   * @param  string $relative_path
    * @return string
    */
   public function getUrl($thumbnail_type = 'full', $relative_path = null)
   {
-    if(is_null($relative_path))
+    if (is_null($relative_path))
     {
       if (!$folder = $this->getsfAssetFolder())
       {
@@ -91,20 +92,20 @@
   /**
    * Physically creates asset
    *
-   * @param string $asset_path path to the asset original file
-   * @param bool $move do move or just copy ?
+   * @param string  $assetPath path to the asset original file
+   * @param boolean $move      do move or just copy ?
+   * @param boolean $move      check duplicate?
    */
-  public function create($asset_path, $move = true, $checkDuplicate = true)
+  public function create($assetPath, $move = true, $checkDuplicate = true)
   {
-    if (!is_file($asset_path))
+    if (!is_file($assetPath))
     {
-      throw new sfAssetException('Asset "%asset%" not found', array('%asset%' 
=> $asset_path));
+      throw new sfAssetException('Asset "%asset%" not found', array('%asset%' 
=> $assetPath));
     }
-
     // calculate asset properties
     if (!$this->getFilename())
     {
-      list (,$filename) = sfAssetsLibraryTools::splitPath($asset_path);
+      list (, $filename) = sfAssetsLibraryTools::splitPath($assetPath);
       $this->setFilename($filename);
     }
 
@@ -113,16 +114,13 @@
     {
       $this->getsfAssetFolder()->create();
     }
-    else
+    // check if a file with this name already exists
+    elseif ($checkDuplicate && 
sfAssetPeer::exists($this->getsfAssetFolder()->getId(), $this->getFilename()))
     {
-      // check if a file with this name already exists
-      if($checkDuplicate && 
sfAssetPeer::exists($this->getsfAssetFolder()->getId(), $this->getFilename()))
-      {
-        $this->setFilename(time().$this->getFilename());
-      }
+      $this->setFilename(time() . $this->getFilename());
     }
 
-    $this->setFilesize((int) filesize($asset_path) / 1024);
+    $this->setFilesize((int) filesize($assetPath) / 1024);
     $this->autoSetType();
     if (sfConfig::get('app_sfAssetsLibrary_check_type', false) && 
!in_array($this->getType(), sfConfig::get('app_sfAssetsLibrary_types', 
array('image', 'txt', 'archive', 'pdf', 'xls', 'doc', 'ppt'))))
     {
@@ -131,11 +129,11 @@
 
     if ($move)
     {
-      rename($asset_path, $this->getFullPath());
+      rename($assetPath, $this->getFullPath());
     }
     else
     {
-      copy($asset_path, $this->getFullPath());
+      copy($assetPath, $this->getFullPath());
     }
 
     if ($this->supportsThumbnails())
@@ -144,6 +142,9 @@
     }
   }
 
+  /**
+   * @return array
+   */
   public function getFilepaths()
   {
     $filepaths = array('full' => $this->getFullPath());
@@ -165,27 +166,27 @@
   /**
    * Change asset directory and/or name
    *
-   * @param sfAssetFolder $new_folder
-   * @param string $new_filename
+   * @param sfAssetFolder $newFolder
+   * @param string        $newFilename
    */
-  public function move(sfAssetFolder $new_folder, $new_filename = null)
+  public function move(sfAssetFolder $newFolder, $newFilename = null)
   {
-    if (sfAssetPeer::exists($new_folder->getId(), $new_filename ? 
$new_filename : $this->getFilename()))
+    if (sfAssetPeer::exists($newFolder->getId(), $newFilename ? $newFilename : 
$this->getFilename()))
     {
-      throw new sfAssetException('The target folder "%folder%" already 
contains an asset named "%name%". The asset has not been moved.', 
array('%folder%' => $new_folder->getName(), '%name%' => $new_filename ? 
$new_filename : $this->getFilename()));
+      throw new sfAssetException('The target folder "%folder%" already 
contains an asset named "%name%". The asset has not been moved.', 
array('%folder%' => $newFolder->getName(), '%name%' => $newFilename ? 
$newFilename : $this->getFilename()));
     }
-    $old_filepaths = $this->getFilepaths();
-    if ($new_filename)
+    $oldFilepaths = $this->getFilepaths();
+    if ($newFilename)
     {
-      if (sfAssetsLibraryTools::sanitizeName($new_filename) != $new_filename)
+      if (sfAssetsLibraryTools::sanitizeName($newFilename) != $newFilename)
       {
-        throw new sfAssetException('The filename "%name%" contains incorrect 
characters. The asset has not be altered.', array('%name%' => $new_filename));
+        throw new sfAssetException('The filename "%name%" contains incorrect 
characters. The asset has not be altered.', array('%name%' => $newFilename));
       }
-      $this->setFilename($new_filename);
+      $this->setFilename($newFilename);
     }
-    $this->setFolderId($new_folder->getId());
+    $this->setFolderId($newFolder->getId());
     $success = true;
-    foreach ($old_filepaths as $type => $filepath)
+    foreach ($oldFilepaths as $type => $filepath)
     {
       $success = rename($filepath, $this->getFullPath($type)) && $success;
     }
@@ -197,6 +198,7 @@
 
   /**
    * Physically remove assets
+   * @return boolean
    */
   public function destroy()
   {
@@ -209,6 +211,10 @@
     return $success;
   }
 
+  /**
+   * @param  PropelPDO $con
+   * @return boolean
+   */
   public function delete(PropelPDO $con = null)
   {
     $success = $this->destroy();

Modified: plugins/sfAssetsLibraryPlugin/branches/1.3/lib/sfAssetRouting.php
===================================================================
--- plugins/sfAssetsLibraryPlugin/branches/1.3/lib/sfAssetRouting.php   
2010-04-26 15:24:30 UTC (rev 29264)
+++ plugins/sfAssetsLibraryPlugin/branches/1.3/lib/sfAssetRouting.php   
2010-04-26 16:28:52 UTC (rev 29265)
@@ -18,32 +18,26 @@
     $r = $event->getSubject();
 
     // prepend our routes
-    $r->prependRoute('sf_guard_signin', new sfRoute('/login', array('module' 
=> 'sfGuardAuth', 'action' => 'signin')));
 
-    $r->prependRoute('sf_asset_library_dir', new sfRoute('/sfAsset/dir/:dir', 
array(
-        'module'    => 'sfAsset',
-        'action'    => 'list',
-        'dir'       => sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media')
-      ),
-      array('dir' => '.*?'))
+    $idActions = array(
+      'tiny_config'   => 'tinyConfigMedia',
+      'delete_folder' => 'deleteFolder',
+      'delete_asset'  => 'deleteAsset',
+      'edit'          => 'edit',
     );
 
     $actions = array(
-      'list'          => 'list',
-      'search'        => 'search',
-      'edit'          => 'edit',
-      'update'        => 'update',
-      'move_asset'    => 'moveAsset',
-      'rename_asset'  => 'renameAsset',
-      'replace_asset' => 'replaceAsset',
-      'delete_asset'  => 'deleteAsset',
-      'create_folder' => 'createFolder',
       'move_folder'   => 'moveFolder',
       'rename_folder' => 'renameFolder',
-      'delete_folder' => 'deleteFolder',
       'mass_upload'   => 'massUpload',
+      'create_folder' => 'createFolder',
       'add_quick'     => 'addQuick',
-      'tiny_config'   => 'tinyConfigMedia',
+      'rename_asset'  => 'renameAsset',
+      'replace_asset' => 'replaceAsset',
+      'move_asset'    => 'moveAsset',
+      'update'        => 'update',
+      'search'        => 'search',
+      'list'          => 'list',
     );
 
     foreach ($actions as $route => $action)
@@ -52,5 +46,21 @@
         'module' => 'sfAsset', 'action' => $action,
       )));
     }
+
+    foreach ($idActions as $route => $action)
+    {
+      $r->prependRoute('sf_asset_library_' . $route, new sfRoute('/sfAsset/' . 
$action . '/:id', array(
+        'module' => 'sfAsset',
+        'action' => $action,
+      )));
+    }
+
+    $r->prependRoute('sf_asset_library_dir', new sfRoute('/sfAsset/dir/:dir', 
array(
+        'module'    => 'sfAsset',
+        'action'    => 'list',
+        'dir'       => sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media')
+      ),
+      array('dir' => '.*?'))
+    );
   }
 }

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/lib/BasesfAssetActions.class.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/lib/BasesfAssetActions.class.php
 2010-04-26 15:24:30 UTC (rev 29264)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/modules/sfAsset/lib/BasesfAssetActions.class.php
 2010-04-26 16:28:52 UTC (rev 29265)
@@ -58,7 +58,7 @@
     }
     $this->files = sfAssetPeer::doSelect($c);
     $this->nb_files = count($this->files);
-    if($this->nb_files)
+    if ($this->nb_files)
     {
       $total_size = 0;
       foreach ($this->files as $file)
@@ -72,8 +72,6 @@
     $this->folder = $folder;
 
     $this->removeLayoutIfPopup($request);
-
-    return sfView::SUCCESS;
   }
 
   /**
@@ -348,8 +346,11 @@
     $folderPath = $asset->getFolderPath();
     try
     {
-      $this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', 
array('object' => $asset)));
-      $asset->delete();
+      if ($asset->delete())
+      {
+        $this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', 
array('object' => $asset)));
+        $this->getUser()->setFlash('notice', 'The file has been deleted');
+      }
     }
     catch (PropelException $e)
     {
@@ -357,7 +358,7 @@
       return $this->forward('sfAsset', 'edit');
     }
 
-    return $this->redirectToPath('@sf_asset_library_dir?dir='.$folderPath);
+    return $this->redirectToPath('@sf_asset_library_dir?dir=' . $folderPath);
   }
 
   /**
@@ -498,12 +499,12 @@
       // physically replace asset
       $file = $form->getValue('file');
       $asset->destroy();
-      $asset->create($file->getTempName(), true, false);
+      $asset->create($file->getTempName(), false, false);
       $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', 
array('object' => $asset)));
       $this->getUser()->setFlash('notice', 'The file has been replaced');
     }
 
-    return $this->redirect('@sf_asset_library_edit?id='.$asset->getId());
+    return $this->redirect('@sf_asset_library_edit?id=' . $asset->getId());
   }
 
   /**
@@ -516,8 +517,6 @@
     $this->forward404Unless($this->sf_asset, 'asset not found');
     $this->form = new sfAssetTinyConfigMediaForm($this->sf_asset);
     
$this->setLayout($this->getContext()->getConfiguration()->getTemplateDir('sfAsset',
 'popupLayout.php') . DIRECTORY_SEPARATOR . 'popupLayout');
-
-    return sfView::SUCCESS;
   }
 
   /**
@@ -595,4 +594,100 @@
     return $asset;
   }
 
+  /**
+   * process search
+   * @param array        $searchParams
+   * @param sfWebRequest $request
+   */
+  protected function processSearch(array $searchParams, sfWebRequest $request)
+  {
+    $c = new Criteria();
+
+    if (isset($searchParams['folder_id']) && $searchParams['folder_id'] !== '')
+    {
+      if (null!= $folder = 
sfAssetFolderPeer::retrieveByPK($searchParams['folder_id']))
+      {
+        $c->addJoin(sfAssetPeer::FOLDER_ID, sfAssetFolderPeer::ID);
+        $c->add(sfAssetFolderPeer::TREE_LEFT, $folder->getTreeLeft(), 
Criteria::GREATER_EQUAL);
+        $c->add(sfAssetFolderPeer::TREE_RIGHT, $folder->getTreeRIGHT(), 
Criteria::LESS_EQUAL);
+      }
+    }
+    if (isset($searchParams['filename']['is_empty']))
+    {
+      $criterion = $c->getNewCriterion(sfAssetPeer::FILENAME, '');
+      $criterion->addOr($c->getNewCriterion(sfAssetPeer::FILENAME, null, 
Criteria::ISNULL));
+      $c->add($criterion);
+    }
+    elseif (isset($searchParams['filename']['text']) && 
$searchParams['filename']['text'] !== '')
+    {
+      $c->add(sfAssetPeer::FILENAME, 
'%'.trim($searchParams['filename']['text'], '*%').'%', Criteria::LIKE);
+    }
+    if (isset($searchParams['author']['is_empty']))
+    {
+      $criterion = $c->getNewCriterion(sfAssetPeer::AUTHOR, '');
+      $criterion->addOr($c->getNewCriterion(sfAssetPeer::AUTHOR, null, 
Criteria::ISNULL));
+      $c->add($criterion);
+    }
+    elseif (isset($searchParams['author']['text']) && 
$searchParams['author']['text'] !== '')
+    {
+      $c->add(sfAssetPeer::AUTHOR, '%'.trim($searchParams['author']['text'], 
'*%').'%', Criteria::LIKE);
+    }
+    if (isset($searchParams['copyright']['is_empty']))
+    {
+      $criterion = $c->getNewCriterion(sfAssetPeer::COPYRIGHT, '');
+      $criterion->addOr($c->getNewCriterion(sfAssetPeer::COPYRIGHT, null, 
Criteria::ISNULL));
+      $c->add($criterion);
+    }
+    elseif (isset($searchParams['copyright']['text']) && 
$searchParams['copyright']['text'] !== '')
+    {
+      $c->add(sfAssetPeer::COPYRIGHT, 
'%'.trim($searchParams['copyright']['text'], '*%').'%', Criteria::LIKE);
+    }
+    if (isset($searchParams['created_at']))
+    {
+      if (isset($searchParams['created_at']['from']) && 
$searchParams['created_at']['from'] !== array())  // TODO check this
+      {
+        $criterion = $c->getNewCriterion(sfAssetPeer::CREATED_AT, 
$searchParams['created_at']['from'], Criteria::GREATER_EQUAL);
+      }
+      if (isset($searchParams['created_at']['to']) && 
$searchParams['created_at']['to'] !== array())  // TODO check this
+      {
+        if (isset($criterion))
+        {
+          $criterion->addAnd($c->getNewCriterion(sfAssetPeer::CREATED_AT, 
$searchParams['created_at']['to'], Criteria::LESS_EQUAL));
+        }
+        else
+        {
+          $criterion = $c->getNewCriterion(sfAssetPeer::CREATED_AT, 
$searchParams['created_at']['to'], Criteria::LESS_EQUAL);
+        }
+      }
+      if (isset($criterion))
+      {
+        $c->add($criterion);
+      }
+    }
+    if (isset($searchParams['description']['is_empty']))
+    {
+      $criterion = $c->getNewCriterion(sfAssetPeer::DESCRIPTION, '');
+      $criterion->addOr($c->getNewCriterion(sfAssetPeer::DESCRIPTION, null, 
Criteria::ISNULL));
+      $c->add($criterion);
+    }
+    else if (isset($searchParams['description']) && 
$searchParams['description'] !== '')
+    {
+      $c->add(sfAssetPeer::DESCRIPTION, '%'.trim($searchParams['description'], 
'*%').'%', Criteria::LIKE);
+    }
+
+    $this->processSort($request);
+    $sortOrder = $this->getUser()->getAttribute('sort', 'name', 
'sf_admin/sf_asset/sort');
+    switch($sortOrder)
+    {
+      case 'date':
+        $c->addDescendingOrderByColumn(sfAssetPeer::CREATED_AT);
+        break;
+      default:
+        $c->addAscendingOrderByColumn(sfAssetPeer::FILENAME);
+        break;
+    }
+
+    return $c;
+  }
+
 }

Modified: 
plugins/sfAssetsLibraryPlugin/branches/1.3/test/functional/sfAssetActionsTest.php
===================================================================
--- 
plugins/sfAssetsLibraryPlugin/branches/1.3/test/functional/sfAssetActionsTest.php
   2010-04-26 15:24:30 UTC (rev 29264)
+++ 
plugins/sfAssetsLibraryPlugin/branches/1.3/test/functional/sfAssetActionsTest.php
   2010-04-26 16:28:52 UTC (rev 29265)
@@ -91,7 +91,7 @@
   with('form')->hasErrors(false)->
   with('response')->isRedirected()->followRedirect()->
   with('response')->begin()->
-    checkElement('h2', '/Your modifications have been saved/')->
+    checkElement('div.save-ok', '/Your modifications have been saved/')->
   end()->
   with('propel')->check('sfAsset', array(
     'folder_id'   => $subdir1->getId(),
@@ -151,7 +151,7 @@
   ), false)->
   with('response')->isRedirected()->followRedirect()->
   with('response')->begin()->
-    checkElement('h2', '/The folder has been deleted/')->
+    checkElement('div.save-ok', '/The folder has been deleted/')->
   end()->
 
   info('move folder')->
@@ -171,7 +171,7 @@
   ))->
   with('response')->isRedirected()->followRedirect()->
   with('response')->begin()->
-    checkElement('h2', '/The folder has been moved/')->
+    checkElement('div.save-ok', '/The folder has been moved/')->
   end()->
 
   info('move asset')->
@@ -186,7 +186,7 @@
   end()->
   with('response')->isRedirected()->followRedirect()->
   with('response')->begin()->
-    checkElement('h2', '/The file has been moved/')->
+    checkElement('div.save-ok', '/The file has been moved/')->
   end()->
   with('propel')->check('sfAsset', array(
     'folder_id'   => $subdir2->getId(),
@@ -207,7 +207,7 @@
   end()->
   with('response')->isRedirected()->followRedirect()->
   with('response')->begin()->
-    checkElement('h2', '/The file has been renamed/')->
+    checkElement('div.save-ok', '/The file has been renamed/')->
   end()->
   with('propel')->check('sfAsset', array(
     'folder_id'   => $subdir2->getId(),
@@ -220,19 +220,23 @@
   click('input[value="Replace"]', array('sf_asset' => array(
     'file' => dirname(__FILE__) . '/../data/propel.gif',
   )))->
-  #with('form')->hasErrors(false)-> // TODO why no form?? :-|
+  #with('response')->begin()->debug()->
+  #with('form')->begin()->debug()->hasErrors(false)->
   with('request')->begin()->
     isParameter('module', 'sfAsset')->
     isParameter('action', 'replaceAsset')->
   end()->
   with('response')->isRedirected()->followRedirect()->
+  with('request')->begin()->
+    isParameter('module', 'sfAsset')->
+    isParameter('action', 'edit')->
+  end()->
   with('response')->begin()->
-    checkElement('h2', '/The file has been replaced/')->
+    checkElement('div.save-ok', '/The file has been replaced/')->#debug()->
   end()->
-  // TODO this test fails :-|
   with('propel')->check('sfAsset', array(
     'folder_id'   => $subdir2->getId(),
-    'filename'    => 'propel.gif',
+    'filename'    => 'demorenamed.png',
     'description' => 'this is a demo image',
     'type'        => 'image',
   ))->
@@ -244,11 +248,14 @@
     isParameter('action', 'deleteAsset')->
   end()->
   with('propel')->check('sfAsset', array(
-    'folder_id'   => $subdir2->getId(),
-    'filename'    => 'propel.gif',
-    'type'        => 'image',
+    'folder_id' => $subdir2->getId(),
+    'filename'  => 'propel.gif',
+    'type'      => 'image',
   ), false)->
   with('response')->isRedirected()->followRedirect()->
+  with('response')->begin()->
+    checkElement('div.save-ok', '/The file has been deleted/')->#debug()->
+  end()->
 
   info('mass upload')->
   click('media')->
@@ -274,4 +281,32 @@
       'filename'  => 'propel2.gif',
       'type'      => 'image',
     ))->
-  end();
\ No newline at end of file
+  end()->
+
+  info('search')->
+  get('/sfAsset/dir/media')->
+  click('input[value="Search"]')->
+  with('form')->begin()->
+    hasErrors(false)->
+  end()->
+  with('request')->begin()->
+    isParameter('module', 'sfAsset')->
+    isParameter('action', 'search')->
+  end()->
+  with('response')->begin()->
+    checkElement('div.search_result', 7)->
+  end()->
+  click('input[value="Search"]', array('sf_asset_filters' => array(
+    'filename' => array('text' => 'asset1'),
+  )))->
+  with('form')->begin()->
+    hasErrors(false)->
+  end()->
+  with('request')->begin()->
+    isParameter('module', 'sfAsset')->
+    isParameter('action', 'search')->
+  end()->
+  with('response')->begin()->
+    checkElement('div.search_result', 3)->
+  end();
+  // TODO more tests...

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to