Esempio n. 1
0
 /**
  * Initialize sfymfony propel
  *
  * @param sfEventDispatcher $dispatcher
  * @param string $culture
  */
 public static function initialize(sfEventDispatcher $dispatcher, $culture = null)
 {
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         // add propel logger
         Propel::setLogger(new sfPropelLogger($dispatcher));
     }
     // propel initialization
     $configuration = sfPropelDatabase::getConfiguration();
     if ($configuration) {
         Propel::setConfiguration($configuration);
         if (!Propel::isInit()) {
             Propel::initialize();
         }
     }
     $dispatcher->connect('user.change_culture', array('sfPropel', 'listenToChangeCultureEvent'));
     if (!is_null($culture)) {
         self::setDefaultCulture($culture);
     } else {
         if (class_exists('sfContext', false) && sfContext::hasInstance() && ($user = sfContext::getInstance()->getUser())) {
             self::setDefaultCulture($user->getCulture());
         }
     }
     self::$initialized = true;
 }
Esempio n. 2
0
 * (c) 2007 Rob Rosenbaum <*****@*****.**>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/*
 * The contents of this file came mostly from the following page:
 * http://www.symfony-project.com/snippets/snippet/215
 */
if (!@constant('SF_APP')) {
    die('Constant "SF_APP" must be defined in your test script.' . "\n");
}
if (!@constant('SF_ENVIRONMENT')) {
    // Only load constants in not done before (group tests)
    define('SF_ENVIRONMENT', 'test');
    define('SF_DEBUG', TRUE);
    define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../../..'));
    $_test_dir = SF_ROOT_DIR . '/test';
    // symfony directories
    include SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
    require_once $sf_symfony_lib_dir . '/vendor/lime/lime.php';
    require_once $sf_symfony_lib_dir . '/util/sfCore.class.php';
    require_once dirname(__FILE__) . '/../lib/sfPropelTest.php';
    sfCore::initSimpleAutoload(array(SF_ROOT_DIR . '/lib/model', $sf_symfony_lib_dir, SF_ROOT_DIR . '/lib', SF_ROOT_DIR . '/apps/theApp/lib', SF_ROOT_DIR . '/plugins'));
    // Location plugins
    set_include_path($sf_symfony_lib_dir . '/vendor' . PATH_SEPARATOR . SF_ROOT_DIR . PATH_SEPARATOR . get_include_path());
    sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir);
    sfContext::getInstance();
    Propel::setConfiguration(sfPropelDatabase::getConfiguration());
    Propel::initialize();
}
<?php

// auto-generated by sfDatabaseConfigHandler
// date: 2009/08/15 10:45:03
$database = new sfPropelDatabase();
$database->initialize(array('dsn' => 'pgsql://*****:*****@localhost/coscupdemo'), 'propel');
$this->databases['propel'] = $database;
Esempio n. 4
0
 public function initialize()
 {
     // 'config/databases.yml' config file
     // auto-generated by sfDatabaseConfigHandler
     // date: 2015/09/01 13:56:04
     $database = new sfPropelDatabase();
     $database->initialize(array('phptype' => 'mysql', 'host' => '127.0.0.1', 'database' => 'tm_marks', 'username' => 'root', 'password' => 'root', 'encoding' => 'utf8'), 'propel');
     $this->databases['propel'] = $database;
     $database = new sfPropelDatabase();
     $database->initialize(array('phptype' => 'mysql', 'host' => '127.0.0.1', 'database' => 'tm_marks', 'username' => 'root', 'password' => 'root', 'encoding' => 'utf8'), 'tm_marks');
     $this->databases['tm_marks'] = $database;
 }
<?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 dirname(__FILE__) . '/../../../../bootstrap/unit.php';
set_include_path(sfConfig::get('sf_symfony_lib_dir') . '/vendor' . PATH_SEPARATOR . get_include_path());
$t = new lime_test(4, new lime_output_color());
$p = new sfPropelDatabase();
$configuration = array('propel' => array('datasources' => array('propel' => array('adapter' => 'mysql', 'connection' => array('phptype' => 'mysql', 'hostspec' => 'localhost', 'database' => 'testdb', 'username' => 'foo', 'password' => 'bar', 'port' => null, 'encoding' => 'utf8', 'persistent' => '1', 'protocol' => null)), 'default' => 'propel')));
$parametersTests = array(array('dsn' => 'mysql://*****:*****@localhost/testdb?encoding=utf8&persistent=1'), array('dsn' => 'mysql://*****:*****@localhost/testdb', 'encoding' => 'utf8', 'persistent' => 1), array('phptype' => 'mysql', 'database' => 'testdb', 'encoding' => 'utf8', 'host' => 'localhost', 'username' => 'foo', 'password' => 'bar', 'persistent' => 1), array('phptype' => 'mysql', 'database' => 'testdb', 'encoding' => 'utf8', 'hostspec' => 'localhost', 'username' => 'foo', 'password' => 'bar', 'persistent' => 1));
foreach ($parametersTests as $parameters) {
    $p->initialize($parameters);
    $t->is($p->getConfiguration(), $configuration);
}
Esempio n. 6
0
 public function initialize()
 {
     $database = new sfPropelDatabase();
     $database->initialize(array('phptype' => 'mysql', 'hostspec' => 'localhost', 'database' => 'lekar_bm400', 'username' => 'root', 'password' => NULL, 'persistent' => true, 'port' => 3306), 'propel');
     $this->databases['propel'] = $database;
 }
<?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 dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(1);
class ProjectConfiguration extends sfProjectConfiguration
{
    public function setup()
    {
        $this->enablePlugins('sfPropelORMPlugin');
        sfConfig::set('sf_plugins_dir', sfConfig::get('sf_root_dir') . '/../../../');
    }
}
new ProjectConfiguration();
// ->__construct()
$t->diag('->__construct()');
$configuration = array('propel' => array('datasources' => array('propel' => array('adapter' => 'mysql', 'connection' => array('dsn' => 'mysql:dbname=testdb;host=localhost', 'user' => 'foo', 'password' => 'bar', 'classname' => 'PropelPDO', 'options' => array('ATTR_PERSISTENT' => true, 'ATTR_AUTOCOMMIT' => false), 'settings' => array('charset' => array('value' => 'utf8'), 'queries' => array())), 'slaves' => array()), 'default' => 'propel')));
$parametersTests = array('dsn' => 'mysql:dbname=testdb;host=localhost', 'username' => 'foo', 'password' => 'bar', 'encoding' => 'utf8', 'persistent' => true, 'options' => array('ATTR_AUTOCOMMIT' => false));
$p = new sfPropelDatabase($parametersTests);
$t->is_deeply($p->getConfiguration(), $configuration, '->__construct() creates a valid propel configuration from parameters');
<?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 dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(1);
$configuration = array('propel' => array('datasources' => array('propel' => array('adapter' => 'mysql', 'connection' => array('dsn' => 'mysql:dbname=testdb;host=localhost', 'user' => 'foo', 'password' => 'bar', 'classname' => 'PropelPDO', 'options' => array('ATTR_PERSISTENT' => true, 'ATTR_AUTOCOMMIT' => false), 'settings' => array('charset' => array('value' => 'utf8'), 'queries' => array()))), 'default' => 'propel')));
$parametersTests = array('dsn' => 'mysql:dbname=testdb;host=localhost', 'username' => 'foo', 'password' => 'bar', 'encoding' => 'utf8', 'persistent' => true, 'options' => array('ATTR_AUTOCOMMIT' => false));
$p = new sfPropelDatabase($parametersTests);
$t->is($p->getConfiguration(), $configuration, 'initialize() - creates a valid propel configuration from parameters');
Esempio n. 9
0
<?php

// auto-generated by sfDatabaseConfigHandler
// date: 2015/09/01 13:56:04
$database = new sfPropelDatabase();
$database->initialize(array('phptype' => 'mysql', 'host' => '127.0.0.1', 'database' => 'tm_marks', 'username' => 'root', 'password' => 'root', 'encoding' => 'utf8'), 'propel');
$this->databases['propel'] = $database;
$database = new sfPropelDatabase();
$database->initialize(array('phptype' => 'mysql', 'host' => '127.0.0.1', 'database' => 'tm_marks', 'username' => 'root', 'password' => 'root', 'encoding' => 'utf8'), 'tm_marks');
$this->databases['tm_marks'] = $database;
Esempio n. 10
0
<?php

// auto-generated by sfDatabaseConfigHandler
// date: 2015/12/07 17:49:30
$database = new sfPropelDatabase();
$database->initialize(array('phptype' => 'mysql', 'hostspec' => 'localhost', 'database' => 'lekar_bm400', 'username' => 'root', 'password' => NULL, 'persistent' => true, 'port' => 3306), 'propel');
$this->databases['propel'] = $database;