예제 #1
0
파일: init.php 프로젝트: helix/spot2
# Include path
$GLOBALS['cfg']['include_path'][] = get_include_path();
set_include_path(join(PATH_SEPARATOR, $GLOBALS['cfg']['include_path']));
// Require PHPUnit
require_once 'PHPUnit/Framework.php';
// Require Spot_Config
require_once 'Spot/Config.php';
// Date setup
date_default_timezone_set('America/Chicago');
/**
 * Setup available adapters for testing
 */
$spotConfig = new Spot_Config();
// MySQL
$cnf =& $GLOBALS['cfg']['adapter']['mysql'];
$adapter = $spotConfig->addConnection('test_mysql', sprintf('mysql://%s:%s@%s/%s', $cnf['user'], $cnf['pass'], $cnf['host'], $cnf['db']));
// MongoDB with adapter options
$cnf =& $GLOBALS['cfg']['adapter']['mongodb'];
$adapter = $spotConfig->addConnection('test_mongodb', sprintf('mongodb://%s:%s', $cnf['host'], $cnf['port']), array('cursor' => array('timeout' => 10), 'mapper' => array('translate_id' => true)));
/**
 * Return Spot mapper for use
 */
$mapper = new Spot_Mapper($spotConfig);
function test_spot_mapper()
{
    global $mapper;
    return $mapper;
}
/**
 * Autoload test fixtures
 */
예제 #2
0
파일: Config.php 프로젝트: helix/spot2
 public function testAddConnectionWithDSNString()
 {
     $cfg = new Spot_Config();
     $adapter = $cfg->addConnection('test_mysql', 'mysql://*****:*****@localhost/test');
     $this->assertTrue($adapter instanceof Spot_Adapter_Mysql);
 }