2016-10-19 17:54:41 +02:00
|
|
|
<?php
|
|
|
|
|
2017-06-03 20:00:07 +02:00
|
|
|
$_SERVER['JOPLIN_TESTING'] = true;
|
2017-06-03 19:12:33 +02:00
|
|
|
|
2017-06-04 00:33:46 +02:00
|
|
|
require_once dirname(__FILE__) . '/TestUtils.php';
|
2016-10-19 17:54:41 +02:00
|
|
|
require_once dirname(__FILE__) . '/BaseTestCase.php';
|
2017-06-03 19:12:33 +02:00
|
|
|
require_once dirname(__FILE__) . '/BaseControllerTestCase.php';
|
2016-10-19 17:54:41 +02:00
|
|
|
|
2017-06-11 23:11:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
// use DiffMatchPatch\DiffMatchPatch;
|
|
|
|
// $dmp = new DiffMatchPatch();
|
|
|
|
// $diff = $dmp->patch_make('car', 'car 🚘');
|
|
|
|
// var_dump($dmp->patch_toText($diff));
|
|
|
|
// var_dump($dmp->patch_apply($diff, 'car'));
|
|
|
|
|
|
|
|
// //$dmp->patch_toText($dmp->patch_make($from, $to));
|
|
|
|
// die();
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-12-27 22:25:07 +02:00
|
|
|
$dbConfig = array(
|
|
|
|
'dbName' => 'notes_test',
|
|
|
|
'user' => 'root',
|
2017-05-22 22:05:29 +02:00
|
|
|
'password' => 'pass',
|
2016-12-27 22:25:07 +02:00
|
|
|
'host' => '127.0.0.1',
|
|
|
|
);
|
|
|
|
|
2016-10-19 17:54:41 +02:00
|
|
|
$structureFile = dirname(dirname(__FILE__)) . '/structure.sql';
|
|
|
|
|
2016-12-27 22:25:07 +02:00
|
|
|
$cmd = sprintf("mysql -u %s %s -h %s -e 'DROP DATABASE IF EXISTS %s; CREATE DATABASE %s;'", $dbConfig['user'], empty($dbConfig['password']) ? '' : '-p' . $dbConfig['password'], $dbConfig['host'], $dbConfig['dbName'], $dbConfig['dbName']);
|
2016-10-19 17:54:41 +02:00
|
|
|
exec($cmd);
|
|
|
|
|
2016-12-27 22:25:07 +02:00
|
|
|
$cmd = sprintf("mysql -u %s %s -h %s %s < '%s'", $dbConfig['user'], empty($dbConfig['password']) ? '' : '-p' . $dbConfig['password'], $dbConfig['host'], $dbConfig['dbName'], $structureFile);
|
2016-10-19 17:54:41 +02:00
|
|
|
exec($cmd);
|
|
|
|
|
|
|
|
$capsule = new \Illuminate\Database\Capsule\Manager();
|
|
|
|
|
2017-06-03 20:00:07 +02:00
|
|
|
$capsuleConfig = [
|
2016-10-19 17:54:41 +02:00
|
|
|
'driver' => 'mysql',
|
2016-12-27 22:25:07 +02:00
|
|
|
'host' => $dbConfig['host'],
|
|
|
|
'database' => $dbConfig['dbName'],
|
|
|
|
'username' => $dbConfig['user'],
|
|
|
|
'password' => $dbConfig['password'],
|
2016-10-19 17:54:41 +02:00
|
|
|
'charset' => 'utf8',
|
|
|
|
'collation' => 'utf8_unicode_ci',
|
|
|
|
'prefix' => '',
|
2017-06-03 20:00:07 +02:00
|
|
|
];
|
2016-10-19 17:54:41 +02:00
|
|
|
|
2017-06-03 20:00:07 +02:00
|
|
|
$capsule->addConnection($capsuleConfig);
|
|
|
|
|
|
|
|
$_SERVER['JOPLIN_TESTING_DB_CONFIG'] = $capsuleConfig;
|
|
|
|
|
|
|
|
$capsule->bootEloquent();
|