applied jobs to tests

This commit is contained in:
denisdulici
2019-11-17 15:06:00 +03:00
parent 272905decc
commit 58048a1979
25 changed files with 194 additions and 186 deletions

View File

@@ -2,8 +2,8 @@
namespace Tests\Feature\Incomes;
use App\Jobs\Common\CreateContact;
use App\Models\Auth\User;
use App\Models\Common\Contact;
use Tests\Feature\FeatureTestCase;
class CustomersTest extends FeatureTestCase
@@ -62,7 +62,7 @@ class CustomersTest extends FeatureTestCase
public function testItShouldSeeCustomerDetailPage()
{
$customer = Contact::create($this->getCustomerRequest());
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
$this->loginAs()
->get(route('customers.show', ['customer' => $customer->id]))
@@ -72,7 +72,7 @@ class CustomersTest extends FeatureTestCase
public function testItShouldSeeCustomerUpdatePage()
{
$customer = Contact::create($this->getCustomerRequest());
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
$this->loginAs()
->get(route('customers.edit', ['customer' => $customer->id]))
@@ -85,7 +85,7 @@ class CustomersTest extends FeatureTestCase
{
$request = $this->getCustomerRequest();
$customer = Contact::create($request);
$customer = $this->dispatch(new CreateContact($request));
$request['name'] = $this->faker->name;
@@ -98,7 +98,7 @@ class CustomersTest extends FeatureTestCase
public function testItShouldDeleteCustomer()
{
$customer = Contact::create($this->getCustomerRequest());
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
$this->loginAs()
->delete(route('customers.destroy', $customer->id))
@@ -135,10 +135,10 @@ class CustomersTest extends FeatureTestCase
$password = $this->faker->password;
return $this->getCustomerRequest() + [
'create_user' => 1,
'locale' => 'en-GB',
'password' => $password,
'password_confirmation' => $password
];
'create_user' => 1,
'locale' => 'en-GB',
'password' => $password,
'password_confirmation' => $password
];
}
}

View File

@@ -20,7 +20,7 @@ class InvoicesTest extends FeatureTestCase
$this->loginAs()
->get(route('invoices.create'))
->assertStatus(200)
->assertSeeText(trans( trans_choice('general.invoices', 1)));
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.invoices', 1)]));
}
public function testItShouldCreateInvoice()
@@ -35,7 +35,7 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldCreateInvoiceWithRecurring()
{
$this->loginAs()
->post(route('invoices.store'), $this->getInvoiceRequest(1))
->post(route('invoices.store'), $this->getInvoiceRequest(true))
->assertStatus(200);
$this->assertFlashLevel('success');
@@ -43,7 +43,7 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldSeeInvoiceUpdatePage()
{
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
$invoice = $this->dispatch(new CreateInvoice($this->getInvoiceRequest()));
$this->loginAs()
->get(route('invoices.edit', ['invoice' => $invoice->id]))
@@ -54,7 +54,9 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldUpdateInvoice()
{
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
$request = $this->getInvoiceRequest();
$invoice = $this->dispatch(new CreateInvoice($request));
$request['contact_name'] = $this->faker->name;
@@ -67,7 +69,7 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldDeleteInvoice()
{
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
$invoice = $this->dispatch(new CreateInvoice($this->getInvoiceRequest()));
$this->loginAs()
->delete(route('invoices.destroy', $invoice->id))
@@ -76,11 +78,11 @@ class InvoicesTest extends FeatureTestCase
$this->assertFlashLevel('success');
}
private function getInvoiceRequest($recurring = 0)
private function getInvoiceRequest($recurring = false)
{
$amount = $this->faker->randomFloat(2, 2);
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD']];
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD']];
$data = [
'company_id' => $this->company->id,
@@ -93,7 +95,7 @@ class InvoicesTest extends FeatureTestCase
'items' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,
'category_id' => $this->company->categories()->type('income')->pluck('id')->first(),
'recurring_frequency' => 'no',
'contact_id' => '0',
'contact_name' => $this->faker->name,

View File

@@ -2,7 +2,7 @@
namespace Tests\Feature\Incomes;
use App\Models\Banking\Transaction;
use App\Jobs\Banking\CreateTransaction;
use Illuminate\Http\UploadedFile;
use Tests\Feature\FeatureTestCase;
@@ -37,7 +37,7 @@ class RevenuesTest extends FeatureTestCase
{
$request = $this->getRevenueRequest();
$revenue = Transaction::create($request);
$revenue = $this->dispatch(new CreateTransaction($request));
$request['name'] = $this->faker->text(15);
@@ -50,7 +50,7 @@ class RevenuesTest extends FeatureTestCase
public function testItShouldDeleteRevenue()
{
$revenue = Transaction::create($this->getRevenueRequest());
$revenue = $this->dispatch(new CreateTransaction($this->getRevenueRequest()));
$this->loginAs()
->delete(route('revenues.destroy', $revenue->id))