protected function execute($arguments = array(), $options = array())
 {
     $this->standardBootstrap($arguments['application'], $options['env']);
     $remove = sfLuceneToolkit::getDirtyIndexRemains();
     if (count($remove) == 0) {
         $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->format('Nothing to do!', 'INFO'))));
     } elseif ($arguments['confirmation'] == 'delete') {
         $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->format('Delete confirmation provided.  Deleting directories now...', array('fg' => 'red', 'bold' => true)))));
         foreach ($remove as $dir) {
             sfToolkit::clearDirectory($dir);
             rmdir($dir);
             $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('dir-', $dir))));
         }
     } else {
         $messages = array($this->formatter->format('The following directories are alien and not referenced by your configuration:', 'INFO'));
         for ($c = count($remove), $x = 0; $x < $c; $x++) {
             $messages[] = '  ' . ($x + 1) . ') ' . $remove[$x];
         }
         $messages[] = '';
         $messages[] = 'These directories were ' . $this->formatter->format('not', array('fg' => 'red', 'bold' => true)) . ' deleted.  To delete these directories, please run:';
         $messages[] = '';
         $messages[] = '     ' . $this->formatter->format('symfony lucene:clean ' . $arguments['application'] . ' delete', 'INFO');
         $messages[] = '';
         $this->dispatcher->notify(new sfEvent($this, 'command.log', $messages));
     }
 }
 public function deleteApplication()
 {
     sfToolkit::clearDirectory(sfConfig::get('sf_apps_dir') . '/' . $this->slug);
     rmdir(sfConfig::get('sf_apps_dir') . '/' . $this->slug);
     @unlink(sfConfig::get('sf_web_dir') . '/' . $this->slug . '_dev.php');
     @unlink(sfConfig::get('sf_web_dir') . '/' . $this->slug . '.php');
 }
Example #3
0
function cleanup()
{
    //sfToolkit::clearDirectory(dirname(__FILE__).'/../fixtures/project/cache');
    sfToolkit::clearDirectory(dirname(__FILE__) . '/../fixtures/project/log');
    @unlink(sfConfig::get('sf_data_dir') . '/test.sqlite');
    @unlink(sfConfig::get('sf_config_dir') . '/app.yml');
}
Example #4
0
function task_extra_cleanup()
{
    sfToolkit::clearDirectory(dirname(__FILE__) . '/../fixtures/project/cache');
    sfToolkit::clearDirectory(dirname(__FILE__) . '/../fixtures/project/log');
    sfToolkit::clearDirectory(dirname(__FILE__) . '/../fixtures/project/plugins');
    sfToolkit::clearDirectory(dirname(__FILE__) . '/../fixtures/project/test/unit');
}
Example #5
0
 protected function clearDirectory($dir)
 {
     sfToolkit::clearDirectory($dir);
     if (is_dir($dir)) {
         rmdir($dir);
     }
 }
Example #6
0
function sf_unit_test_shutdown()
{
  $sf_root_dir = sys_get_temp_dir().'/sf_test_project';
  if(is_dir($sf_root_dir))
  {
    sfToolkit::clearDirectory($sf_root_dir);
    @rmdir($sf_root_dir);
  }

  $sessions = glob(sys_get_temp_dir().'/sessions*');
  $tmp_files = glob(sys_get_temp_dir().'/sf*');

  $files = array_merge((empty($sessions) ? array() : $sessions), (empty($tmp_files) ? array() : $tmp_files));
  foreach ($files as $file)
  {
    if(is_dir($file))
    {
      sfToolkit::clearDirectory($file);
      @rmdir($file);
    }
    else
    {
      @unlink($file);
    }
  }
}
 public function customize($params)
 {
     $params['moduleName'] = 'search';
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     $generatorManager = new sfGeneratorManager(sfProjectConfiguration::getActive());
     sfGeneratorConfigHandler::getContent($generatorManager, 'xfGeneratorInterface', $params);
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->logSection('Diem Extended', 'Setup ' . dmProject::getKey());
     $this->dispatcher->notify(new sfEvent($this, 'dm.setup.before', array('clear-db' => $options['clear-db'])));
     // don't use cache:clear task because it changes current app & environment
     @sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir'));
     if (!file_exists(dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineRecord.php'))) {
         $this->getContext()->get('filesystem')->copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data', 'skeleton', 'lib', 'model', 'doctrine', 'myDoctrineRecord.php'), dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineRecord.php'));
     }
     if (!file_exists(dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineQuery.php'))) {
         $this->getContext()->get('filesystem')->copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data', 'skeleton', 'lib', 'model', 'doctrine', 'myDoctrineQuery.php'), dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineQuery.php'));
     }
     if (!file_exists(dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineTable.php'))) {
         $this->getContext()->get('filesystem')->copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data', 'skeleton', 'lib', 'model', 'doctrine', 'myDoctrineTable.php'), dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineTable.php'));
     }
     $this->runTask('doctrine:build', array(), array('model' => true));
     if ($options['clear-db'] || $options['clear-tables'] || $this->isProjectLocked()) {
         $this->reloadAutoload();
         if ($options['clear-db']) {
             $this->runTask('doctrine:drop-db', array(), array('env' => $options['env'], 'no-confirmation' => dmArray::get($options, 'no-confirmation', false)));
         } else {
             $this->runTask('dm:drop-tables', array(), array('env' => $options['env']));
         }
         if ($options['clear-db'] && ($ret = $this->runTask('doctrine:build-db', array(), array('env' => $options['env'])))) {
             return $ret;
         }
         $this->runTask('doctrine:build-sql', array(), array('env' => $options['env']));
         $this->runTask('doctrine:insert-sql', array(), array('env' => $options['env']));
     } else {
         $this->runTask('dm:upgrade', array(), array('env' => $options['env']));
     }
     $this->reloadAutoload();
     $this->withDatabase();
     $this->runTask('dm:clear-cache', array(), array('env' => $options['env']));
     $this->getContext()->reloadModuleManager();
     $this->runTask('doctrine:build-forms', array(), array('generator-class' => 'dmDoctrineFormGenerator'));
     $this->runTask('doctrine:build-filters', array(), array('generator-class' => 'dmDoctrineFormFilterGenerator'));
     $this->runTask('dm:publish-assets');
     $this->runTask('dm:clear-cache', array(), array('env' => $options['env']));
     $this->reloadAutoload();
     $this->getContext()->reloadModuleManager();
     $this->runTask('dmAdmin:generate', array(), array('env' => $options['env']));
     if (!$options['dont-load-data']) {
         $this->runTask('dm:data', array(), array('load-doctrine-data' => $options['load-doctrine-data'], 'env' => $options['env']));
     }
     $this->logSection('Diem Extended', 'generate front modules');
     if (!($return = $this->context->get('filesystem')->sf('dmFront:generate --env=' . dmArray::get($options, 'env', 'dev')))) {
         $this->logBlock(array('Can\'t run dmFront:generate: ' . $this->context->get('filesystem')->getLastExec('output'), 'Please run "php symfony dmFront:generate" manually to generate front templates'), 'ERROR');
     }
     $this->runTask('dm:permissions');
     // fix db file permissions
     if ('Sqlite' === Doctrine_Manager::connection()->getDriverName()) {
         $this->filesystem->chmod(sfConfig::get('sf_data_dir'), 0777, 00);
     }
     $this->runTask('dm:clear-cache', array(), array('env' => $options['env']));
     $this->dispatcher->notify(new sfEvent($this, 'dm.setup.after', array('clear-db' => $options['clear-db'])));
     $this->logBlock('Setup successful', 'INFO_LARGE');
     $this->unlockProject();
 }
Example #9
0
function refresh_assets()
{
    $uploadDir = dirname(__FILE__) . '/../fixtures/project/web/uploads';
    sfToolkit::clearDirectory($uploadDir);
    $finder = new sfFinder();
    $filesystem = new sfFilesystem();
    $filesystem->mirror(dirname(__FILE__) . '/../fixtures/assets', $uploadDir, $finder);
}
 protected function boot()
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($this->options['app'], $this->options['env'], $this->options['debug']);
     $this->context = dm::createContext($configuration);
     sfConfig::set('sf_logging_enabled', false);
     // remove all cache
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
 }
Example #11
0
 public static function doDeleteAll(PropelPDO $con = null)
 {
     if (file_exists($index = self::getLuceneIndexFile())) {
         sfToolkit::clearDirectory($index);
         rmdir($index);
     }
     return parent::doDeleteAll($con);
 }
Example #12
0
function sf_functional_test_shutdown_cleanup()
{
    sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir'));
    sfToolkit::clearDirectory(sfConfig::get('sf_log_dir'));
    $databases = glob(sfConfig::get('sf_data_dir') . '/*.sqlite');
    foreach ($databases as $database) {
        unlink($database);
    }
}
 public static function removeIndex($class)
 {
   $index = self::getLuceneIndexFile($class);
   if ($index && file_exists($index))
   {
     sfToolkit::clearDirectory($index);
     rmdir($index);
   }
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $plugin = $arguments['plugin'];
     $modules = $options['module'];
     // validate the plugin name
     if ('Plugin' != substr($plugin, -6) || !preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $plugin)) {
         throw new sfCommandException(sprintf('The plugin name "%s" is invalid.', $plugin));
     }
     // validate the test application name
     if (!preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $options['test-application'])) {
         throw new sfCommandException(sprintf('The application name "%s" is invalid.', $options['test-application']));
     }
     $this->checkPluginExists($plugin, false);
     if (is_readable(sfConfig::get('sf_data_dir') . '/skeleton/plugin')) {
         $skeletonDir = sfConfig::get('sf_data_dir') . '/skeleton/plugin';
     } else {
         $skeletonDir = dirname(__FILE__) . '/skeleton/plugin';
     }
     $pluginDir = sfConfig::get('sf_plugins_dir') . '/' . $plugin;
     $testProject = $pluginDir . '/test/fixtures/project';
     $testApp = $testProject . '/apps/' . $options['test-application'];
     $properties = parse_ini_file(sfConfig::get('sf_config_dir') . '/properties.ini', true);
     $constants = array('PLUGIN_NAME' => $plugin, 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here', 'APP_NAME' => $options['test-application']);
     // plugin
     $finder = sfFinder::type('any')->discard('.sf');
     $this->getFilesystem()->mirror($skeletonDir . '/plugin', $pluginDir, $finder);
     // PluginConfiguration
     $this->getFilesystem()->rename($pluginDir . '/config/PluginConfiguration.class.php', $pluginDir . '/config/' . $plugin . 'Configuration.class.php');
     // tokens
     $finder = sfFinder::type('file')->name('*.php', '*.yml', 'package.xml.tmpl');
     $this->getFilesystem()->replaceTokens($finder->in($pluginDir), '##', '##', $constants);
     if ($options['skip-test-dir']) {
         sfToolkit::clearDirectory($pluginDir . '/test');
         $this->getFilesystem()->remove($pluginDir . '/test');
     } else {
         // test project and app
         $finder = sfFinder::type('any')->discard('.sf');
         $this->getFilesystem()->mirror(sfConfig::get('sf_symfony_lib_dir') . '/task/generator/skeleton/project', $testProject, $finder);
         $this->getFilesystem()->mirror(sfConfig::get('sf_symfony_lib_dir') . '/task/generator/skeleton/app/app', $testApp, $finder);
         // ProjectConfiguration
         $this->getFilesystem()->copy($skeletonDir . '/project/ProjectConfiguration.class.php', $testProject . '/config/ProjectConfiguration.class.php', array('override' => true));
         $this->getFileSystem()->replaceTokens($testProject . '/config/ProjectConfiguration.class.php', '##', '##', $constants);
         // ApplicationConfiguration
         $this->getFilesystem()->rename($testApp . '/config/ApplicationConfiguration.class.php', $testApp . '/config/' . $options['test-application'] . 'Configuration.class.php');
         $this->getFilesystem()->replaceTokens($testApp . '/config/' . $options['test-application'] . 'Configuration.class.php', '##', '##', $constants);
         // settings.yml
         $this->getFilesystem()->replaceTokens($testApp . '/config/settings.yml', '##', '##', array('NO_SCRIPT_NAME' => 'off', 'CSRF_SECRET' => $plugin, 'ESCAPING_STRATEGY' => 'on'));
     }
     // modules
     foreach ($modules as $module) {
         $moduleTask = new sfGeneratePluginModuleTask($this->dispatcher, $this->formatter);
         $moduleTask->setCommandApplication($this->commandApplication);
         $moduleTask->setConfiguration($this->configuration);
         $moduleTask->run(array($plugin, $module));
     }
 }
 /**
  * Intializes the context for this test
  *
  */
 private function initializeContext()
 {
     // only initialize the context one time
     if (!$this->context) {
         $configuration = ProjectConfiguration::getApplicationConfiguration($this->getApplication(), $this->getEnvironment(), $this->isDebug());
         sfContext::createInstance($configuration);
         // remove all cache
         sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     }
 }
Example #16
0
 public static function checkSymfonyVersion()
 {
     // recent symfony update?
     $last_version = @file_get_contents(sfConfig::get('sf_config_cache_dir') . '/VERSION');
     $current_version = trim(file_get_contents(sfConfig::get('sf_symfony_lib_dir') . '/VERSION'));
     if ($last_version != $current_version) {
         // clear cache
         sfToolkit::clearDirectory(sfConfig::get('sf_config_cache_dir'));
     }
 }
 public function customizeGenerator($params)
 {
     $params['model_class'] = 'Article';
     $params['moduleName'] = $this->moduleName;
     sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir'));
     $generatorManager = new sfGeneratorManager();
     $generatorManager->initialize();
     mkdir(sfConfig::get('sf_config_cache_dir'), 0777);
     file_put_contents(sprintf('%s/modules_%s_config_generator.yml.php', sfConfig::get('sf_config_cache_dir'), $this->moduleName), '<?php ' . $generatorManager->generate('sfPropelAdminGenerator', $params));
     return $this;
 }
 /**
  * Listener for the task.cache.clear event.
  */
 public static function listenToClearCache(sfEvent $event)
 {
     foreach (sfProjectConfiguration::getActive()->getDimension()->getAllowed() as $dimensionName => $dimensions) {
         foreach ($dimensions as $dimension) {
             $sf_cache_dir = sfConfig::get('sf_root_dir') . '/cache/' . $dimension;
             if (is_dir($sf_cache_dir)) {
                 sfToolkit::clearDirectory($sf_cache_dir);
             }
         }
     }
 }
 public function customizeGenerator($params)
 {
     $params['model_class'] = 'Article';
     $params['moduleName'] = $this->moduleName;
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     $generatorManager = new sfGeneratorManager($this->getContext()->getConfiguration());
     if (!is_dir(sfConfig::get('sf_config_cache_dir'))) {
         mkdir(sfConfig::get('sf_config_cache_dir'), 0777);
     }
     file_put_contents(sprintf('%s/modules_%s_config_generator.yml.php', sfConfig::get('sf_config_cache_dir'), $this->moduleName), '<?php ' . sfGeneratorConfigHandler::getContent($generatorManager, 'sfPropelAdminGenerator', $params));
     return $this;
 }
Example #20
0
 public function cleanup()
 {
     foreach (array_diff($this->getPlugins(), $this->plugins) as $dir) {
         sfToolkit::clearDirectory($dir);
         rmdir($dir);
     }
     sfToolkit::clearDirectory(dirname(__FILE__) . '/../../fixtures/project/test/unit');
     foreach (glob(dirname(__FILE__) . '/../../fixtures/project/plugins/*/test/unit/*') as $dir) {
         sfToolkit::clearDirectory($dir);
         rmdir($dir);
     }
 }
Example #21
0
 public function boot($app = 'admin', $env = 'test', $debug = true)
 {
     $rootDir = getcwd();
     // configuration
     require_once $rootDir . '/config/ProjectConfiguration.class.php';
     $this->configuration = ProjectConfiguration::getApplicationConfiguration($app, $env, $debug, $rootDir);
     $this->context = dmContext::createInstance($this->configuration, null, $this->contextClass);
     sfConfig::set('sf_logging_enabled', false);
     // remove all cache
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     $this->cleanup();
     $this->initialize();
     register_shutdown_function(array($this, 'cleanup'));
     return $this;
 }
Example #22
0
 /**
  * SetUp
  */
 public function setUp()
 {
     $dir = getcwd();
     chdir(sfConfig::get('sf_root_dir'));
     // Clear logs
     sfToolkit::clearDirectory(sfConfig::get('sf_log_dir'));
     // Remove cache
     sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir'));
     // Rebuild DB
     $task = new sfDoctrineBuildTask(new sfEventDispatcher(), new sfFormatter());
     $task->run($args = array(), $options = array('env' => 'test', 'no-confirmation' => true, 'db' => true, 'and-migrate' => true, 'application' => 'frontend'));
     // Таск создает свой конфиг, после чего в изоляции может молча умереть
     ProjectConfiguration::getApplicationConfiguration('frontend', 'test', $debug = true);
     chdir($dir);
 }
 /**
  * setUp method for PHPUnit
  *
  */
 protected function setUp()
 {
     // Here we have to initialize the according context for the test case.
     // As this initialization is quite expensive, the script tries to
     // to do this as rare as possible.
     // Testing different applications needs "switching" the context,
     // this is to be checked here, too.
     $app = $this->getApplication();
     $oldApp = null;
     if (!sfContext::hasInstance($app)) {
         // is another app already loaded?
         if (sfContext::hasInstance()) {
             // mark the name of this known instance
             $oldApp = sfContext::getInstance()->getConfiguration()->getApplication();
         }
     } else {
         $oldApp = $app;
     }
     $needNewInstance = $app != $oldApp;
     // Switching the context does not work as expected.
     // When a different context instance is known at this point
     // it is destroyed first.
     // This mechanism does not guarantee a complete switch
     // of the context.
     // All loaded classes can not be unloaded and there will
     // occure class conflicts (e.g the myUser class) anyway.
     // Therefore functional tests for several applications have to be run
     // with activated process-isolation!
     if ($oldApp && $needNewInstance) {
         $oldInstance = sfContext::getInstance($oldApp);
         $oldInstance->shutdown();
         $this->context = null;
     }
     if ($needNewInstance) {
         $configuration = $this->getApplicationConfiguration();
         sfContext::createInstance($this->getApplicationConfiguration(), $app);
         sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
         // We have to create a configuration first before the symfony lib is defined.
         // this is the only but ugly chance for including the lime lib correctly
         // without creating a project configuration instance somewhere before
         require_once $configuration->getSymfonyLibDir() . '/vendor/lime/lime.php';
     }
     // autoloading ready, continue
     $browser = sfConfig::get('app_sf_php_unit_2_plugin_class_browser', 'sfBrowser');
     $tester = sfConfig::get('app_sf_php_unit_2_plugin_class_functional', 'sfTestFunctional');
     $this->testBrowser = new $tester(new $browser(), $this->getTest());
     $this->_start();
 }
 /**
  * Customizes the generator configuration
  *
  * @param $params
  */
 public function customizeGenerator(array $params)
 {
     if (!isset($params['index_class'])) {
         $params['index_class'] = 'TestSearch';
     }
     $params['moduleName'] = 'search';
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     $generatorManager = new sfGeneratorManager($this->getContext()->getConfiguration());
     if (!is_dir(sfConfig::get('sf_config_cache_dir'))) {
         mkdir(sfConfig::get('sf_config_cache_dir'), 0777);
     }
     $filename = sprintf('%s/modules_%s_config_generator.yml.php', sfConfig::get('sf_config_cache_dir'), $params['moduleName']);
     $content = '<?php ' . sfGeneratorConfigHandler::getContent($generatorManager, 'xfGeneratorInterface', $params);
     file_put_contents($filename, $content);
     return $this;
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     require_once dirname(__FILE__) . '/../../vendor/lime/lime.php';
     require_once dirname(__FILE__) . '/lime_symfony.php';
     // cleanup
     require_once dirname(__FILE__) . '/../../util/sfToolkit.class.php';
     if ($files = glob(sys_get_temp_dir() . DIRECTORY_SEPARATOR . '/sf_autoload_unit_*')) {
         foreach ($files as $file) {
             unlink($file);
         }
     }
     // update sfCoreAutoload
     if ($options['update-autoloader']) {
         require_once dirname(__FILE__) . '/../../autoload/sfCoreAutoload.class.php';
         sfCoreAutoload::make();
     }
     $status = false;
     $statusFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sprintf('/.test_symfony_%s_status', md5(dirname(__FILE__)));
     if ($options['only-failed']) {
         if (file_exists($statusFile)) {
             $status = unserialize(file_get_contents($statusFile));
         }
     }
     $h = new lime_symfony(array('force_colors' => $options['color'], 'verbose' => $options['trace']));
     $h->base_dir = realpath(dirname(__FILE__) . '/../../../test');
     // remove generated files
     if ($options['rebuild-all']) {
         $finder = sfFinder::type('dir')->name(array('base', 'om', 'map'));
         foreach ($finder->in(glob($h->base_dir . '/../lib/plugins/*/test/functional/fixtures/lib')) as $dir) {
             sfToolkit::clearDirectory($dir);
         }
     }
     if ($status) {
         foreach ($status as $file) {
             $h->register($file);
         }
     } else {
         $h->register(sfFinder::type('file')->prune('fixtures')->name('*Test.php')->in(array_merge(array($h->base_dir . '/unit'), glob($h->base_dir . '/../lib/plugins/*/test/unit'), array($h->base_dir . '/functional'), glob($h->base_dir . '/../lib/plugins/*/test/functional'), array($h->base_dir . '/other'))));
     }
     $ret = $h->run() ? 0 : 1;
     file_put_contents($statusFile, serialize($h->get_failed_files()));
     if ($options['xml']) {
         file_put_contents($options['xml'], $h->to_xml());
     }
     return $ret;
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     if (!$options['no-confirmation'] && !$this->askConfirmation(array(sprintf('You are about to delete the site named "%s"', $arguments['application']), 'Are you sure you want to proceed? (y/N)'), 'QUESTION_LARGE', false)) {
         $this->logSection('sympal', 'Delete site task aborted');
         return 1;
     }
     $databaseManager = new sfDatabaseManager($this->configuration);
     $site = Doctrine_Core::getTable('sfSympalSite')->findOneBySlug($arguments['application']);
     if ($site) {
         $this->logSection('sympal', sprintf('Deleting site named "%s" from database...', $site->title));
         $site->delete();
     }
     if (isset($options['and-app']) && $options['and-app']) {
         $this->logSection('sympal', sprintf('Deleting Symfony application named "%s"...', $arguments['application']));
         sfToolkit::clearDirectory(sfConfig::get('sf_apps_dir') . '/' . $arguments['application']);
         rmdir(sfConfig::get('sf_apps_dir') . '/' . $arguments['application']);
         @unlink(sfConfig::get('sf_web_dir') . '/' . $arguments['application'] . '_dev.php');
         @unlink(sfConfig::get('sf_web_dir') . '/' . $arguments['application'] . '.php');
     }
 }
Example #27
0
function sf_functional_test_shutdown_cleanup()
{
    sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir'));
    sfToolkit::clearDirectory(sfConfig::get('sf_log_dir'));
    $sf_root_dir = sys_get_temp_dir() . '/sf_test_project';
    if (is_dir($sf_root_dir)) {
        sfToolkit::clearDirectory($sf_root_dir);
        @rmdir($sf_root_dir);
    }
    $sessions = glob(sys_get_temp_dir() . '/sessions*');
    $tmp_files = glob(sys_get_temp_dir() . '/sf*');
    $files = array_merge(empty($sessions) ? array() : $sessions, empty($tmp_files) ? array() : $tmp_files);
    foreach ($files as $file) {
        if (is_dir($file)) {
            sfToolkit::clearDirectory($file);
            @rmdir($file);
        } else {
            @unlink($file);
        }
    }
}
Example #28
0
 public function launch()
 {
     $b = $this;
     // default page is in cache (without layout)
     $b->get('/')->isStatusCode(200)->isRequestParameter('module', 'default')->isRequestParameter('action', 'index')->checkResponseElement('body', '/congratulations/i')->isCached(true);
     $b->get('/nocache')->isStatusCode(200)->isRequestParameter('module', 'nocache')->isRequestParameter('action', 'index')->checkResponseElement('body', '/nocache/i')->isCached(false);
     $b->get('/cache/page')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'page')->checkResponseElement('body', '/page in cache/')->isCached(true, true);
     $b->get('/cache/forward')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'forward')->checkResponseElement('body', '/page in cache/')->isCached(true);
     // remove all cache
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     $b->getMultiAction()->getMultiAction('requestParam')->checkResponseElement('#cacheableComponent .cacheableComponent__componentParam_')->checkResponseElement('#cacheableComponentVarParam .cacheableComponent_varParam_componentParam_')->checkResponseElement('#cacheablePartial .cacheablePartial__')->checkResponseElement('#cacheablePartialVarParam .cacheablePartial_varParam_');
     // remove all cache
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     $b->getMultiAction('requestParam')->checkResponseElement('#cacheableComponent .cacheableComponent__componentParam_requestParam')->checkResponseElement('#cacheableComponentVarParam .cacheableComponent_varParam_componentParam_requestParam')->checkResponseElement('#cacheablePartial .cacheablePartial__requestParam')->checkResponseElement('#cacheablePartialVarParam .cacheablePartial_varParam_requestParam')->getMultiAction()->checkResponseElement('#cacheableComponent .cacheableComponent__componentParam_requestParam')->checkResponseElement('#cacheableComponentVarParam .cacheableComponent_varParam_componentParam_requestParam')->checkResponseElement('#cacheablePartial .cacheablePartial__requestParam')->checkResponseElement('#cacheablePartialVarParam .cacheablePartial_varParam_requestParam')->getMultiAction('anotherRequestParam')->checkResponseElement('#cacheableComponent .cacheableComponent__componentParam_requestParam')->checkResponseElement('#cacheableComponentVarParam .cacheableComponent_varParam_componentParam_requestParam')->checkResponseElement('#cacheablePartial .cacheablePartial__requestParam')->checkResponseElement('#cacheablePartialVarParam .cacheablePartial_varParam_requestParam');
     // check contextual cache with another action
     $b->get('/cache/multiBis')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'multiBis')->isCached(false)->checkResponseElement('#cacheablePartial .cacheablePartial__requestParam')->checkResponseElement('#contextualCacheablePartial .contextualCacheablePartial__')->checkResponseElement('#cacheableComponent .cacheableComponent__componentParam_requestParam')->checkResponseElement('#contextualCacheableComponent .contextualCacheableComponent__componentParam_')->isUriCached('@sf_cache_partial?module=cache&action=_cacheablePartial&sf_cache_key=' . md5(serialize(array())), true)->isUriCached('@sf_cache_partial?module=cache&action=_contextualCacheableComponent&sf_cache_key=' . md5(serialize(array())), true)->isUriCached('@sf_cache_partial?module=cache&action=_cacheableComponent&sf_cache_key=' . md5(serialize(array())), true)->isUriCached('@sf_cache_partial?module=cache&action=_contextualCacheableComponent&sf_cache_key=' . md5(serialize(array())), true);
     // remove all cache
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     // check user supplied cache key for partials and components
     $b->get('/cache/specificCacheKey')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'specificCacheKey')->isCached(false)->isUriCached('@sf_cache_partial?module=cache&action=_cacheablePartial&sf_cache_key=cacheablePartial', true)->isUriCached('@sf_cache_partial?module=cache&action=_contextualCacheableComponent&sf_cache_key=contextualCacheableComponent', true)->isUriCached('@sf_cache_partial?module=cache&action=_cacheableComponent&sf_cache_key=cacheableComponent', true)->isUriCached('@sf_cache_partial?module=cache&action=_contextualCacheableComponent&sf_cache_key=contextualCacheableComponent', true);
     // check cache content for actions
     // remove all cache
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     $b->get('/cache/action')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'action')->isCached(true);
     $b->test()->is(sfConfig::get('ACTION_EXECUTED', false), true, 'action is executed when not in cache');
     sfConfig::set('ACTION_EXECUTED', false);
     $response = $b->getResponse();
     $content1 = $response->getContent();
     $contentType1 = $response->getContentType();
     $headers1 = $response->getHttpHeaders();
     $b->get('/cache/action')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'action')->isCached(true);
     $b->test()->is(sfConfig::get('ACTION_EXECUTED', false), false, 'action is not executed when in cache');
     $response = $b->getResponse();
     $content2 = $response->getContent();
     $contentType2 = $response->getContentType();
     $headers2 = $response->getHttpHeaders();
     $b->test()->is($content1, $content2, 'response content is the same');
     $b->test()->is($contentType1, $contentType2, 'response content type is the same');
     $b->test()->is($headers1, $headers2, 'response http headers are the same');
 }
Example #29
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once __DIR__ . '/../../bootstrap/unit.php';
require_once __DIR__ . '/sfCacheDriverTests.class.php';
$t = new lime_test(65);
// setup
sfConfig::set('sf_logging_enabled', false);
$temp = tempnam('/tmp/cache_dir', 'tmp');
unlink($temp);
mkdir($temp);
// ->initialize()
$t->diag('->initialize()');
try {
    $cache = new sfFileCache();
    $t->fail('->initialize() throws an sfInitializationException exception if you don\'t pass a "cache_dir" parameter');
} catch (sfInitializationException $e) {
    $t->pass('->initialize() throws an sfInitializationException exception if you don\'t pass a "cache_dir" parameter');
}
$cache = new sfFileCache(array('cache_dir' => $temp));
sfCacheDriverTests::launch($t, $cache);
// teardown
sfToolkit::clearDirectory($temp);
rmdir($temp);
 public function teardown()
 {
     sfToolkit::clearDirectory(dirname(__FILE__) . '/../data/project/cache');
     sfToolkit::clearDirectory(dirname(__FILE__) . '/../data/project/log');
 }