fixed tests

This commit is contained in:
denisdulici
2019-11-18 10:54:26 +03:00
parent 63ab57730d
commit 2cdc431f8c
17 changed files with 123 additions and 154 deletions

View File

@ -1,26 +0,0 @@
<?php
use Faker\Generator;
use App\Models\Auth\User;
use App\Models\Common\Item;
use App\Models\Common\Company;
use Illuminate\Database\Eloquent\Factory;
/** @var Factory $factory */
$factory->define(Item::class, function (Generator $faker) {
/** @var User $user */
$user = User::first();
/** @var Company $company */
$company = $user->companies()->first();
return [
'name' => $faker->title,
'company_id' => $company->id,
'description' => $faker->text(100),
'purchase_price' => $faker->randomFloat(2,10,20),
'sale_price' => $faker->randomFloat(2,10,20),
'category_id' => $company->categories()->first()->id,
'tax_id' => $company->taxes()->first()->id,
'enabled' => $this->faker->boolean ? 1 : 0
];
});

View File

@ -0,0 +1,21 @@
<?php
use App\Models\Auth\User;
use App\Models\Common\Item;
use Faker\Generator as Faker;
$factory->define(Item::class, function (Faker $faker) {
$user = User::first();
$company = $user->companies()->first();
return [
'company_id' => $company->id,
'name' => $faker->text(15),
'description' => $faker->text(100),
'purchase_price' => $faker->randomFloat(2, 10, 20),
'sale_price' => $faker->randomFloat(2, 10, 20),
'category_id' => $company->categories()->type('item')->pluck('id')->first(),
'tax_id' => '',
'enabled' => $faker->boolean ? 1 : 0
];
});

View File

@ -0,0 +1,28 @@
<?php
use App\Models\Auth\User;
use App\Models\Banking\Transaction;
use Faker\Generator as Faker;
use Illuminate\Http\UploadedFile;
$factory->define(Transaction::class, function (Faker $faker) {
$user = User::first();
$company = $user->companies()->first();
$attachment = UploadedFile::fake()->create('image.jpg');
return [
'company_id' => $company->id,
'type' => 'income',
'account_id' => setting('default.account'),
'paid_at' => $faker->date(),
'amount' => $faker->randomFloat(2, 2),
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'description' => $faker->text(5),
'category_id' => $company->categories()->type('income')->first()->id,
'reference' => $faker->text(5),
'payment_method' => setting('default.payment_method'),
'attachment' => $attachment,
];
});