Exemplo n.º 1
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);
 }
Exemplo n.º 2
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']);
     }
 }
Exemplo n.º 3
0
 public function cleanMigrationsTable()
 {
     // @codeCoverageIgnoreStart
     if (!Config::runningUnitTest()) {
         return;
     }
     // @codeCoverageIgnoreEnd
     $this->db = Db::connection();
     $this->db->dropTable($this->table);
     $this->checkMigrationsTable();
 }
Exemplo n.º 4
0
 public function fire()
 {
     $this->checkMigrationsTable();
     if ($lastMigration = $this->getLastMigration()) {
         $file = $lastMigration['file'];
         $runAt = $lastMigration['run_at'];
         $this->comment(sprintf(' You are going to revert migration "%s" which was run at %s', $file, $runAt));
         if (Config::runningUnitTest() || $this->confirm('please confirm', false)) {
             $this->revertMigration($file);
         }
     } else {
         $this->info('No migrations to be reverted.');
     }
     // @codeCoverageIgnoreEnd
 }
Exemplo n.º 5
0
 public function __construct()
 {
     parent::__construct(false);
     static::$runningUnitTest = Config::runningUnitTest();
     // @codeCoverageIgnoreStart
     if ($this->_sitePathPrefix = Config::get('app.site_path')) {
         $this->_uriSource = self::URI_SOURCE_GET_URL;
         $this->_sitePathLength = strlen($this->_sitePathPrefix);
     }
     // @codeCoverageIgnoreEnd
     $this->removeExtraSlashes(true);
     $routes = is_file($file = $_SERVER['PHWOOLCON_ROOT_PATH'] . '/app/routes.php') ? include $file : [];
     is_array($routes) and $this->addRoutes($routes);
     $this->cookies = static::$di->getShared('cookies');
     $this->response = static::$di->getShared('response');
     $this->response->setStatusCode(200);
 }
Exemplo n.º 6
0
 public static function register(Di $di)
 {
     static::$di = $di;
     static::$runningUnitTest = Config::runningUnitTest();
     $di->setShared('view', function () {
         return new static(Config::get('view'));
     });
 }