mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for tests
This commit is contained in:
parent
7b073d033a
commit
49ac6a3d50
@ -25,6 +25,9 @@ use App\Helpers\Invoice\InvoiceSum;
|
|||||||
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
|
use App\Models\BankIntegration;
|
||||||
|
use App\Models\BankTransaction;
|
||||||
|
use App\Models\BankTransactionRule;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
@ -47,6 +50,7 @@ use App\Utils\Ninja;
|
|||||||
use App\Utils\Traits\GeneratesCounter;
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Database\Factories\BankTransactionRuleFactory;
|
||||||
use Faker\Factory;
|
use Faker\Factory;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
@ -87,7 +91,7 @@ class CreateSingleAccount extends Command
|
|||||||
MultiDB::setDb($this->option('database'));
|
MultiDB::setDb($this->option('database'));
|
||||||
|
|
||||||
$this->info(date('r').' Create Single Sample Account...');
|
$this->info(date('r').' Create Single Sample Account...');
|
||||||
$this->count = 1;
|
$this->count = 5;
|
||||||
$this->gateway = $this->argument('gateway');
|
$this->gateway = $this->argument('gateway');
|
||||||
|
|
||||||
$this->info('Warming up cache');
|
$this->info('Warming up cache');
|
||||||
@ -179,6 +183,22 @@ class CreateSingleAccount extends Command
|
|||||||
'rate' => 5
|
'rate' => 5
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$bi = BankIntegration::factory()->create([
|
||||||
|
'account_id' => $account->id,
|
||||||
|
'company_id' => $company->id,
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
BankTransaction::factory()->count(50)->create([
|
||||||
|
'bank_integration_id' => $bi->id,
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'company_id' => $company->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$btr = BankTransactionRule::factory()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'company_id' => $company->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$this->info('Creating '.$this->count.' clients');
|
$this->info('Creating '.$this->count.' clients');
|
||||||
|
|
||||||
@ -358,7 +378,7 @@ class CreateSingleAccount extends Command
|
|||||||
|
|
||||||
private function createExpense($client)
|
private function createExpense($client)
|
||||||
{
|
{
|
||||||
Expense::factory()->count(rand(1, 2))->create([
|
Expense::factory()->count(rand(1, 20))->create([
|
||||||
'user_id' => $client->user->id,
|
'user_id' => $client->user->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'company_id' => $client->company->id,
|
'company_id' => $client->company->id,
|
||||||
|
@ -34,7 +34,8 @@ class BankTransactionFactory extends Factory
|
|||||||
'date' => $this->faker->date('Y-m-d') ,
|
'date' => $this->faker->date('Y-m-d') ,
|
||||||
'bank_account_id' => 1 ,
|
'bank_account_id' => 1 ,
|
||||||
'description' =>$this->faker->words(5, true) ,
|
'description' =>$this->faker->words(5, true) ,
|
||||||
'status_id'=> 1
|
'status_id'=> 1,
|
||||||
|
'base_type' => (bool)rand(0,1) ? 'CREDIT' : 'DEBIT',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,10 @@ class BankTransactionRuleFactory extends Factory
|
|||||||
public function definition()
|
public function definition()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' =>$this->faker->name(),
|
'name' => $this->faker->name(),
|
||||||
|
'applies_to' => (bool)rand(0,1) ? 'CREDIT' : 'DEBIT',
|
||||||
|
'matches_on_all' => (bool)rand(0,1),
|
||||||
|
'auto_convert' => (bool)rand(0,1),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,12 +263,11 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
$payment_id = $arr['data']['id'];
|
$payment_id = $arr['data']['id'];
|
||||||
|
|
||||||
$payment = Payment::find($this->decodePrimaryKey($payment_id))->first();
|
$payment = Payment::with('invoices')->find($this->decodePrimaryKey($payment_id));
|
||||||
$payment->load('invoices');
|
|
||||||
|
|
||||||
$this->assertNotNull($payment);
|
$this->assertNotNull($payment);
|
||||||
$this->assertNotNull($payment->invoices());
|
$this->assertNotNull($payment->invoices());
|
||||||
$this->assertEquals(1, $payment->invoices()->count());
|
$this->assertEquals(1, $payment->invoices->count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1345,7 +1344,7 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
$payment_id = $arr['data']['id'];
|
$payment_id = $arr['data']['id'];
|
||||||
|
|
||||||
$payment = Payment::find($this->decodePrimaryKey($payment_id))->first();
|
$payment = Payment::find($this->decodePrimaryKey($payment_id));
|
||||||
|
|
||||||
// nlog($payment);
|
// nlog($payment);
|
||||||
|
|
||||||
@ -1527,7 +1526,7 @@ class PaymentTest extends TestCase
|
|||||||
public function testUniquePaymentNumbers()
|
public function testUniquePaymentNumbers()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => $invoice->amount,
|
'amount' => $this->invoice->amount,
|
||||||
'client_id' => $this->client->hashed_id,
|
'client_id' => $this->client->hashed_id,
|
||||||
'date' => '2020/12/12',
|
'date' => '2020/12/12',
|
||||||
'number' => 'duplicate',
|
'number' => 'duplicate',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user