示例#1
0
 public function initialize()
 {
     parent::initialize();
     $db = Db::connection();
     $db->tableExists($this->_table) or $this->createTable();
     $db->delete($this->_table);
 }
示例#2
0
 public function __construct($options)
 {
     $this->options = $options;
     $this->table = $options['table'];
     $this->db = Db::connection($options['connection']);
     $this->db->tableExists($this->table) or $this->createTable();
     Config::runningUnitTest() and $this->db->delete($this->table);
 }
示例#3
0
 public function setUp()
 {
     parent::setUp();
     Config::set('counter.default', 'rds');
     Counter::register($this->di);
     $db = Db::connection();
     $db->tableExists('counter') and $db->dropTable('counter');
 }
示例#4
0
 protected static function createConfigTable()
 {
     $db = Db::connection();
     $db->createTable('config', null, ['columns' => [new Column('key', ['type' => Column::TYPE_VARCHAR, 'size' => 32, 'notNull' => true, 'primary' => true]), new Column('value', ['type' => Column::TYPE_TEXT])]]);
     if (PhwoolconConfig::runningUnitTest()) {
         static::saveConfig('_testing', ['k' => 'v']);
     }
 }
示例#5
0
 public function reset($keyName)
 {
     $db = Db::connection();
     $db->updateAsDict($this->table, ['value' => 0], ['conditions' => $this->updateCondition, 'bind' => [$keyName]]);
 }
示例#6
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->db = Db::connection();
     parent::execute($input, $output);
 }
示例#7
0
 public function testConnection()
 {
     $this->assertEquals('value', Db::connection()->query('SELECT "value" v')->fetch()['v'], 'Unable to connect DB');
 }