Implement PHP CS Fixer and a coding standard to follow (#471)

* Create PHP CS Fixer config and add to CI workflow

* Run php cs fixer on project

* Add newline at end of file

* Update to use PHP CS Fixer v3

* Run v3 config on project

* Run seperate config in CI
This commit is contained in:
Mwikala Kangwa
2021-05-21 12:57:51 +01:00
committed by GitHub
parent 633cad9b89
commit 9e98a96d61
316 changed files with 4715 additions and 3195 deletions

View File

@ -1,12 +1,13 @@
<?php
use Crater\Models\User;
use Crater\Models\FileDisk;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Illuminate\Support\Facades\Queue;
use Crater\Jobs\CreateBackupJob;
use function Pest\Laravel\{postJson, getJson};
use Crater\Models\FileDisk;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Queue;
use Laravel\Sanctum\Sanctum;
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -24,7 +25,7 @@ beforeEach(function () {
test('get backups', function () {
$disk = FileDisk::factory()->create([
'set_as_default' => true
'set_as_default' => true,
]);
$response = getJson("/api/v1/backups?disk={$disk->driver}&&file_disk_id={$disk->id}");
@ -50,7 +51,7 @@ test('create backup', function () {
$response->assertStatus(200)->assertJson([
"disks" => [
"local"
]
"local",
],
]);
});

View File

@ -6,7 +6,9 @@ use Crater\Http\Requests\ProfileRequest;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use function Pest\Laravel\{postJson, getJson, putJson};
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -41,7 +43,7 @@ test('update profile', function () {
$user = [
'name' => 'John Doe',
'password' => 'admin@123',
'email' => 'admin@crater.in'
'email' => 'admin@crater.in',
];
$response = putJson('api/v1/me', $user);
@ -50,7 +52,7 @@ test('update profile', function () {
$this->assertDatabaseHas('users', [
'name' => $user['name'],
'email' => $user['email']
'email' => $user['email'],
]);
});
@ -71,7 +73,7 @@ test('update company', function () {
'address_street_1' => 'test1',
'address_street_2' => 'test2',
'phone' => '1234567890',
'zip' => '112233'
'zip' => '112233',
];
$response = putJson('api/v1/company', $company);
@ -79,7 +81,7 @@ test('update company', function () {
$response->assertOk();
$this->assertDatabaseHas('companies', [
'name' => $company['name']
'name' => $company['name'],
]);
$this->assertDatabaseHas('addresses', [
@ -89,13 +91,13 @@ test('update company', function () {
'address_street_1' => $company['address_street_1'],
'address_street_2' => $company['address_street_2'],
'phone' => $company['phone'],
'zip' => $company['zip']
'zip' => $company['zip'],
]);
});
test('update settings', function () {
$settings = [
'currency'=> 1,
'currency' => 1,
'time_zone' => 'Asia/Kolkata',
'language' => 'en',
'fiscal_year' => '1-12',
@ -105,20 +107,20 @@ test('update settings', function () {
'notify_invoice_viewed' => 'YES',
'notify_estimate_viewed' => 'YES',
'tax_per_item' => 'YES',
'discount_per_item' => 'YES'
'discount_per_item' => 'YES',
];
$response = postJson('/api/v1/company/settings', ['settings' => $settings]);
$response->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
foreach ($settings as $key => $value) {
$this->assertDatabaseHas('company_settings', [
'option' => $key,
'value' => $value
'value' => $value,
]);
}
});
@ -135,7 +137,7 @@ test('get notification email settings', function () {
'notify_invoice_viewed',
'notify_estimate_viewed',
'tax_per_item',
'discount_per_item'
'discount_per_item',
];
$response = getJson('/api/v1/company/settings?'.http_build_query($data));

View File

@ -1,12 +1,15 @@
<?php
use Crater\Models\User;
use Crater\Http\Controllers\V1\CustomField\CustomFieldsController;
use Crater\Http\Requests\CustomFieldRequest;
use Crater\Models\CustomField;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\CustomFieldRequest;
use Crater\Http\Controllers\V1\CustomField\CustomFieldsController;
use function Pest\Laravel\{postJson, putJson, getJson, deleteJson};
use function Pest\Laravel\deleteJson;
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -34,7 +37,7 @@ test('create custom field', function () {
postJson('api/v1/custom-fields', $data)
->assertStatus(200)
->assertJson([
'success' => true
'success' => true,
]);
$this->assertDatabaseHas('custom_fields', [
@ -42,7 +45,7 @@ test('create custom field', function () {
'label' => $data['label'],
'type' => $data['type'],
'model_type' => $data['model_type'],
'is_required' => $data['is_required']
'is_required' => $data['is_required'],
]);
});
@ -58,13 +61,13 @@ test('update custom field', function () {
$customField = CustomField::factory()->create();
$newCustomField = CustomField::factory()->raw([
'is_required' => false
'is_required' => false,
]);
putJson('api/v1/custom-fields/' . $customField->id, $newCustomField)
putJson('api/v1/custom-fields/'.$customField->id, $newCustomField)
->assertStatus(200)
->assertJson([
'success' => true
'success' => true,
]);
$this->assertDatabaseHas('custom_fields', [
@ -87,12 +90,12 @@ test('update validates using a form request', function () {
test('delete custom field', function () {
$customField = CustomField::factory()->create();
$response = deleteJson('api/v1/custom-fields/' . $customField->id);
$response = deleteJson('api/v1/custom-fields/'.$customField->id);
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
$this->assertDeleted($customField);

View File

@ -1,12 +1,14 @@
<?php
use Crater\Models\User;
use Crater\Http\Controllers\V1\Customer\CustomersController;
use Crater\Http\Requests\CustomerRequest;
use Crater\Models\Invoice;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\CustomerRequest;
use Crater\Http\Controllers\V1\Customer\CustomersController;
use function Pest\Laravel\{postJson, putJson, getJson};
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -30,11 +32,11 @@ test('get customers', function () {
test('customer stats', function () {
$customer = User::factory()->create([
'role' => 'customer'
'role' => 'customer',
]);
$invoice = Invoice::factory()->create([
'user_id' => $customer->id
'user_id' => $customer->id,
]);
$response = getJson("api/v1/customers/{$customer->id}/stats");
@ -45,7 +47,7 @@ test('customer stats', function () {
test('create customer', function () {
$customer = User::factory()->raw([
'password' => 'secret',
'role' => 'customer'
'role' => 'customer',
]);
$response = postJson('api/v1/customers', $customer);
@ -54,13 +56,13 @@ test('create customer', function () {
'name' => $customer['name'],
'email' => $customer['email'],
'role' => $customer['role'],
'company_id' => $customer['company_id']
'company_id' => $customer['company_id'],
]);
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
});
@ -74,7 +76,7 @@ test('store validates using a form request', function () {
test('get customer', function () {
$customer = User::factory()->create([
'role' => 'customer'
'role' => 'customer',
]);
$response = getJson("api/v1/customers/{$customer->id}");
@ -84,7 +86,7 @@ test('get customer', function () {
'name' => $customer['name'],
'email' => $customer['email'],
'role' => $customer['role'],
'company_id' => $customer['company_id']
'company_id' => $customer['company_id'],
]);
$response->assertOk();
@ -92,28 +94,28 @@ test('get customer', function () {
test('update customer', function () {
$customer = User::factory()->create([
'role' => 'customer'
]);
$customer1 = User::factory()->raw([
'role' => 'customer',
'name' => 'new name'
]);
$response = putJson('api/v1/customers/' . $customer->id, $customer1);
$customer1 = User::factory()->raw([
'role' => 'customer',
'name' => 'new name',
]);
$response = putJson('api/v1/customers/'.$customer->id, $customer1);
$this->assertDatabaseHas('users', [
'id' => $customer->id,
'name' => $customer1['name'],
'email' => $customer1['email'],
'role' => $customer1['role'],
'company_id' => $customer1['company_id']
'company_id' => $customer1['company_id'],
]);
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
});
@ -130,25 +132,25 @@ test('search customers', function () {
'page' => 1,
'limit' => 15,
'search' => 'doe',
'email' => '.com'
'email' => '.com',
];
$queryString = http_build_query($filters, '', '&');
$response = getJson('api/v1/customers?' . $queryString);
$response = getJson('api/v1/customers?'.$queryString);
$response->assertOk();
});
test('delete multiple customer', function () {
$customers = User::factory()->count(4)->create([
'role' => 'customer'
'role' => 'customer',
]);
$ids = $customers->pluck('id');
$data = [
'ids' => $ids
'ids' => $ids,
];
$response = postJson('api/v1/customers/delete', $data);
@ -156,6 +158,6 @@ test('delete multiple customer', function () {
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
});

View File

@ -1,4 +1,5 @@
<?php
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;

View File

@ -1,19 +1,21 @@
<?php
use Crater\Models\User;
use Crater\Models\Estimate;
use Crater\Models\EstimateItem;
use Crater\Models\Tax;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\EstimatesRequest;
use Crater\Http\Controllers\V1\Estimate\EstimatesController;
use Crater\Http\Controllers\V1\Estimate\SendEstimateController;
use Crater\Http\Requests\DeleteEstimatesRequest;
use Crater\Http\Requests\EstimatesRequest;
use Crater\Http\Requests\SendEstimatesRequest;
use Crater\Mail\SendEstimateMail;
use Crater\Models\Estimate;
use Crater\Models\EstimateItem;
use Crater\Models\Tax;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use function Pest\Laravel\{postJson, putJson, getJson};
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -38,10 +40,10 @@ test('get estimates', function () {
test('create estimate', function () {
$estimate = Estimate::factory()->raw([
'items' => [
EstimateItem::factory()->raw()
EstimateItem::factory()->raw(),
],
'taxes' => [
Tax::factory()->raw()
Tax::factory()->raw(),
],
]);
@ -81,16 +83,16 @@ test('update estimate', function () {
$estimate2 = Estimate::factory()->raw([
'items' => [
EstimateItem::factory()->raw()
EstimateItem::factory()->raw(),
],
'taxes' => [
Tax::factory()->raw([
'tax_type_id' => $estimate->taxes[0]->tax_type_id
])
]
'tax_type_id' => $estimate->taxes[0]->tax_type_id,
]),
],
]);
$response = putJson('api/v1/estimates/' . $estimate->id, $estimate2);
$response = putJson('api/v1/estimates/'.$estimate->id, $estimate2);
$newEstimate = $response->decodeResponseJson()['estimate'];
@ -108,11 +110,11 @@ test('update estimate', function () {
]);
$this->assertDatabaseHas('taxes', [
'estimate_id' => $newEstimate['id']
'estimate_id' => $newEstimate['id'],
]);
$this->assertDatabaseHas('estimate_items', [
'estimate_id' => $newEstimate['id']
'estimate_id' => $newEstimate['id'],
]);
$response->assertStatus(200);
@ -133,12 +135,12 @@ test('search estimates', function () {
'search' => 'doe',
'from_date' => '2020-07-18',
'to_date' => '2020-07-20',
'estimate_number' => '000003'
'estimate_number' => '000003',
];
$queryString = http_build_query($filters, '', '&');
$response = getJson('api/v1/estimates?' . $queryString);
$response = getJson('api/v1/estimates?'.$queryString);
$response->assertStatus(200);
});
@ -163,13 +165,13 @@ test('send estimate to customer', function () {
'subject' => 'test',
'body' => 'test',
'from' => 'john@example.com',
'to' => 'doe@example.com'
'to' => 'doe@example.com',
];
postJson("api/v1/estimates/{$estimate->id}/send", $data)
->assertStatus(200)
->assertJson([
'success' => true
'success' => true,
]);
Mail::assertSent(SendEstimateMail::class);
@ -182,7 +184,7 @@ test('estimate mark as accepted', function () {
]);
$data = [
'status' => Estimate::STATUS_ACCEPTED
'status' => Estimate::STATUS_ACCEPTED,
];
$response = postJson("api/v1/estimates/{$estimate->id}/status", $data);
@ -190,7 +192,7 @@ test('estimate mark as accepted', function () {
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
$estimate2 = Estimate::find($estimate->id);
@ -204,7 +206,7 @@ test('estimate mark as rejected', function () {
]);
$data = [
'status' => Estimate::STATUS_REJECTED
'status' => Estimate::STATUS_REJECTED,
];
$response = postJson("api/v1/estimates/{$estimate->id}/status", $data);
@ -212,7 +214,7 @@ test('estimate mark as rejected', function () {
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
$estimate2 = Estimate::find($estimate->id);
@ -248,7 +250,7 @@ test('delete multiple estimates', function () {
$ids = $estimates->pluck('id');
$data = [
'ids' => $ids
'ids' => $ids,
];
$response = postJson('api/v1/estimates/delete', $data);
@ -256,7 +258,7 @@ test('delete multiple estimates', function () {
$response
->assertStatus(200)
->assertJson([
'success' => true
'success' => true,
]);
foreach ($estimates as $estimate) {

View File

@ -1,11 +1,15 @@
<?php
use Crater\Models\User;
use Crater\Http\Controllers\V1\Expense\ExpenseCategoriesController;
use Crater\Http\Requests\ExpenseCategoryRequest;
use Crater\Models\ExpenseCategory;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\ExpenseCategoryRequest;
use Crater\Http\Controllers\V1\Expense\ExpenseCategoriesController;
use function Pest\Laravel\{postJson, putJson, getJson, deleteJson};
use function Pest\Laravel\deleteJson;
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -82,7 +86,7 @@ test('delete category', function () {
deleteJson('api/v1/categories/'.$category->id)
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
$this->assertDeleted($category);

View File

@ -1,12 +1,14 @@
<?php
use Crater\Models\User;
use Crater\Http\Controllers\V1\Expense\ExpensesController;
use Crater\Http\Requests\ExpenseRequest;
use Crater\Models\Expense;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\ExpenseRequest;
use Crater\Http\Controllers\V1\Expense\ExpensesController;
use function Pest\Laravel\{postJson, putJson, getJson, deleteJson};
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -48,7 +50,7 @@ test('store validates using a form request', function () {
test('get expense data', function () {
$expense = Expense::factory()->create([
'expense_date' => '2019-02-05'
'expense_date' => '2019-02-05',
]);
getJson("api/v1/expenses/{$expense->id}")->assertOk();
@ -63,12 +65,12 @@ test('get expense data', function () {
test('update expense', function () {
$expense = Expense::factory()->create([
'expense_date' => '2019-02-05'
'expense_date' => '2019-02-05',
]);
$expense2 = Expense::factory()->raw();
putJson('api/v1/expenses/' . $expense->id, $expense2)->assertOk();
putJson('api/v1/expenses/'.$expense->id, $expense2)->assertOk();
$this->assertDatabaseHas('expenses', [
'id' => $expense->id,
@ -93,23 +95,23 @@ test('search expenses', function () {
'expense_category_id' => 1,
'search' => 'cate',
'from_date' => '2020-07-18',
'to_date' => '2020-07-20'
'to_date' => '2020-07-20',
];
$queryString = http_build_query($filters, '', '&');
$response = getJson('api/v1/expenses?' . $queryString);
$response = getJson('api/v1/expenses?'.$queryString);
$response->assertOk();
});
test('delete multiple expenses', function () {
$expenses = Expense::factory()->count(3)->create([
'expense_date' => '2019-02-05'
'expense_date' => '2019-02-05',
]);
$data = [
'ids' => $expenses->pluck('id')
'ids' => $expenses->pluck('id'),
];
$response = postJson('api/v1/expenses/delete', $data);
@ -117,7 +119,7 @@ test('delete multiple expenses', function () {
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
foreach ($expenses as $expense) {

View File

@ -1,10 +1,12 @@
<?php
use Crater\Models\User;
use Crater\Models\FileDisk;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use function Pest\Laravel\{postJson, putJson, getJson};
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);

View File

@ -1,16 +1,18 @@
<?php
use Crater\Models\User;
use Crater\Http\Controllers\V1\Invoice\InvoicesController;
use Crater\Http\Requests\InvoicesRequest;
use Crater\Mail\SendInvoiceMail;
use Crater\Models\Invoice;
use Crater\Models\InvoiceItem;
use Crater\Models\Tax;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\InvoicesRequest;
use Crater\Http\Controllers\V1\Invoice\InvoicesController;
use Crater\Mail\SendInvoiceMail;
use function Pest\Laravel\{postJson, putJson, getJson};
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -36,7 +38,7 @@ test('create invoice', function () {
$invoice = Invoice::factory()
->raw([
'taxes' => [Tax::factory()->raw()],
'items' => [InvoiceItem::factory()->raw()]
'items' => [InvoiceItem::factory()->raw()],
]);
$response = postJson('api/v1/invoices', $invoice);
@ -62,7 +64,7 @@ test('create invoice as sent', function () {
$invoice = Invoice::factory()
->raw([
'taxes' => [Tax::factory()->raw()],
'items' => [InvoiceItem::factory()->raw()]
'items' => [InvoiceItem::factory()->raw()],
]);
$response = postJson('api/v1/invoices', $invoice);
@ -101,10 +103,10 @@ test('update invoice', function () {
$invoice2 = Invoice::factory()
->raw([
'taxes' => [Tax::factory()->raw()],
'items' => [InvoiceItem::factory()->raw()]
'items' => [InvoiceItem::factory()->raw()],
]);
putJson('api/v1/invoices/' . $invoice->id, $invoice2)->assertOk();
putJson('api/v1/invoices/'.$invoice->id, $invoice2)->assertOk();
$this->assertDatabaseHas('invoices', [
'invoice_number' => $invoice2['invoice_number'],
@ -141,15 +143,15 @@ test('send invoice to customer', function () {
'from' => 'john@example.com',
'to' => 'doe@example.com',
'subject' => 'email subject',
'body' => 'email body'
'body' => 'email body',
];
$response = postJson('api/v1/invoices/' . $invoices->id . '/send', $data);
$response = postJson('api/v1/invoices/'.$invoices->id.'/send', $data);
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
$invoice2 = Invoice::find($invoices->id);
@ -165,15 +167,15 @@ test('invoice mark as paid', function () {
]);
$data = [
'status' => Invoice::STATUS_COMPLETED
'status' => Invoice::STATUS_COMPLETED,
];
$response = postJson('api/v1/invoices/' . $invoice->id . '/status', $data);
$response = postJson('api/v1/invoices/'.$invoice->id.'/status', $data);
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
$this->assertEquals(Invoice::find($invoice->id)->paid_status, Invoice::STATUS_PAID);
@ -186,15 +188,15 @@ test('invoice mark as sent', function () {
]);
$data = [
'status' => Invoice::STATUS_SENT
'status' => Invoice::STATUS_SENT,
];
$response = postJson('api/v1/invoices/' . $invoice->id . '/status', $data);
$response = postJson('api/v1/invoices/'.$invoice->id.'/status', $data);
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
$this->assertEquals(Invoice::find($invoice->id)->status, Invoice::STATUS_SENT);
@ -208,12 +210,12 @@ test('search invoices', function () {
'status' => Invoice::STATUS_DRAFT,
'from_date' => '2019-01-20',
'to_date' => '2019-01-27',
'invoice_number' => '000012'
'invoice_number' => '000012',
];
$queryString = http_build_query($filters, '', '&');
$response = getJson('api/v1/invoices?' . $queryString);
$response = getJson('api/v1/invoices?'.$queryString);
$response->assertOk();
});
@ -227,13 +229,13 @@ test('delete multiple invoices', function () {
$ids = $invoices->pluck('id');
$data = [
'ids' => $ids
'ids' => $ids,
];
postJson('api/v1/invoices/delete', $data)
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
foreach ($invoices as $invoice) {
@ -252,6 +254,6 @@ test('clone invoice', function () {
$response
->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
});

View File

@ -1,13 +1,15 @@
<?php
use Crater\Models\User;
use Crater\Http\Controllers\V1\Item\ItemsController;
use Crater\Http\Requests\ItemsRequest;
use Crater\Models\Item;
use Crater\Models\Tax;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\ItemsRequest;
use Crater\Http\Controllers\V1\Item\ItemsController;
use function Pest\Laravel\{postJson, putJson, getJson, deleteJson};
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -33,8 +35,8 @@ test('create item', function () {
$item = Item::factory()->raw([
'taxes' => [
Tax::factory()->raw(),
Tax::factory()->raw()
]
Tax::factory()->raw(),
],
]);
$response = postJson('api/v1/items', $item);
@ -43,7 +45,7 @@ test('create item', function () {
'name' => $item['name'],
'description' => $item['description'],
'price' => $item['price'],
'company_id' => $item['company_id']
'company_id' => $item['company_id'],
]);
$this->assertDatabaseHas('taxes', [
@ -72,7 +74,7 @@ test('get item', function () {
'name' => $item['name'],
'description' => $item['description'],
'price' => $item['price'],
'company_id' => $item['company_id']
'company_id' => $item['company_id'],
]);
});
@ -81,11 +83,11 @@ test('update item', function () {
$update_item = Item::factory()->raw([
'taxes' => [
Tax::factory()->raw()
]
Tax::factory()->raw(),
],
]);
$response = putJson('api/v1/items/' . $item->id, $update_item);
$response = putJson('api/v1/items/'.$item->id, $update_item);
$response->assertOk();
@ -93,7 +95,7 @@ test('update item', function () {
'name' => $update_item['name'],
'description' => $update_item['description'],
'price' => $update_item['price'],
'company_id' => $update_item['company_id']
'company_id' => $update_item['company_id'],
]);
$this->assertDatabaseHas('taxes', [
@ -113,7 +115,7 @@ test('delete multiple items', function () {
$items = Item::factory()->count(5)->create();
$data = [
'ids' => $items->pluck('id')
'ids' => $items->pluck('id'),
];
postJson("/api/v1/items/delete", $data)->assertOk();
@ -129,12 +131,12 @@ test('search items', function () {
'limit' => 15,
'search' => 'doe',
'price' => 6,
'unit' => 'kg'
'unit' => 'kg',
];
$queryString = http_build_query($filters, '', '&');
$response = getJson('api/v1/items?' . $queryString);
$response = getJson('api/v1/items?'.$queryString);
$response->assertOk();
});

View File

@ -22,25 +22,25 @@ beforeEach(function () {
test('next number', function () {
$key = 'invoice';
$response = getJson('api/v1/next-number?key=' . $key);
$response = getJson('api/v1/next-number?key='.$key);
$response->assertStatus(200)->assertJson([
'nextNumber' => '000001'
'nextNumber' => '000001',
]);
$key = 'estimate';
$response = getJson('api/v1/next-number?key=' . $key);
$response = getJson('api/v1/next-number?key='.$key);
$response->assertStatus(200)->assertJson([
'nextNumber' => '000001'
'nextNumber' => '000001',
]);
$key = 'payment';
$response = getJson('api/v1/next-number?key=' . $key);
$response = getJson('api/v1/next-number?key='.$key);
$response->assertStatus(200)->assertJson([
'nextNumber' => '000001'
'nextNumber' => '000001',
]);
});

View File

@ -4,7 +4,10 @@ use Crater\Models\Note;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use function Pest\Laravel\{getJson, postJson, putJson, deleteJson};
use function Pest\Laravel\deleteJson;
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -38,7 +41,7 @@ test('retrieve note', function () {
getJson("/api/v1/notes/{$note->id}")
->assertStatus(200)
->assertJson([
'note' => $note->toArray()
'note' => $note->toArray(),
]);
});
@ -59,7 +62,7 @@ test('delete note', function () {
deleteJson("/api/v1/notes/{$note->id}")
->assertStatus(200)
->assertJson([
'success' => true
'success' => true,
]);
$this->assertDeleted($note);

View File

@ -1,12 +1,15 @@
<?php
use Crater\Models\User;
use Crater\Http\Controllers\V1\Payment\PaymentMethodsController;
use Crater\Http\Requests\PaymentMethodRequest;
use Crater\Models\PaymentMethod;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\PaymentMethodRequest;
use Crater\Http\Controllers\V1\Payment\PaymentMethodsController;
use function Pest\Laravel\{postJson, putJson, getJson, deleteJson};
use function Pest\Laravel\deleteJson;
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -42,7 +45,7 @@ test('create payment method', function () {
$this->assertDatabaseHas('payment_methods', [
'name' => $data['name'],
'company_id' => $data['company_id']
'company_id' => $data['company_id'],
]);
});
@ -72,7 +75,7 @@ test('update payment method', function () {
$method = PaymentMethod::factory()->create();
$data = [
'name' => 'updated name'
'name' => 'updated name',
];
$response = putJson("api/v1/payment-methods/{$method->id}", $data);
@ -81,7 +84,7 @@ test('update payment method', function () {
$this->assertDatabaseHas('payment_methods', [
'id' => $method->id,
'name' => $data['name']
'name' => $data['name'],
]);
});
@ -96,7 +99,7 @@ test('update validates using a form request', function () {
test('delete payment method', function () {
$method = PaymentMethod::factory()->create();
$response = deleteJson('api/v1/payment-methods/' . $method->id);
$response = deleteJson('api/v1/payment-methods/'.$method->id);
$response->assertOk();

View File

@ -1,15 +1,17 @@
<?php
use Crater\Models\User;
use Crater\Http\Controllers\V1\Payment\PaymentsController;
use Crater\Http\Requests\PaymentRequest;
use Crater\Mail\SendPaymentMail;
use Crater\Models\Invoice;
use Crater\Models\Payment;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\PaymentRequest;
use Crater\Http\Controllers\V1\Payment\PaymentsController;
use Crater\Mail\SendPaymentMail;
use function Pest\Laravel\{postJson, putJson, getJson, deleteJson};
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -41,12 +43,12 @@ test('get payment', function () {
test('create payment', function () {
$invoice = Invoice::factory()->create([
'due_amount' => 100
'due_amount' => 100,
]);
$payment = Payment::factory()->raw([
'invoice_id' => $invoice->id,
'payment_number' => "PAY-000001"
'payment_number' => "PAY-000001",
]);
$response = postJson('api/v1/payments', $payment);
@ -71,7 +73,7 @@ test('store validates using a form request', function () {
test('update payment', function () {
$payment = Payment::factory()->create([
'payment_date' => '1988-08-18'
'payment_date' => '1988-08-18',
]);
$payment2 = Payment::factory()->raw([
@ -104,18 +106,17 @@ test('search payments', function () {
'limit' => 15,
'search' => 'doe',
'payment_number' => 'PAY-000001',
'payment_mode' => 'OTHER'
'payment_mode' => 'OTHER',
];
$queryString = http_build_query($filters, '', '&');
$response = getJson('api/v1/payments?' . $queryString);
$response = getJson('api/v1/payments?'.$queryString);
$response->assertOk();
});
test('send payment to customer', function () {
Mail::fake();
$payment = Payment::factory()->create();
@ -124,13 +125,13 @@ test('send payment to customer', function () {
'subject' => 'test',
'body' => 'test',
'from' => 'john@example.com',
'to' => 'doe@example.com'
'to' => 'doe@example.com',
];
$response = postJson("api/v1/payments/{$payment->id}/send", $data);
$response->assertJson([
'success' => true
'success' => true,
]);
Mail::assertSent(SendPaymentMail::class);
@ -142,12 +143,12 @@ test('delete payment', function () {
$ids = $payments->pluck('id');
$data = [
'ids' => $ids
'ids' => $ids,
];
$response = postJson('api/v1/payments/delete', $data);
$response->assertJson([
'success' => true
'success' => true,
]);
});

View File

@ -1,6 +1,7 @@
<?php
use Crater\Models\User;
use Crater\Models\Company;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use function Pest\Laravel\getJson;
@ -27,9 +28,9 @@ test('get customer sales report', function () {
'to_date' => '2020-07-20',
];
$queryString = http_build_query($filters, '', '&');
$queryString = Company::find(1)->unique_hash . '?' . $queryString;
$queryString = Company::find(1)->unique_hash.'?'.$queryString;
$response = getJson('reports/sales/customers/'. $queryString);
$response = getJson('reports/sales/customers/'.$queryString);
$response->assertOk();
});
@ -42,9 +43,9 @@ test('get item sales report', function () {
'to_date' => '2020-07-20',
];
$queryString = http_build_query($filters, '', '&');
$queryString = Company::find(1)->unique_hash . '?' . $queryString;
$queryString = Company::find(1)->unique_hash.'?'.$queryString;
$response = getJson('reports/sales/items/' . $queryString);
$response = getJson('reports/sales/items/'.$queryString);
$response->assertOk();
});
@ -57,9 +58,9 @@ test('get expenses report', function () {
'to_date' => '2020-07-20',
];
$queryString = http_build_query($filters, '', '&');
$queryString = Company::find(1)->unique_hash . '?' . $queryString;
$queryString = Company::find(1)->unique_hash.'?'.$queryString;
$response = getJson('reports/expenses/' . $queryString);
$response = getJson('reports/expenses/'.$queryString);
$response->assertOk();
});
@ -72,9 +73,9 @@ test('get tax summary', function () {
'to_date' => '2020-07-20',
];
$queryString = http_build_query($filters, '', '&');
$queryString = Company::find(1)->unique_hash . '?' . $queryString;
$queryString = Company::find(1)->unique_hash.'?'.$queryString;
$response = getJson('reports/tax-summary/' . $queryString);
$response = getJson('reports/tax-summary/'.$queryString);
$response->assertOk();
});
@ -87,10 +88,9 @@ test('get profit loss', function () {
'to_date' => '2020-07-20',
];
$queryString = http_build_query($filters, '', '&');
$queryString = Company::find(1)->unique_hash . '?' . $queryString;
$queryString = Company::find(1)->unique_hash.'?'.$queryString;
$response = getJson('reports/profit-loss/' . $queryString);
$response = getJson('reports/profit-loss/'.$queryString);
$response->assertOk();
});

View File

@ -1,13 +1,16 @@
<?php
use Crater\Models\User;
use Crater\Http\Controllers\V1\Settings\TaxTypesController;
use Crater\Http\Requests\TaxTypeRequest;
use Crater\Models\TaxType;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\TaxTypeRequest;
use Crater\Http\Controllers\V1\Settings\TaxTypesController;
use function Pest\Laravel\{postJson, putJson, getJson, deleteJson};
use function Pest\Laravel\deleteJson;
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -48,11 +51,11 @@ test('store validates using a form request', function () {
test('get tax type', function () {
$taxType = TaxType::factory()->create();
$response = getJson('api/v1/tax-types/' . $taxType->id);
$response = getJson('api/v1/tax-types/'.$taxType->id);
$response->assertOk()
->assertJson([
'taxType' => $taxType->toArray()
'taxType' => $taxType->toArray(),
]);
});
@ -61,11 +64,11 @@ test('update tax type', function () {
$taxType1 = TaxType::factory()->raw();
$response = putJson('api/v1/tax-types/' . $taxType->id, $taxType1);
$response = putJson('api/v1/tax-types/'.$taxType->id, $taxType1);
$response->assertOk()
->assertJson([
'taxType' => $taxType1
'taxType' => $taxType1,
]);
});
@ -80,11 +83,11 @@ test('update validates using a form request', function () {
test('delete tax type', function () {
$taxType = TaxType::factory()->create();
$response = deleteJson('api/v1/tax-types/' . $taxType->id);
$response = deleteJson('api/v1/tax-types/'.$taxType->id);
$response->assertOk()
->assertJson([
'success' => true
'success' => true,
]);
$this->assertDeleted($taxType);

View File

@ -1,12 +1,15 @@
<?php
use Crater\Models\User;
use Crater\Http\Controllers\V1\Item\UnitsController;
use Crater\Http\Requests\UnitRequest;
use Crater\Models\Unit;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use Crater\Http\Requests\UnitRequest;
use Crater\Http\Controllers\V1\Item\UnitsController;
use function Pest\Laravel\{postJson, putJson, getJson, deleteJson};
use function Pest\Laravel\deleteJson;
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
use function Pest\Laravel\putJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
@ -31,7 +34,7 @@ test('get units', function () {
test('create unit', function () {
$data = [
'name' => 'unit name',
'company_id' => User::find(1)->company_id
'company_id' => User::find(1)->company_id,
];
$response = postJson('api/v1/units', $data);