Exemplo n.º 1
0
 public function setUp()
 {
     $this->config = Config::getInstance();
 }
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this 
 * file except in compliance with the License.
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under 
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
 * language governing permissions and limitations under the License.
 *
 * @author toni lopez <*****@*****.**>
 */
use EasyConfig\Config;
date_default_timezone_set('UTC');
require_once __DIR__ . '/../../../autoload.php';
$config = Config::getInstance();
$path = __DIR__ . '/../../../../config';
$config->loadConfig(array("{$path}/environment.yml"));
$mysqlConfig = $config->fetch('db');
$dsn = "mysql:dbname={$mysqlConfig['schema']};host={$mysqlConfig['host']}";
$mysql = new PDO($dsn, $mysqlConfig['user'], $mysqlConfig['password']);
// is _schema table there? if not, let's create it
if (!$mysql->query('select 1 from _schema')) {
    $schemaQuery = file_get_contents(__DIR__ . '/../../../../db/schema.sql');
    if ($mysql->exec($schemaQuery) === false) {
        $error = $mysql->errorInfo();
        echo "Cannot apply schema.sql: " . $error[2] . "\n";
        exit;
    }
    $query = <<<SQL
create table if not exists _schema (