Using existing customer

Already [creating](https://github.com/akaunting/akaunting/blob/master/database/seeds/TestCompany.php#L78) customer during testing
This commit is contained in:
EnesSacid-Buker 2022-02-16 16:13:50 +03:00 committed by GitHub
parent 76e9eb39be
commit 93bc59409e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,6 @@ namespace Tests\Feature;
use App\Models\Auth\User;
use App\Models\Common\Contact;
use App\Models\Document\Document;
use App\Jobs\Common\CreateContact;
use App\Jobs\Document\CreateDocument;
use App\Jobs\Setting\CreateCurrency;
use Illuminate\Support\Facades\File;
@ -52,7 +51,7 @@ class PaymentTestCase extends FeatureTestCase
$this->updateSetting();
$this->createCustomer();
$this->loginAsCustomer();
$this->createInvoice();
@ -140,20 +139,11 @@ class PaymentTestCase extends FeatureTestCase
$this->invoice = $this->dispatch(new CreateDocument($this->getInvoiceRequest()));
}
public function createCustomer()
public function loginAsCustomer()
{
$password = $this->faker->password;
$this->customer = Contact::customer()->first();
$request = Contact::factory()->customer()->enabled()->raw() + [
'create_user' => 'true',
'locale' => 'en-GB',
'password' => $password,
'password_confirmation' => $password,
];
$this->customer = $this->dispatch(new CreateContact($request));
$this->customer_user = User::where('email', $request['email'])->first();
$this->customer_user = User::where('email', $this->customer->email)->first();
}
public function getInvoiceRequest()