本文整理汇总了PHP中sfToolkit::getTmpDir方法的典型用法代码示例。如果您正苦于以下问题:PHP sfToolkit::getTmpDir方法的具体用法?PHP sfToolkit::getTmpDir怎么用?PHP sfToolkit::getTmpDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfToolkit
的用法示例。
在下文中一共展示了sfToolkit::getTmpDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: autoload
/**
* Autoloads symfony
* Note: This is not compatible with ->bootstrap()
* Code adopted from command/sfSymfonyCommandApplication.class.php
*/
public function autoload()
{
if ($this->autoload) {
return;
}
$this->autoload = 'simple';
require_once $this->sf_lib_dir . '/util/sfCore.class.php';
require_once $this->sf_lib_dir . '/config/sfConfig.class.php';
require_once $this->sf_lib_dir . '/util/sfSimpleAutoload.class.php';
require_once $this->sf_lib_dir . '/util/sfToolkit.class.php';
require_once $this->sf_lib_dir . '/util/sfFinder.class.php';
sfConfig::add(array('sf_symfony_lib_dir' => $this->sf_lib_dir, 'sf_symfony_data_dir' => $this->sf_lib_dir));
// directory layout
sfCore::initDirectoryLayout($this->sf_lib_dir);
// include path
set_include_path(sfConfig::get('sf_lib_dir') . PATH_SEPARATOR . sfConfig::get('sf_app_lib_dir') . PATH_SEPARATOR . sfConfig::get('sf_model_dir') . PATH_SEPARATOR . get_include_path());
$cache = sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . sprintf('limeade_autoload_%s.data', md5(__FILE__));
$autoloader = sfSimpleAutoload::getInstance($cache);
$autoloader->register();
$finder = sfFinder::type('file')->ignore_version_control()->prune('test')->prune('vendor')->name('*.php');
$autoloader->addFiles($finder->in(sfConfig::get('sf_symfony_lib_dir')));
$autoloader->addFiles($finder->in($this->project_root));
$autoloader->addDirectory(sfConfig::get('sf_root_dir') . '/plugins');
return $this;
}
示例2: initialize
public function initialize($t)
{
$this->t = $t;
$this->tmp_dir = sfToolkit::getTmpDir() . DS . 'sf_test_project';
if (is_dir($this->tmp_dir)) {
$this->clearTmpDir();
rmdir($this->tmp_dir);
}
mkdir($this->tmp_dir, 0777);
$this->current_dir = getcwd();
chdir($this->tmp_dir);
$this->php_cli = sfToolkit::getPhpCli();
}
示例3: getInstance
public static function getInstance($factories = array(), $force = false)
{
if (!isset(self::$instance) || $force) {
self::$instance = new sfContext();
self::$instance->sessionPath = sfToolkit::getTmpDir() . '/sessions_' . rand(11111, 99999);
self::$instance->storage = new sfSessionTestStorage(array('session_path' => self::$instance->sessionPath));
self::$instance->dispatcher = new sfEventDispatcher();
foreach ($factories as $type => $class) {
self::$instance->inject($type, $class);
}
}
return self::$instance;
}
示例4: initialize
public function initialize($t)
{
$this->t = $t;
$this->tmp_dir = sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . 'symfony_cmd';
if (is_dir($this->tmp_dir)) {
$this->clearTmpDir();
rmdir($this->tmp_dir);
}
mkdir($this->tmp_dir, 0777);
$this->current_dir = getcwd();
chdir($this->tmp_dir);
$this->php_cli = sfToolkit::getPhpCli();
}
示例5: sf_unit_test_shutdown
function sf_unit_test_shutdown()
{
$sf_root_dir = sfToolkit::getTmpDir() . '/sf_test_project';
if (is_dir($sf_root_dir)) {
sfToolkit::clearDirectory($sf_root_dir);
@rmdir($sf_root_dir);
}
$sessions = glob(sfToolkit::getTmpDir() . '/sessions*');
$tmp_files = glob(sfToolkit::getTmpDir() . '/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);
}
}
}
示例6: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
if (!$options['no-confirmation'] && !$this->askConfirmation(array('This command will remove all data in your database.', 'Are you sure you want to proceed? (y/N)'), null, false)) {
$this->logSection('propel', 'Task aborted.');
return 1;
}
$this->schemaToXML(self::DO_NOT_CHECK_SCHEMA, 'generated-');
$this->copyXmlSchemaFromPlugins('generated-');
$databaseManager = new sfDatabaseManager($this->configuration);
$properties = $this->getProperties(sfConfig::get('sf_data_dir') . '/sql/sqldb.map');
$sqls = array();
foreach ($properties as $file => $connection) {
if (!is_null($options['connection']) && $options['connection'] != $connection) {
continue;
}
if (!isset($sqls[$connection])) {
$sqls[$connection] = array();
}
$sqls[$connection][] = $file;
}
$this->tmpDir = sfToolkit::getTmpDir() . '/propel_insert_sql_' . rand(11111, 99999);
register_shutdown_function(array($this, 'removeTmpDir'));
mkdir($this->tmpDir, 0777, true);
foreach ($sqls as $connection => $files) {
$dir = $this->tmpDir . '/' . $connection;
mkdir($dir, 0777, true);
$content = '';
foreach ($files as $file) {
$content .= "{$file}={$connection}\n";
copy(sfConfig::get('sf_data_dir') . '/sql/' . $file, $dir . '/' . $file);
}
file_put_contents($dir . '/sqldb.map', $content);
$properties = $this->getPhingPropertiesForConnection($databaseManager, $connection);
$properties['propel.sql.dir'] = $dir;
$ret = $this->callPhing('insert-sql', self::CHECK_SCHEMA, $properties);
}
$this->removeTmpDir();
$this->cleanup();
return !$ret;
}
示例7: dirname
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(47, new lime_output_color());
class MySessionStorage extends sfSessionTestStorage
{
public function regenerate($destroy = false)
{
$this->sessionId = rand(1, 9999);
return true;
}
}
$dispatcher = new sfEventDispatcher();
$sessionPath = sfToolkit::getTmpDir() . '/sessions_' . rand(11111, 99999);
$storage = new MySessionStorage(array('session_path' => $sessionPath));
$user = new sfBasicSecurityUser($dispatcher, $storage);
// ->initialize()
$t->diag('->initialize()');
$t->todo('->initialize() times out the user if no request made for a long time');
// ->listCredentials()
$t->diag('->listCredentials()');
$user->clearCredentials();
$user->addCredential('user');
$t->is($user->listCredentials(), array('user'), '->listCredentials() returns user credentials as an array');
// ->setAuthenticated() ->isAuthenticated()
$t->diag('->setAuthenticated() ->isAuthenticated()');
$t->is($user->isAuthenticated(), false, '->isAuthenticated() returns false by default');
$user->setAuthenticated(true);
$t->is($user->isAuthenticated(), true, '->isAuthenticated() returns true if the user is authenticated');
示例8: dirname
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . '/unit.php';
require_once sfConfig::get('sf_symfony_lib_dir') . '/command/sfCommandApplication.class.php';
require_once sfConfig::get('sf_symfony_lib_dir') . '/command/sfSymfonyCommandApplication.class.php';
$tmpDir = sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . 'sf_' . rand(11111, 99999);
mkdir($tmpDir, 0777, true);
chdir($tmpDir);
$application = new sfSymfonyCommandApplication(new sfEventDispatcher(), new sfFormatter(), array('symfony_lib_dir' => sfConfig::get('sf_symfony_lib_dir')));
register_shutdown_function('sf_shutdown_task_test');
function sf_shutdown_task_test()
{
global $tmpDir;
sfToolkit::clearDirectory($tmpDir);
rmdir($tmpDir);
}
示例9: dirname
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(29, new lime_output_color());
class ProjectConfiguration extends sfProjectConfiguration
{
}
class TestConfiguration extends sfApplicationConfiguration
{
public function getI18NGlobalDirs()
{
return array(dirname(__FILE__) . '/fixtures');
}
}
$configuration = new TestConfiguration('test', true, sfConfig::get('sf_test_cache_dir', sfToolkit::getTmpDir()));
$dispatcher = $configuration->getEventDispatcher();
$cache = new sfNoCache();
// ->initialize()
$t->diag('->initialize()');
$i18n = new sfI18N($configuration, $cache);
$dispatcher->notify(new sfEvent(null, 'user.change_culture', array('culture' => 'fr')));
$t->is($i18n->getCulture(), 'fr', '->initialize() connects to the user.change_culture event');
// ->getCulture() ->setCulture()
$t->diag('->getCulture() ->setCulture()');
$i18n = new sfI18N($configuration, $cache);
$t->is($i18n->getCulture(), 'en', '->getCulture() returns the current culture');
$i18n->setCulture('fr');
$t->is($i18n->getCulture(), 'fr', '->setCulture() sets the current culture');
// ->__()
$t->diag('->__()');
示例10: addslashes
$t->is(sfToolkit::stripslashesDeep(array(array('foo' => addslashes("foo's bar")), addslashes("foo's bar"))), array(array('foo' => "foo's bar"), "foo's bar"), '::stripslashesDeep() strip slashes on deep arrays');
// ::clearDirectory()
$t->diag('::clearDirectory()');
$tmp_dir = sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . 'symfony_tests_' . rand(1, 999);
mkdir($tmp_dir);
file_put_contents($tmp_dir . DIRECTORY_SEPARATOR . 'test', 'ok');
mkdir($tmp_dir . DIRECTORY_SEPARATOR . 'foo');
file_put_contents($tmp_dir . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'bar', 'ok');
sfToolkit::clearDirectory($tmp_dir);
$t->ok(!is_dir($tmp_dir . DIRECTORY_SEPARATOR . 'foo'), '::clearDirectory() removes all directories from the directory parameter');
$t->ok(!is_file($tmp_dir . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'bar'), '::clearDirectory() removes all directories from the directory parameter');
$t->ok(!is_file($tmp_dir . DIRECTORY_SEPARATOR . 'test'), '::clearDirectory() removes all directories from the directory parameter');
rmdir($tmp_dir);
// ::clearGlob()
$t->diag('::clearGlob()');
$tmp_dir = sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . 'symfony_tests_' . rand(1, 999);
mkdir($tmp_dir);
mkdir($tmp_dir . DIRECTORY_SEPARATOR . 'foo');
mkdir($tmp_dir . DIRECTORY_SEPARATOR . 'bar');
file_put_contents($tmp_dir . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'bar', 'ok');
file_put_contents($tmp_dir . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'foo', 'ok');
file_put_contents($tmp_dir . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR . 'bar', 'ok');
sfToolkit::clearGlob($tmp_dir . '/*/bar');
$t->ok(!is_file($tmp_dir . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'bar'), '::clearGlob() removes all files and directories matching the pattern parameter');
$t->ok(!is_file($tmp_dir . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'bar'), '::clearGlob() removes all files and directories matching the pattern parameter');
$t->ok(is_file($tmp_dir . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'foo'), '::clearGlob() removes all files and directories matching the pattern parameter');
sfToolkit::clearDirectory($tmp_dir);
rmdir($tmp_dir);
// ::arrayDeepMerge()
$t->diag('::arrayDeepMerge()');
$t->is(sfToolkit::arrayDeepMerge(array('d' => 'due', 't' => 'tre'), array('d' => 'bis', 'q' => 'quattro')), array('d' => 'bis', 't' => 'tre', 'q' => 'quattro'), '::arrayDeepMerge() merges linear arrays preserving literal keys');
示例11: dirname
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . '/../../../../../test/bootstrap/unit.php';
require_once dirname(__FILE__) . '/../../../../autoload/sfSimpleAutoload.class.php';
$autoload = sfSimpleAutoload::getInstance(sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . sprintf('sf_autoload_unit_propel_%s.data', md5(__FILE__)));
$autoload->addDirectory(realpath(dirname(__FILE__) . '/../../lib'));
$autoload->register();
$_test_dir = realpath(dirname(__FILE__) . '/..');
示例12: getRequest
public function getRequest()
{
return $this->request;
}
public function getUser()
{
return $this->user;
}
public function getStorage()
{
return $this->storage;
}
}
$t = new lime_test(33, new lime_output_color());
$_SERVER['session_id'] = 'test';
sfConfig::set('sf_test_cache_dir', sfToolkit::getTmpDir());
$context = new sfContext();
$request = new sfWebRequest();
$request->initialize($context);
$context->request = $request;
$storage = sfStorage::newInstance('sfSessionTestStorage');
$storage->initialize($context);
$storage->clear();
$context->storage = $storage;
$user = new sfUser();
$user->initialize($context);
$context->user = $user;
// ->initialize()
$t->diag('->initialize()');
$t->is($user->getCulture(), 'en', '->initialize() sets the culture to "en" by default');
sfConfig::set('sf_i18n_default_culture', 'de');
示例13: removeCache
public static function removeCache()
{
unlink(sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . 'sf_autoload_paths.php');
}
示例14: dirname
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(69, new lime_output_color());
$tmpDir = sfToolkit::getTmpDir();
$content = 'This is an ASCII file.';
file_put_contents($tmpDir . '/test.txt', $content);
class testValidatorFile extends sfValidatorFile
{
public function getMimeType($file, $fallback)
{
return parent::getMimeType($file, $fallback);
}
public function guessFromNothing($file)
{
return 'nothing/plain';
}
public function guessFromFileinfo($file)
{
return parent::guessFromFileinfo($file);
}
public function guessFromMimeContentType($file)
{
return parent::guessFromMimeContentType($file);
示例15: dirname
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . '/../../lib/vendor/lime/lime.php';
class lime_symfony extends lime_harness
{
protected function get_relative_file($file)
{
$file = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(array(realpath($this->base_dir) . DIRECTORY_SEPARATOR, realpath($this->base_dir . '/../lib/plugins') . DIRECTORY_SEPARATOR, $this->extension), '', $file));
return preg_replace('#^(.*?)Plugin/test/(unit|functional)/#', '[$1] $2/', $file);
}
}
require_once dirname(__FILE__) . '/../../lib/util/sfToolkit.class.php';
if ($files = glob(sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . '/sf_autoload_unit_*')) {
foreach ($files as $file) {
unlink($file);
}
}
// update sfCoreAutoload
require_once dirname(__FILE__) . '/../../lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::make();
$h = new lime_symfony(new lime_output_color());
$h->base_dir = realpath(dirname(__FILE__) . '/..');
$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'))));
exit($h->run() ? 0 : 1);