v2 first commit

This commit is contained in:
denisdulici
2019-11-16 10:21:14 +03:00
parent 5b23e9c2c4
commit 6d50fa8442
3075 changed files with 3451681 additions and 65594 deletions

View File

@ -19,8 +19,7 @@ class LoginTest extends FeatureTestCase
public function testItShouldLoginUser()
{
$this->post(route('login'), ['email' => $this->user->email, 'password' => $this->user->password])
->assertStatus(302)
->assertRedirect(url('/'));
->assertStatus(200);
$this->isAuthenticated($this->user->user);
}

View File

@ -28,8 +28,7 @@ class PermissionsTest extends FeatureTestCase
{
$this->loginAs()
->post(route('permissions.store'), $this->getPermissionRequest())
->assertStatus(302)
->assertRedirect(route('permissions.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -54,8 +53,7 @@ class PermissionsTest extends FeatureTestCase
$this->loginAs()
->patch(route('permissions.update', $permission->id), $request)
->assertStatus(302)
->assertRedirect(route('permissions.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -66,8 +64,7 @@ class PermissionsTest extends FeatureTestCase
$this->loginAs()
->delete(route('permissions.destroy', $permission->id))
->assertStatus(302)
->assertRedirect(route('permissions.index'));
->assertStatus(200);
$this->assertFlashLevel('success');

View File

@ -29,8 +29,7 @@ class RolesTest extends FeatureTestCase
{
$this->loginAs()
->post(route('roles.store'), $this->getRoleRequest())
->assertStatus(302)
->assertRedirect(route('roles.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -55,8 +54,7 @@ class RolesTest extends FeatureTestCase
$this->loginAs()
->patch(route('roles.update', $role->id), $request)
->assertStatus(302)
->assertRedirect(route('roles.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -67,8 +65,7 @@ class RolesTest extends FeatureTestCase
$this->loginAs()
->delete(route('roles.destroy', $role->id))
->assertStatus(302)
->assertRedirect(route('roles.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}

View File

@ -29,8 +29,7 @@ class UsersTest extends FeatureTestCase
{
$this->loginAs()
->post(route('users.store'), $this->getUserRequest())
->assertStatus(302)
->assertRedirect(route('users.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -55,8 +54,7 @@ class UsersTest extends FeatureTestCase
$this->loginAs()
->patch(route('users.update', $user->id), $request)
->assertStatus(302)
->assertRedirect(route('users.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -67,8 +65,7 @@ class UsersTest extends FeatureTestCase
$this->loginAs()
->delete(route('users.destroy', $user->id))
->assertStatus(302)
->assertRedirect(route('users.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}

View File

@ -26,9 +26,8 @@ class AccountsTest extends FeatureTestCase
public function testItShouldCreateAccount()
{
$this->loginAs()
->post(url('banking/accounts'), $this->getAccountRequest())
->assertStatus(302)
->assertRedirect(url('banking/accounts'));
->post(route('accounts.index'), $this->getAccountRequest())
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -52,9 +51,8 @@ class AccountsTest extends FeatureTestCase
$request['name'] = $this->faker->text(5);
$this->loginAs()
->patch(url('banking/accounts', $account->id), $request)
->assertStatus(302)
->assertRedirect(url('banking/accounts'));
->patch(route('accounts.update', ['account' => $account->id]), $request)
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -65,8 +63,7 @@ class AccountsTest extends FeatureTestCase
$this->loginAs()
->delete(route('accounts.destroy', ['account' => $account]))
->assertStatus(302)
->assertRedirect(route('accounts.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -77,7 +74,7 @@ class AccountsTest extends FeatureTestCase
'company_id' => $this->company->id,
'name' => $this->faker->text(5),
'number' => '1',
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'opening_balance' => 0,
'bank_name' => $this->faker->text(5),
'bank_phone' => null,

View File

@ -26,9 +26,8 @@ class ReconciliationsTest extends FeatureTestCase
public function testItShouldCreateReconciliation()
{
$this->loginAs()
->post(url('banking/reconciliations'), $this->getReconciliationRequest())
->assertStatus(302)
->assertRedirect(url('banking/reconciliations'));
->post(route('reconciliations.store'), $this->getReconciliationRequest())
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -52,9 +51,8 @@ class ReconciliationsTest extends FeatureTestCase
$request['description'] = $this->faker->text(10);
$this->loginAs()
->patch(url('banking/reconciliations', $reconciliation->id), $request)
->assertStatus(302)
->assertRedirect(url('banking/reconciliations'));
->patch(route('reconciliations.update', $reconciliation->id), $request)
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -65,8 +63,7 @@ class ReconciliationsTest extends FeatureTestCase
$this->loginAs()
->delete(route('reconciliations.destroy', ['reconciliation' => $reconciliation]))
->assertStatus(302)
->assertRedirect(route('reconciliations.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -77,7 +74,7 @@ class ReconciliationsTest extends FeatureTestCase
return [
'company_id' => $this->company->id,
'account_id' => '1',
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'opening_balance' => '0',
'closing_balance' => '10',
'started_at' => $this->faker->date(),

View File

@ -3,8 +3,7 @@
namespace Tests\Feature\Banking;
use App\Models\Banking\Transfer;
use App\Models\Expense\Payment;
use App\Models\Income\Revenue;
use App\Models\Banking\Transaction;
use Illuminate\Http\UploadedFile;
use Tests\Feature\FeatureTestCase;
@ -28,90 +27,79 @@ class TransfersTest extends FeatureTestCase
public function testItShouldCreateTransfer()
{
// Create Revenue
$revenue_request = $this->getRevenueRequest();
$revenue = Revenue::create($revenue_request);
// Create income
$income_transaction = Transaction::create($this->getIncomeRequest());
// Create Payment
$payment_request = $this->getPaymentRequest();
$payment = Payment::create($payment_request);
// Create expense
$expense_transaction = Transaction::create($this->getExpenseRequest());
$this->loginAs()
->post(url('banking/transfers'), $this->getTransferRequest($revenue, $payment))
->assertStatus(302)
->assertRedirect(url('banking/transfers'));
->post(route('transfers.store'), $this->getTransferRequest($income_transaction, $expense_transaction))
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldSeeTransferUpdatePage()
{
// Create Revenue
$revenue_request = $this->getRevenueRequest();
$revenue = Revenue::create($revenue_request);
// Create income
$income_transaction = Transaction::create($this->getIncomeRequest());
// Create Payment
$payment_request = $this->getPaymentRequest();
$payment = Payment::create($payment_request);
// Create expense
$expense_transaction = Transaction::create($this->getExpenseRequest());
$transfer = Transfer::create($this->getTransferRequest($revenue, $payment));
$transfer = Transfer::create($this->getTransferRequest($income_transaction, $expense_transaction));
$this->loginAs()
->get(route('transfers.edit', ['transfer' => $transfer->id]))
->assertStatus(200)
->assertSee($payment->description);
}
public function testItShouldDeleteTransfer()
{
// Create Revenue
$revenue_request = $this->getRevenueRequest();
$revenue = Revenue::create($revenue_request);
// Create Payment
$payment_request = $this->getPaymentRequest();
$payment = Payment::create($payment_request);
$transfer = Transfer::create($this->getTransferRequest($revenue, $payment));
$this->loginAs()
->delete(url('banking/transfers', ['transfer' => $transfer->id]))
->assertStatus(302)
->assertRedirect(url('banking/transfers'));
$this->assertFlashLevel('success');
->assertSee($expense_transaction->description);
}
public function testItShouldUpdateTransfer()
{
// Create Revenue
$revenue_request = $this->getRevenueRequest();
$revenue = Revenue::create($revenue_request);
// Create income
$income_transaction = Transaction::create($this->getIncomeRequest());
// Create Payment
$payment_request = $this->getPaymentRequest();
$payment = Payment::create($payment_request);
// Create expense
$expense_transaction = Transaction::create($this->getExpenseRequest());
$request = $this->getTransferRequest($revenue, $payment);
$request = $this->getTransferRequest($income_transaction, $expense_transaction);
$transfer = Transfer::create($request);
$request['description'] = $this->faker->text(10);
$this->loginAs()
->patch(url('banking/transfers', ['transfer' => $transfer->id]), $request)
->assertStatus(302)
->assertRedirect(url('banking/transfers'));
->patch(route('transfers.update', ['transfer' => $transfer->id]), $request)
->assertStatus(200);
$this->assertFlashLevel('success');
}
private function getTransferRequest($revenue, $payment)
public function testItShouldDeleteTransfer()
{
// Create income
$income_transaction = Transaction::create($this->getIncomeRequest());
// Create expense
$expense_transaction = Transaction::create($this->getExpenseRequest());
$transfer = Transfer::create($this->getTransferRequest($income_transaction, $expense_transaction));
$this->loginAs()
->delete(route('transfers.destroy', ['transfer' => $transfer->id]))
->assertStatus(200);
$this->assertFlashLevel('success');
}
private function getTransferRequest($income_transaction, $expense_transaction)
{
return [
'company_id' => $this->company->id,
'revenue_id' => $revenue->id,
'payment_id' => $payment->id,
'income_transaction_id' => $income_transaction->id,
'expense_transaction_id' => $expense_transaction->id,
'from_account_id' => '1',
'to_account_id' => '2',
'amount' => '5',
@ -119,46 +107,46 @@ class TransfersTest extends FeatureTestCase
'description'=> $this->faker->text(5),
'payment_method' => 'offlinepayment.cash.1',
'reference' => null,
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'currency_rate' => '1'
];
}
private function getRevenueRequest()
private function getIncomeRequest()
{
$attachment = UploadedFile::fake()->create('image.jpg');
return [
'company_id' => $this->company->id,
'customer_id' => '',
'account_id' => setting('general.default_account'),
'type' => 'income',
'account_id' => setting('default.account'),
'paid_at' => $this->faker->date(),
'amount' => $this->faker->randomFloat(2, 2),
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'description' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,
'reference' => $this->faker->text(5),
'payment_method' => setting('general.default_payment_method'),
'payment_method' => setting('default.payment_method'),
'attachment' => $attachment
];
}
private function getPaymentRequest()
private function getExpenseRequest()
{
$attachment = UploadedFile::fake()->create('image.jpg');
return [
'company_id' => $this->company->id,
'account_id' => setting('general.default_account'),
'vendor_id' => '',
'type' => 'expense',
'account_id' => setting('default.account'),
'paid_at' => $this->faker->date(),
'amount' => $this->faker->randomFloat(2, 2),
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'description' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('expense')->first()->id,
'payment_method' => setting('general.default_payment_method'),
'payment_method' => setting('default.payment_method'),
'reference' => $this->faker->text(5),
'attachment' => $attachment
];

View File

@ -12,7 +12,7 @@ class BillReminderTest extends FeatureTestCase
{
private $addDay;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
@ -51,23 +51,23 @@ class BillReminderTest extends FeatureTestCase
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD']];
$data = [
'vendor_id' => '0',
'contact_id' => '0',
'billed_at' => $this->faker->date(),
'due_at' => Date::now()->subDays($this->addDay - 1),
'bill_number' => '1',
'order_number' => '1',
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'item' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,
'recurring_frequency' => 'no',
'vendor_name' => $this->faker->name,
'vendor_email' => $this->faker->email,
'vendor_tax_number' => null,
'vendor_phone' => null,
'vendor_address' => $this->faker->address,
'contact_name' => $this->faker->name,
'contact_email' => $this->faker->email,
'contact_tax_number' => null,
'contact_phone' => null,
'contact_address' => $this->faker->address,
'bill_status_code' => 'sent',
'amount' => $amount,
'company_id' => $this->company->id,

View File

@ -12,7 +12,7 @@ class InvoiceReminderTest extends FeatureTestCase
{
private $addDay;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
@ -51,23 +51,23 @@ class InvoiceReminderTest extends FeatureTestCase
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD']];
$data = [
'customer_id' => '0',
'contact_id' => '0',
'invoiced_at' => $this->faker->date(),
'due_at' => Date::now()->addDay($this->addDay - 1),
'invoice_number' => '1',
'order_number' => '1',
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'item' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,
'recurring_frequency' => 'no',
'customer_name' => $this->faker->name,
'customer_email' => $this->faker->email,
'customer_tax_number' => null,
'customer_phone' => null,
'customer_address' => $this->faker->address,
'contact_name' => $this->faker->name,
'contact_email' => $this->faker->email,
'contact_tax_number' => null,
'contact_phone' => null,
'contact_address' => $this->faker->address,
'invoice_status_code' => 'sent',
'amount' => $amount,
'company_id' => $this->company->id,

View File

@ -28,8 +28,7 @@ class ItemsTest extends FeatureTestCase
{
$this->loginAs()
->post(route('items.store'), $this->getItemRequest())
->assertStatus(302)
->assertRedirect(route('items.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -54,8 +53,7 @@ class ItemsTest extends FeatureTestCase
$this->loginAs()
->patch(route('items.update', $item->id), $request)
->assertStatus(302)
->assertRedirect(route('items.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -66,8 +64,7 @@ class ItemsTest extends FeatureTestCase
$this->loginAs()
->delete(route('items.destroy', ['item' => $item]))
->assertStatus(302)
->assertRedirect(route('items.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -79,12 +76,10 @@ class ItemsTest extends FeatureTestCase
return [
'company_id' => $this->company->id,
'name' => $this->faker->text(15),
'sku' => $this->faker->unique()->ean8,
'picture' => $picture,
'description' => $this->faker->text(100),
'purchase_price' => $this->faker->randomFloat(2, 10, 20),
'sale_price' => $this->faker->randomFloat(2, 10, 20),
'quantity' => $this->faker->randomNumber(2),
'category_id' => $this->company->categories()->type('item')->first()->id,
'tax_id' => '',
'enabled' => $this->faker->boolean ? 1 : 0

View File

@ -2,9 +2,7 @@
namespace Tests\Feature\Expenses;
use App\Models\Common\Item;
use App\Models\Expense\Bill;
use App\Models\Expense\Vendor;
use App\Jobs\Expense\CreateBill;
use Tests\Feature\FeatureTestCase;
class BillsTest extends FeatureTestCase
@ -29,8 +27,7 @@ class BillsTest extends FeatureTestCase
{
$this->loginAs()
->post(route('bills.store'), $this->getBillRequest())
->assertStatus(302)
->assertRedirect(route('bills.show', ['bill' => 1]));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -39,29 +36,27 @@ class BillsTest extends FeatureTestCase
{
$this->loginAs()
->post(route('bills.store'), $this->getBillRequest(1))
->assertStatus(302)
->assertRedirect(route('bills.show', ['bill' => 1]));
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldSeeBillUpdatePage()
{
$bill = Bill::create($this->getBillRequest());
$bill = dispatch_now(new CreateBill($this->getBillRequest()));
$this->loginAs()
->get(route('bills.edit', ['bill' => $bill->id]))
->assertStatus(200)
->assertSee($bill->vendor_name)
->assertSee($bill->vendor_email);
->assertSee($bill->contact_name)
->assertSee($bill->contact_email);
}
public function testItShouldUpdateBill()
{
$request = $this->getBillRequest();
$bill = dispatch_now(new CreateBill($this->getBillRequest()));
$bill = Bill::create($request);
$request['vendor_name'] = $this->faker->name;
$request['contact_name'] = $this->faker->name;
$this->loginAs()
->patch(route('bills.update', $bill->id), $request)
@ -72,7 +67,7 @@ class BillsTest extends FeatureTestCase
public function testItShouldDeleteBill()
{
$bill = Bill::create($this->getBillRequest());
$bill = dispatch_now(new CreateBill($this->getBillRequest()));
$this->loginAs()
->delete(route('bills.destroy', $bill->id))
@ -90,26 +85,26 @@ class BillsTest extends FeatureTestCase
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD', 'tax_id' => null]];
$data = [
'vendor_id' => '0',
'company_id' => $this->company->id,
'billed_at' => $this->faker->date(),
'due_at' => $this->faker->date(),
'bill_number' => '1',
'order_number' => '1',
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'item' => $items,
'items' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('expense')->first()->id,
'recurring_frequency' => 'no',
'vendor_name' => $this->faker->name,
'vendor_email' =>$this->faker->email,
'vendor_tax_number' => null,
'vendor_phone' => null,
'vendor_address' => $this->faker->address,
'contact_id' => '0',
'contact_name' => $this->faker->name,
'contact_email' =>$this->faker->email,
'contact_tax_number' => null,
'contact_phone' => null,
'contact_address' => $this->faker->address,
'bill_status_code' => 'draft',
'amount' => $amount,
'company_id' => $this->company->id,
];
if ($recurring) {

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Expenses;
use App\Models\Expense\Payment;
use App\Models\Banking\Transaction;
use Illuminate\Http\UploadedFile;
use Tests\Feature\FeatureTestCase;
@ -11,7 +11,7 @@ class PaymentsTest extends FeatureTestCase
public function testItShouldSeePaymentListPage()
{
$this->loginAs()
->get(url('expenses/payments'))
->get(route('payments.index'))
->assertStatus(200)
->assertSeeText(trans_choice('general.payments', 2));
}
@ -19,7 +19,7 @@ class PaymentsTest extends FeatureTestCase
public function testItShouldSeePaymentCreatePage()
{
$this->loginAs()
->get(url('expenses/payments/create'))
->get(route('payments.create'))
->assertStatus(200)
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.payments', 1)]));
}
@ -27,9 +27,8 @@ class PaymentsTest extends FeatureTestCase
public function testItShouldCreatePayment()
{
$this->loginAs()
->post(url('expenses/payments'), $this->getPaymentRequest())
->assertStatus(302)
->assertRedirect(url('expenses/payments'));
->post(route('payments.store'), $this->getPaymentRequest())
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -38,26 +37,24 @@ class PaymentsTest extends FeatureTestCase
{
$request = $this->getPaymentRequest();
$payment = Payment::create($request);
$payment = Transaction::create($request);
$request['name'] = $this->faker->text(15);
$this->loginAs()
->patch(url('expenses/payments', $payment->id), $request)
->assertStatus(302)
->assertRedirect(url('expenses/payments'));
->patch(route('payments.update', $payment->id), $request)
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldDeletePayment()
{
$payment = Payment::create($this->getPaymentRequest());
$payment = Transaction::create($this->getPaymentRequest());
$this->loginAs()
->delete(url('expenses/payments', $payment->id))
->assertStatus(302)
->assertRedirect(url('expenses/payments'));
->delete(route('payments.destroy', $payment->id))
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -68,15 +65,15 @@ class PaymentsTest extends FeatureTestCase
return [
'company_id' => $this->company->id,
'account_id' => setting('general.default_account'),
'vendor_id' => '',
'type' => 'expense',
'account_id' => setting('default.account'),
'paid_at' => $this->faker->date(),
'amount' => $this->faker->randomFloat(2, 2),
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'description' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('expense')->first()->id,
'payment_method' => setting('general.default_payment_method'),
'payment_method' => setting('default.payment_method'),
'reference' => $this->faker->text(5),
'attachment' => $attachment,
];

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Expenses;
use App\Models\Expense\Vendor;
use App\Models\Common\Contact;
use Tests\Feature\FeatureTestCase;
class VendorsTest extends FeatureTestCase
@ -27,15 +27,14 @@ class VendorsTest extends FeatureTestCase
{
$this->loginAs()
->post(route('vendors.store'), $this->getVendorRequest())
->assertStatus(302)
->assertRedirect(route('vendors.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldSeeVendorDetailPage()
{
$vendor = Vendor::create($this->getVendorRequest());
$vendor = Contact::create($this->getVendorRequest());
$this->loginAs()
->get(route('vendors.show', ['vendor' => $vendor->id]))
@ -45,7 +44,7 @@ class VendorsTest extends FeatureTestCase
public function testItShouldSeeVendorUpdatePage()
{
$vendor = Vendor::create($this->getVendorRequest());
$vendor = Contact::create($this->getVendorRequest());
$this->loginAs()
->get(route('vendors.edit', ['vendor' => $vendor->id]))
@ -58,26 +57,24 @@ class VendorsTest extends FeatureTestCase
{
$request = $this->getVendorRequest();
$vendor = Vendor::create($request);
$vendor = Contact::create($request);
$request['name'] = $this->faker->name;
$this->loginAs()
->patch(route('vendors.update', $vendor->id), $request)
->assertStatus(302)
->assertRedirect(route('vendors.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldDeleteVendor()
{
$vendor = Vendor::create($this->getVendorRequest());
$vendor = Contact::create($this->getVendorRequest());
$this->loginAs()
->delete(route('vendors.destroy', $vendor->id))
->assertStatus(302)
->assertRedirect(route('vendors.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -86,6 +83,7 @@ class VendorsTest extends FeatureTestCase
{
return [
'company_id' => $this->company->id,
'type' => 'vendor',
'name' => $this->faker->name,
'email' => $this->faker->email,
'tax_number' => $this->faker->randomNumber(9),

View File

@ -20,7 +20,7 @@ abstract class FeatureTestCase extends TestCase
/** @var Company */
protected $company;
protected function setUp()
protected function setUp(): void
{
parent::setUp();

View File

@ -3,7 +3,7 @@
namespace Tests\Feature\Incomes;
use App\Models\Auth\User;
use App\Models\Income\Customer;
use App\Models\Common\Contact;
use Tests\Feature\FeatureTestCase;
class CustomersTest extends FeatureTestCase
@ -28,8 +28,7 @@ class CustomersTest extends FeatureTestCase
{
$this->loginAs()
->post(route('customers.store'), $this->getCustomerRequest())
->assertStatus(302)
->assertRedirect(route('customers.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -40,8 +39,7 @@ class CustomersTest extends FeatureTestCase
$this->loginAs()
->post(route('customers.store'), $customer)
->assertStatus(302)
->assertRedirect(route('customers.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
@ -64,7 +62,7 @@ class CustomersTest extends FeatureTestCase
public function testItShouldSeeCustomerDetailPage()
{
$customer = Customer::create($this->getCustomerRequest());
$customer = Contact::create($this->getCustomerRequest());
$this->loginAs()
->get(route('customers.show', ['customer' => $customer->id]))
@ -74,7 +72,7 @@ class CustomersTest extends FeatureTestCase
public function testItShouldSeeCustomerUpdatePage()
{
$customer = Customer::create($this->getCustomerRequest());
$customer = Contact::create($this->getCustomerRequest());
$this->loginAs()
->get(route('customers.edit', ['customer' => $customer->id]))
@ -87,26 +85,24 @@ class CustomersTest extends FeatureTestCase
{
$request = $this->getCustomerRequest();
$customer = Customer::create($request);
$customer = Contact::create($request);
$request['name'] = $this->faker->name;
$this->loginAs()
->patch(route('customers.update', $customer->id), $request)
->assertStatus(302)
->assertRedirect(route('customers.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldDeleteCustomer()
{
$customer = Customer::create($this->getCustomerRequest());
$customer = Contact::create($this->getCustomerRequest());
$this->loginAs()
->delete(route('customers.destroy', $customer->id))
->assertStatus(302)
->assertRedirect(route('customers.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
@ -122,6 +118,7 @@ class CustomersTest extends FeatureTestCase
{
return [
'company_id' => $this->company->id,
'type' => 'customer',
'name' => $this->faker->name,
'email' => $this->faker->email,
'tax_number' => $this->faker->randomNumber(9),

View File

@ -2,9 +2,7 @@
namespace Tests\Feature\Incomes;
use App\Models\Common\Item;
use App\Models\Income\Customer;
use App\Models\Income\Invoice;
use App\Jobs\Income\CreateInvoice;
use Tests\Feature\FeatureTestCase;
class InvoicesTest extends FeatureTestCase
@ -12,7 +10,7 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldSeeInvoiceListPage()
{
$this->loginAs()
->get(url('incomes/invoices'))
->get(route('invoices.index'))
->assertStatus(200)
->assertSeeText(trans_choice('general.invoices', 2));
}
@ -20,7 +18,7 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldSeeInvoiceCreatePage()
{
$this->loginAs()
->get(url('incomes/invoices'))
->get(route('invoices.create'))
->assertStatus(200)
->assertSeeText(trans( trans_choice('general.invoices', 1)));
}
@ -28,9 +26,8 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldCreateInvoice()
{
$this->loginAs()
->post(url('incomes/invoices'), $this->getInvoiceRequest())
->assertStatus(302)
->assertRedirect(url('incomes/invoices', ['invoice' => 1]));
->post(route('invoices.store'), $this->getInvoiceRequest())
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -38,36 +35,43 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldCreateInvoiceWithRecurring()
{
$this->loginAs()
->post(url('incomes/invoices'), $this->getInvoiceRequest(1))
->assertStatus(302)
->assertRedirect(url('incomes/invoices', ['invoice' => 1]));
->post(route('invoices.store'), $this->getInvoiceRequest(1))
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldUpdateInvoice()
public function testItShouldSeeInvoiceUpdatePage()
{
$request = $this->getInvoiceRequest();
$invoice = Invoice::create($request);
$request['customer_name'] = $this->faker->name;
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
$this->loginAs()
->patch(url('incomes/invoices', $invoice->id), $request)
->assertStatus(302);
->get(route('invoices.edit', ['invoice' => $invoice->id]))
->assertStatus(200)
->assertSee($invoice->contact_name)
->assertSee($invoice->contact_email);
}
public function testItShouldUpdateInvoice()
{
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
$request['contact_name'] = $this->faker->name;
$this->loginAs()
->patch(route('invoices.update', $invoice->id), $request)
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldDeleteInvoice()
{
$invoice = Invoice::create($this->getInvoiceRequest());
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
$this->loginAs()
->delete(url('incomes/invoices', $invoice->id))
->assertStatus(302)
->assertRedirect(url('incomes/invoices'));
->delete(route('invoices.destroy', $invoice->id))
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -79,26 +83,26 @@ class InvoicesTest extends FeatureTestCase
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD']];
$data = [
'customer_id' => '0',
'company_id' => $this->company->id,
'invoiced_at' => $this->faker->date(),
'due_at' => $this->faker->date(),
'invoice_number' => '1',
'order_number' => '1',
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'item' => $items,
'items' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,
'recurring_frequency' => 'no',
'customer_name' => $this->faker->name,
'customer_email' =>$this->faker->email,
'customer_tax_number' => null,
'customer_phone' => null,
'customer_address' => $this->faker->address,
'contact_id' => '0',
'contact_name' => $this->faker->name,
'contact_email' =>$this->faker->email,
'contact_tax_number' => null,
'contact_phone' => null,
'contact_address' => $this->faker->address,
'invoice_status_code' => 'draft',
'amount' => $amount,
'company_id' => $this->company->id,
];
if ($recurring) {

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Incomes;
use App\Models\Income\Revenue;
use App\Models\Banking\Transaction;
use Illuminate\Http\UploadedFile;
use Tests\Feature\FeatureTestCase;
@ -28,8 +28,7 @@ class RevenuesTest extends FeatureTestCase
{
$this->loginAs()
->post(route('revenues.store'), $this->getRevenueRequest())
->assertStatus(302)
->assertRedirect(route('revenues.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -38,26 +37,24 @@ class RevenuesTest extends FeatureTestCase
{
$request = $this->getRevenueRequest();
$revenue = Revenue::create($request);
$revenue = Transaction::create($request);
$request['name'] = $this->faker->text(15);
$this->loginAs()
->patch(route('revenues.update', $revenue->id), $request)
->assertStatus(302)
->assertRedirect(route('revenues.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldDeleteRevenue()
{
$revenue = Revenue::create($this->getRevenueRequest());
$revenue = Transaction::create($this->getRevenueRequest());
$this->loginAs()
->delete(route('revenues.destroy', $revenue->id))
->assertStatus(302)
->assertRedirect(route('revenues.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -68,16 +65,16 @@ class RevenuesTest extends FeatureTestCase
return [
'company_id' => $this->company->id,
'customer_id' => '',
'account_id' => setting('general.default_account'),
'type' => 'income',
'account_id' => setting('default.account'),
'paid_at' => $this->faker->date(),
'amount' => $this->faker->randomFloat(2, 2),
'currency_code' => setting('general.default_currency'),
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'description' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,
'reference' => $this->faker->text(5),
'payment_method' => setting('general.default_payment_method'),
'payment_method' => setting('default.payment_method'),
'attachment' => $attachment,
];
}

View File

@ -1,16 +0,0 @@
<?php
namespace Tests\Feature\Reports;
use Tests\Feature\FeatureTestCase;
class ExpenseSummaryTest extends FeatureTestCase
{
public function testItShouldSeeExpenseSummaryPage()
{
$this->loginAs()
->get(url('reports/expense-summary'))
->assertStatus(200)
->assertSeeText(trans('reports.summary.expense'));
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace Tests\Feature\Reports;
use Tests\Feature\FeatureTestCase;
class IncomeExpenseSummaryTest extends FeatureTestCase
{
public function testItShouldSeeIncomeExpenseSummaryPage()
{
$this->loginAs()
->get(url('reports/income-expense-summary'))
->assertStatus(200)
->assertSeeText(trans('reports.summary.income_expense'));
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace Tests\Feature\Reports;
use Tests\Feature\FeatureTestCase;
class IncomeSummaryTest extends FeatureTestCase
{
public function testItShouldSeeIncomeSummaryPage()
{
$this->loginAs()
->get(url('reports/income-summary'))
->assertStatus(200)
->assertSeeText(trans('reports.summary.income'));
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace Tests\Feature\Reports;
use Tests\Feature\FeatureTestCase;
class ProfitLossTest extends FeatureTestCase
{
public function testItShouldSeeProfitLossPage()
{
$this->loginAs()
->get(url('reports/profit-loss'))
->assertStatus(200)
->assertSeeText(trans('reports.profit_loss'));
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace Tests\Feature\Reports;
use Tests\Feature\FeatureTestCase;
class TaxSummaryTest extends FeatureTestCase
{
public function testItShouldSeeTaxSummaryPage()
{
$this->loginAs()
->get(url('reports/tax-summary'))
->assertStatus(200)
->assertSeeText(trans('reports.summary.tax'));
}
}

View File

@ -27,8 +27,7 @@ class CategoriesTest extends FeatureTestCase
{
$this->loginAs()
->post(route('categories.store'), $this->getCategoryRequest())
->assertStatus(302)
->assertRedirect(route('categories.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -53,8 +52,7 @@ class CategoriesTest extends FeatureTestCase
$this->loginAs()
->patch(route('categories.update', $category->id), $request)
->assertStatus(302)
->assertRedirect(route('categories.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -65,8 +63,7 @@ class CategoriesTest extends FeatureTestCase
$this->loginAs()
->delete(route('categories.destroy', $category->id))
->assertStatus(302)
->assertRedirect(route('categories.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}

View File

@ -27,8 +27,7 @@ class CurrenciesTest extends FeatureTestCase
{
$this->loginAs()
->post(route('currencies.store'), $this->getCurrencyRequest())
->assertStatus(302)
->assertRedirect(route('currencies.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -43,8 +42,7 @@ class CurrenciesTest extends FeatureTestCase
$this->loginAs()
->patch(route('currencies.update', $currency->id), $request)
->assertStatus(302)
->assertRedirect(route('currencies.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -55,8 +53,7 @@ class CurrenciesTest extends FeatureTestCase
$this->loginAs()
->delete(route('currencies.destroy', $currency->id))
->assertStatus(302)
->assertRedirect(route('currencies.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}

View File

@ -27,8 +27,7 @@ class TaxesTest extends FeatureTestCase
{
$this->loginAs()
->post(route('taxes.store'), $this->getTaxRequest())
->assertStatus(302)
->assertRedirect(route('taxes.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -43,8 +42,7 @@ class TaxesTest extends FeatureTestCase
$this->loginAs()
->patch(route('taxes.update', $tax->id), $request)
->assertStatus(302)
->assertRedirect(route('taxes.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
@ -55,8 +53,7 @@ class TaxesTest extends FeatureTestCase
$this->loginAs()
->delete(route('taxes.destroy', $tax->id))
->assertStatus(302)
->assertRedirect(route('taxes.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}

View File

@ -11,7 +11,7 @@ abstract class TestCase extends BaseTestCase
{
use CreatesApplication, DatabaseMigrations;
protected function setUp()
protected function setUp(): void
{
parent::setUp();