Clean up test data.

This commit is contained in:
James Cole
2016-05-14 21:49:16 +02:00
parent f78d56b149
commit e5eabdf7e7
5 changed files with 730 additions and 1095 deletions

View File

@@ -21,10 +21,7 @@ class DatabaseSeeder extends Seeder
$this->call('TransactionCurrencySeeder');
$this->call('TransactionTypeSeeder');
$this->call('PermissionSeeder');
if (App::environment() == 'testing') {
$this->call('TestDataSeeder');
}
$this->call('TestDataSeeder');
}
}

View File

@@ -9,8 +9,6 @@ declare(strict_types = 1);
*/
use Carbon\Carbon;
use FireflyIII\Events\BudgetLimitStored;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Support\Migration\TestData;
use Illuminate\Database\Seeder;
@@ -19,19 +17,11 @@ use Illuminate\Database\Seeder;
*/
class TestDataSeeder extends Seeder
{
/** @var Carbon */
public $end;
/** @var Carbon */
public $start;
/**
* TestDataSeeder constructor.
*/
public function __construct()
{
$this->start = Carbon::create()->subYears(2)->startOfYear();
$this->end = Carbon::now();
}
/**
@@ -41,12 +31,13 @@ class TestDataSeeder extends Seeder
*/
public function run()
{
$current = clone $this->start;
while ($current < $this->end) {
$month = $current->format('F Y');
$current->addMonth();
$disk = Storage::disk('database');
$env = App::environment();
$fileName = 'seed.' . $env . '.json';
if ($disk->exists($fileName)) {
$file = json_decode($disk->get($fileName), true);
// run the file:
TestData::run($file);
}
}
}