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,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,
]);
});