protected function setUp()
 {
     parent::setUp();
     \Myfox\Lib\Mysql::removeAllNames();
     \Myfox\Lib\Mysql::register('default', __DIR__ . '/ini/mysql.ini');
     self::$mysql = \Myfox\Lib\Mysql::instance('default');
 }
 protected function setUp()
 {
     parent::setUp();
     \Myfox\Lib\Mysql::removeAllNames();
     \Myfox\Lib\Mysql::register('default', __DIR__ . '/ini/mysql.ini');
     self::$mysql = \Myfox\Lib\Mysql::instance('default');
     self::$mysql->query(sprintf("DELETE FROM %shost_list WHERE host_name LIKE 'unittest%%'", self::$mysql->option('prefix', '')));
 }
Example #3
0
 protected function setUp()
 {
     parent::setUp();
     $config = new Config(__DIR__ . '/ini/mysql_test.ini');
     $logurl = parse_url($config->get('logurl', ''));
     $this->logfile = $logurl['path'];
     Mysql::removeAllNames();
     self::$mysql = new Mysql(__DIR__ . '/ini/mysql.ini');
     self::$mysql->query('DROP TABLE IF EXISTS only_for_test');
     self::$mysql->query('CREATE TABLE `only_for_test` (
         `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
         `content` varchar(32) DEFAULT NULL,
         PRIMARY KEY (`id`)
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8');
     @unlink($this->logfile);
 }
    /**
     * 测试表及信息创建
     */
    protected function setUp()
    {
        parent::setUp();
        \Myfox\Lib\Mysql::removeAllNames();
        \Myfox\Lib\Mysql::register('default', __DIR__ . '/ini/mysql.ini');
        $this->mysql = \Myfox\Lib\Mysql::instance('default');
        $config = new \Myfox\Lib\Config(__DIR__ . '/ini/mysql.ini');
        foreach ($config->get('master') as $host) {
            $urlRes = parse_url($host);
            $this->infos['host'] = $urlRes['host'];
            $this->infos['port'] = array_key_exists('port', $urlRes) ? $urlRes['port'] : 3306;
            $this->infos['user'] = array_key_exists('user', $urlRes) ? $urlRes['user'] : '******';
            $this->infos['pass'] = array_key_exists('pass', $urlRes) ? $urlRes['pass'] : '';
        }
        self::cleanTable('default', 'route_info');
        $this->table_bak('table_list');
        $this->table_bak('host_list');
        $this->table_bak('settings');
        //插入测试分片表1
        $this->mysql->query('CREATE TABLE `test_table_real1` (
			`id` int(10) unsigned NOT NULL auto_increment,
			`key1` varchar(64) NOT NULL default "",
			`key2` int(10) NOT NULL default 0,
			PRIMARY KEY (`id`)
		)');
        //插入测试分片表2
        $this->mysql->query('CREATE TABLE `test_table_real2` (
			`id` int(10) unsigned NOT NULL auto_increment,
			`key1` varchar(64) NOT NULL default "",
			`key2` int(10) NOT NULL default 0,
			PRIMARY KEY (`id`)
		)');
        //插入测试分片表3
        $this->mysql->query('CREATE TABLE `test_table_real3` (
			`id` int(10) unsigned NOT NULL auto_increment,
			`key1` varchar(64) NOT NULL default "",
			`key2` int(10) NOT NULL default 0,
			PRIMARY KEY (`id`)
		)');
    }