/**
  * Creates the cache directory on demand
  *
  * @param sfFilebasePluginDirectory | string: The pathname of the cache directory.
  * @return sfFilebasePluginDirectory $cache_directory
  */
 public function initCacheDirectory($cache_directory)
 {
     $this->cacheDirectory = $this->filebase->getFilebaseFile($cache_directory);
     if (!$this->cacheDirectory->fileExists()) {
         $this->cacheDirectory = $this->filebase->mkDir($this->cacheDirectory);
     }
     return $this->cacheDirectory;
 }
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(81, new lime_output_color());
$t->diag('Ok, let\'s take a look... These tests are as incomplete as tests can be.');
$t->diag('Any exeptions thrown during testrun may cause in file-permission issues. After a test-run failed, please manually clean up the standard-filebase-directory unter sfConfig::get(sf_upload_dir) and run php ./symfony fix-perms task as a system administrator.');
###  INSTANCIATING FILEBASE
$t->isa_ok(new sfFilebasePlugin(), 'sfFilebasePlugin', 'sfFilebasePlugin instanziated.');
$t->diag('Performing some file operations.');
$f = new sfFilebasePlugin();
$t->diag('Lets try to generate a directory with mkDir().');
$dir = null;
try {
    $t->isa_ok($dir = $f->mkDir('my_dir', 0777), 'sfFilebasePluginDirectory', 'mkDir() successfully created a new directory.');
} catch (Exception $e) {
    $t->fail((string) $e->getMessage());
    $t->diag('Maybe the directory already exists....');
}
$t->ok($dir instanceof sfFilebasePluginDirectory, 'mkDir() returns instance of sfFilebasePluginDirectory.');
$t->diag('Directory was created, now try to delete it.');
$t->is($dir->fileExists(), true, 'File check with fileExists() is true.');
$t->is($dir->isWritable(), true, 'File check with is Writable() is true');
try {
    $success = $dir->delete();
} catch (Exception $e) {
    $t->diag((string) $e->getMessage());
    $t->diag('Maybe the directory does not exist or is write protected.');
}
$t->is($success, true, "Return-Value of delete() is true, that means the directory was successfully deleted.");