mirror of
https://github.com/crater-invoice/crater.git
synced 2025-12-15 09:52:55 -05:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user