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:
		| @@ -5,7 +5,6 @@ namespace Tests\Feature; | |||||||
| use App\Models\Auth\User; | use App\Models\Auth\User; | ||||||
| use App\Models\Common\Contact; | use App\Models\Common\Contact; | ||||||
| use App\Models\Document\Document; | use App\Models\Document\Document; | ||||||
| use App\Jobs\Common\CreateContact; |  | ||||||
| use App\Jobs\Document\CreateDocument; | use App\Jobs\Document\CreateDocument; | ||||||
| use App\Jobs\Setting\CreateCurrency; | use App\Jobs\Setting\CreateCurrency; | ||||||
| use Illuminate\Support\Facades\File; | use Illuminate\Support\Facades\File; | ||||||
| @@ -52,7 +51,7 @@ class PaymentTestCase extends FeatureTestCase | |||||||
|  |  | ||||||
|         $this->updateSetting(); |         $this->updateSetting(); | ||||||
|  |  | ||||||
|         $this->createCustomer(); |         $this->loginAsCustomer(); | ||||||
|  |  | ||||||
|         $this->createInvoice(); |         $this->createInvoice(); | ||||||
|  |  | ||||||
| @@ -140,20 +139,11 @@ class PaymentTestCase extends FeatureTestCase | |||||||
|         $this->invoice = $this->dispatch(new CreateDocument($this->getInvoiceRequest())); |         $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() + [ |         $this->customer_user = User::where('email', $this->customer->email)->first(); | ||||||
|             '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(); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getInvoiceRequest() |     public function getInvoiceRequest() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user