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,
];
});

View File

@ -3,14 +3,15 @@
namespace Database\Seeds;
use App\Abstracts\Model;
use App\Models\Auth\User;
use App\Jobs\Auth\CreateUser;
use App\Models\Common\Company;
use Artisan;
use Date;
use App\Traits\Jobs;
use Illuminate\Database\Seeder;
class TestCompany extends Seeder
{
use Jobs;
/**
* Run the database seeds.
*
@ -37,8 +38,8 @@ class TestCompany extends Seeder
setting()->setExtraColumns(['company_id' => '1']);
setting()->set([
'company.name' => 'Test Inc.',
'company.email' => 'info@test.com',
'company.name' => 'Test Company',
'company.email' => 'test@company.com',
'company.address' => 'New Street 1254',
'localisation.financial_start' => '01-01',
'default.currency' => 'USD',
@ -46,8 +47,8 @@ class TestCompany extends Seeder
'default.payment_method' => 'offline-payments.cash.1',
'schedule.bill_days' => '10,5,3,1',
'schedule.invoice_days' => '1,3,5,10',
'schedule.send_invoice_reminder' => '0',
'schedule.send_bill_reminder' => '0',
'schedule.send_invoice_reminder' => '1',
'schedule.send_bill_reminder' => '1',
'wizard.completed' => '1',
'contact.type.customer' => 'customer',
'contact.type.vendor' => 'vendor',
@ -59,25 +60,16 @@ class TestCompany extends Seeder
public function createUser()
{
// Create user
$user = User::create([
'name' => 'Admin',
'email' => 'admin@akaunting.com',
$this->dispatch(new CreateUser([
'name' => 'Test',
'email' => 'test@company.com',
'password' => '123456',
'last_logged_in_at' => Date::now(),
]);
'locale' => 'en-GB',
'companies' => ['1'],
'roles' => ['1'],
'enabled' => '1',
]));
// Attach Role
$user->roles()->attach(1);
// Attach company
$user->companies()->attach(1);
Artisan::call('user:seed', [
'user' => $user->id,
'company' => 1,
]);
$this->command->info('Admin user created.');
$this->command->info('Test user created.');
}
}