Skip to content

Commit

Permalink
Adding to dev:check, updating shipment test
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrell committed Feb 7, 2025
1 parent 248ad37 commit b5f73af
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
38 changes: 35 additions & 3 deletions app/Console/Commands/PreCommitChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public function handle()
'ide-helper' => false,
'phpstan' => false,
'npm-lint' => false,
'typescript' => false // Renamed from npm-build
'typescript' => false, // Renamed from npm-build
'tests:php' => false,
];

$this->info("Running pre-commit checks and prep");
Expand Down Expand Up @@ -64,14 +65,13 @@ public function handle()
$output .= $buffer;
if (\Symfony\Component\Process\Process::ERR === $type) {
$this->output->write($buffer);
throw new \Exception("Failed to run phpstan via sail");
} else {
$this->output->write($buffer);
}
});
$checks['phpstan'] = str_contains($output, '[OK] No errors');
} catch (\Exception $e) {
$this->comment("Trying to run phpstan directly with php");
$this->comment("Trying to run phpstan directly with php due to error: " . $e->getMessage());

try {
$process = new \Symfony\Component\Process\Process(['php', './vendor/bin/phpstan', 'analyse']);
Expand Down Expand Up @@ -122,6 +122,38 @@ public function handle()
$this->error("Failed to run TypeScript check: " . $e->getMessage()); // Updated error message
}

$this->newLine(2);
$this->info("========== Running tests:php ==========");
try {
$process = new \Symfony\Component\Process\Process(['./vendor/bin/sail', 'pest']);
$process->run(function ($type, $buffer) {
if (\Symfony\Component\Process\Process::ERR === $type) {
$this->output->write($buffer);
} else {
$this->output->write($buffer);
}
});
$checks['tests:php'] = $process->isSuccessful();
} catch (\Exception $e) {
$this->comment("Trying to run pest directly with php due to error: " . $e->getMessage());

try {
$process = new \Symfony\Component\Process\Process(['php', './vendor/bin/pest']);
$output = '';
$process->run(function ($type, $buffer) use (&$output) {
$output .= $buffer;
if (\Symfony\Component\Process\Process::ERR === $type) {
$this->output->write($buffer);
} else {
$this->output->write($buffer);
}
});
$checks['tests:php'] = $process->isSuccessful();
} catch (\Exception $e) {
$this->error("Failed to run pest: " . $e->getMessage());
}
}

$this->newLine(2);
$this->info("========== Completed pre-commit checks and prep ==========");

Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Actions/Organizations/SendInviteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Illuminate\Foundation\Testing\RefreshDatabase;
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
use Illuminate\Support\Carbon;
use Mockery;

uses(RefreshDatabase::class);

Expand Down
21 changes: 7 additions & 14 deletions tests/Unit/Actions/Shipments/CreateShipmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
'stop_type' => 'pickup',
'stop_number' => 1,
'special_instructions' => 'Handle with care',
'reference_numbers' => "['REF123', 'REF456']",
'appointment' => [
'datetime' => now()->addDays(2)->toDateTimeString(),
],
'reference_numbers' => 'REF123,REF456',
'appointment_at' => now()->addDays(2)->toDateTimeString(),
],
];

Expand All @@ -52,10 +50,11 @@
'stop_type' => 'pickup',
'stop_number' => 1,
'special_instructions' => 'Handle with care',
'reference_numbers' => 'REF123,REF456',
])->exists())->toBeTrue();

expect($shipment->stops)->toHaveCount(1)
->first()->appointment->not->toBeNull();
->first()->appointment_at->not->toBeNull();
});

test('it creates shipment with all optional fields', function () {
Expand All @@ -66,9 +65,7 @@
'stop_number' => 1,
'special_instructions' => 'Handle with care',
'reference_numbers' => 'REF123',
'appointment' => [
'datetime' => now()->addDays(2)->toDateTimeString(),
],
'appointment_at' => now()->addDays(2)->toDateTimeString(),
],
];

Expand Down Expand Up @@ -111,19 +108,15 @@
'stop_number' => 1,
'special_instructions' => 'First pickup',
'reference_numbers' => 'REF123',
'appointment' => [
'datetime' => now()->addDays(1)->toDateTimeString(),
],
'appointment_at' => now()->addDays(1)->toDateTimeString(),
],
[
'facility_id' => $delivery->id,
'stop_type' => 'delivery',
'stop_number' => 2,
'special_instructions' => 'Final delivery',
'reference_numbers' => 'REF456',
'appointment' => [
'datetime' => now()->addDays(2)->toDateTimeString(),
],
'appointment_at' => now()->addDays(2)->toDateTimeString(),
],
];

Expand Down

0 comments on commit b5f73af

Please sign in to comment.