本文整理汇总了PHP中lithium\data\Connections::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Connections::add方法的具体用法?PHP Connections::add怎么用?PHP Connections::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\data\Connections
的用法示例。
在下文中一共展示了Connections::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->_handlers = array('id' => function ($v) {
return is_string($v) && preg_match('/^[0-9a-f]{24}$/', $v) ? new MongoId($v) : $v;
}, 'date' => function ($v) {
$v = is_numeric($v) ? (int) $v : strtotime($v);
return !$v ? new MongoDate() : new MongoDate($v);
}, 'regex' => function ($v) {
return new MongoRegex($v);
}, 'integer' => function ($v) {
return (int) $v;
}, 'float' => function ($v) {
return (double) $v;
}, 'boolean' => function ($v) {
return (bool) $v;
}, 'code' => function ($v) {
return new MongoCode($v);
}, 'binary' => function ($v) {
return new MongoBinData($v);
});
$model = $this->_model;
Connections::add('mockconn', array('object' => new MongoDb(array('autoConnect' => false))));
$model::config(array('meta' => array('connection' => 'mockconn')));
$model::schema(false);
$model::schema($this->_schema);
}
示例2: testStreamConnection
public function testStreamConnection()
{
$config = array('socket' => 'Stream', 'host' => 'localhost', 'login' => 'root', 'password' => '', 'port' => '80');
Connections::add('stream-test', 'Http', $config);
$result = Connections::get('stream-test');
$this->assertTrue($result instanceof \lithium\data\source\Http);
}
示例3: setUp
public function setUp()
{
Connections::add('mockconn', array('object' => new MockSource()));
$schema = new Schema(array('fields' => array('id' => 'int', 'title' => 'string', 'body' => 'text')));
MockPost::config(array('meta' => array('connection' => 'mockconn', 'key' => 'id', 'locked' => true), 'schema' => $schema));
$this->_record = new Record(array('model' => 'lithium\\tests\\mocks\\data\\MockPost'));
}
示例4: setUp
public function setUp()
{
$this->_db = new MockDatabase();
Connections::add('mockconn', array('object' => $this->_db));
MockGallery::config(array('meta' => array('connection' => 'mockconn')));
MockImage::config(array('meta' => array('connection' => 'mockconn')));
}
示例5: tearDown
/**
* Teardown method run after every test method.
*/
public function tearDown()
{
Connections::reset();
foreach ($this->_backup as $name => $config) {
Connections::add($name, $config);
}
}
示例6: setUp
public function setUp()
{
Connections::add('test-gh', array('type' => 'http', 'adapter' => 'GitHub', 'login' => '', 'password' => '', 'socket' => 'li3_github\\tests\\mocks\\MockGitHubSocket'));
Issues::config(array('connection' => 'test-gh'));
Repos::config(array('connection' => 'test-gh'));
Users::config(array('connection' => 'test-gh'));
Orgs::config(array('connection' => 'test-gh'));
}
示例7: testConnectWithWrongPassword
public function testConnectWithWrongPassword()
{
$config = $this->_dbConfig;
$config['login'] = 'wrong_login';
$config['password'] = 'wrong_pass';
$connection = 'wrong_passord';
Connections::add($connection, $config);
$this->expectException('/Host connected, but could not access database/');
Connections::get($connection)->connect();
}
示例8: setUp
public function setUp()
{
$this->_backup['cwd'] = getcwd();
$this->_backup['_SERVER'] = $_SERVER;
$_SERVER['argv'] = array();
Libraries::add('create_test', array('path' => $this->_testPath . '/create_test'));
$this->request = new Request(array('input' => fopen('php://temp', 'w+')));
$this->request->params = array('library' => 'create_test', 'action' => null);
Connections::add('default', array('type' => null, 'adapter' => 'lithium\\tests\\mocks\\data\\model\\MockDatabase'));
}
示例9: add
/**
* 添加数据库链接
* @param string $name 名称
* @param array $config 配置
* @param bool $overwrite 是否覆盖已有配置,默认否
* @return array
*/
public static function add($name, array $config = array(), $overwrite = false)
{
if ($overwrite) {
parent::add($name, $config);
} else {
if (!isset(static::$_configurations[$name])) {
parent::add($name, $config);
}
}
return static::$_configurations[$name];
}
示例10: setUp
public function setUp()
{
$this->_db = new CouchDb(array('socket' => false));
$model = $this->_model;
Connections::add('mockconn', array('object' => $this->_db));
$model::config(array('meta' => array('connection' => 'mockconn')));
$model::resetSchema();
$entity = new Document(compact('model'));
$type = 'create';
$this->_query = new Query(compact('model', 'entity', 'type'));
}
示例11: testConnectWithWrongPassword
public function testConnectWithWrongPassword()
{
$this->skipIf(!$this->with('PostgreSql'));
$config = $this->_dbConfig;
$config['login'] = 'wrong_login';
$config['password'] = 'wrong_pass';
$config['object'] = null;
$connection = 'wrong_passord';
Connections::add($connection, $config);
$this->expectException();
Connections::get($connection)->connect();
}
示例12: setUp
public function setUp()
{
$this->_db = new MockDatabase();
Connections::add('mockconn', array('object' => $this->_db));
$config = array('meta' => array('connection' => 'mockconn'));
MockQueryPost::config($config);
MockQueryComment::config($config);
MockGallery::config($config);
MockImage::config($config);
MockImageTag::config($config);
MockTag::config($config);
}
示例13: testErrorExceptions
public function testErrorExceptions()
{
$config = array('adapter' => 'None', 'type' => 'Error');
Connections::add('NoConnection', $config);
$result = false;
try {
Connections::get('NoConnection');
} catch (Exception $e) {
$result = true;
}
$this->assertTrue($result, 'Exception is not thrown');
}
示例14: setUp
public function setUp()
{
Connections::add('mocksource', array('object' => new MockSource()));
Connections::add('mockconn', array('object' => new MockDatabase()));
MockPost::config(array('meta' => array('connection' => 'mocksource')));
MockTag::config(array('meta' => array('connection' => 'mocksource')));
MockComment::config(array('meta' => array('connection' => 'mocksource')));
MockCreator::config(array('meta' => array('connection' => 'mocksource')));
MockSubProduct::config(array('meta' => array('connection' => 'mockconn')));
MockProduct::config(array('meta' => array('connection' => 'mockconn')));
MockPostForValidates::config(array('meta' => array('connection' => 'mockconn')));
$this->_altSchema = new Schema(array('fields' => array('id' => array('type' => 'integer'), 'author_id' => array('type' => 'integer'), 'title' => array('type' => 'string'), 'body' => array('type' => 'text'))));
}
示例15: setUp
public function setUp()
{
$connection = new MockDocumentSource();
Connections::add('mockconn', array('object' => $connection));
MockDocumentPost::config(array('meta' => array('connection' => 'mockconn')));
}