chore: code refactor via rector

This commit is contained in:
idevakk
2025-11-14 02:01:01 -08:00
parent 90ab79b3a2
commit ae795880ed
148 changed files with 1520 additions and 1486 deletions

View File

@@ -2,6 +2,8 @@
namespace Tests\Feature\Controllers;
use Carbon\Carbon;
use Exception;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
@@ -35,7 +37,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_rejects_webhook_with_invalid_data_type()
public function it_rejects_webhook_with_invalid_data_type(): void
{
$invalidData = [
'type' => 'invalid_type',
@@ -49,7 +51,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_rejects_webhook_with_missing_data_type()
public function it_rejects_webhook_with_missing_data_type(): void
{
$dataWithoutType = [
'email' => 'test@example.com',
@@ -63,7 +65,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_rejects_webhook_with_no_data()
public function it_rejects_webhook_with_no_data(): void
{
$response = $this->postJson('/webhook/oxapay', []);
@@ -72,7 +74,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_rejects_webhook_with_invalid_hmac_signature()
public function it_rejects_webhook_with_invalid_hmac_signature(): void
{
$validData = [
'type' => 'invoice',
@@ -84,7 +86,7 @@ class WebhookControllerTest extends TestCase
'date' => time(),
];
$postData = json_encode($validData);
json_encode($validData);
$invalidHmac = 'invalid_hmac_signature';
$response = $this->postJson('/webhook/oxapay', $validData, [
@@ -96,7 +98,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_processes_valid_invoice_webhook_successfully()
public function it_processes_valid_invoice_webhook_successfully(): void
{
$validData = [
'type' => 'invoice',
@@ -121,7 +123,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_processes_valid_payment_link_webhook_successfully()
public function it_processes_valid_payment_link_webhook_successfully(): void
{
$validData = [
'type' => 'payment_link',
@@ -146,7 +148,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_processes_valid_payout_webhook_successfully()
public function it_processes_valid_payout_webhook_successfully(): void
{
$validData = [
'type' => 'payout',
@@ -173,7 +175,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_handles_webhook_processing_errors_gracefully()
public function it_handles_webhook_processing_errors_gracefully(): void
{
// Use invalid date format to trigger error handling
$validData = [
@@ -201,7 +203,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_logs_invoice_payment_details_correctly()
public function it_logs_invoice_payment_details_correctly(): void
{
$validData = [
'type' => 'invoice',
@@ -227,7 +229,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_logs_payout_details_correctly()
public function it_logs_payout_details_correctly(): void
{
$validData = [
'type' => 'payout',
@@ -255,7 +257,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_logs_invalid_data_warnings()
public function it_logs_invalid_data_warnings(): void
{
$invalidData = [
'type' => 'invalid_type',
@@ -268,7 +270,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_logs_invalid_hmac_signature_warnings()
public function it_logs_invalid_hmac_signature_warnings(): void
{
$validData = [
'type' => 'invoice',
@@ -276,10 +278,7 @@ class WebhookControllerTest extends TestCase
'amount' => '100',
'currency' => 'USD',
];
$postData = json_encode($validData);
$apiSecretKey = 'test_merchant_key';
$validHmac = hash_hmac('sha512', $postData, $apiSecretKey);
json_encode($validData);
$invalidHmac = 'invalid_hmac';
$response = $this->postJson('/webhook/oxapay', $validData, [
@@ -290,7 +289,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_handles_webhook_processing_exceptions()
public function it_handles_webhook_processing_exceptions(): void
{
$validData = [
'type' => 'invoice',
@@ -311,9 +310,9 @@ class WebhookControllerTest extends TestCase
// Telegram notification for error is handled by error logging
// Simulate an exception during processing by mocking a method that gets called
$this->mock(\Carbon\Carbon::class)
$this->mock(Carbon::class)
->shouldReceive('createFromTimestamp')
->andThrow(new \Exception('Date processing error'));
->andThrow(new Exception('Date processing error'));
$response = $this->postJson('/webhook/oxapay', $validData, [
'HMAC' => $validHmac,
@@ -324,7 +323,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_uses_correct_api_key_based_on_webhook_type()
public function it_uses_correct_api_key_based_on_webhook_type(): void
{
$invoiceData = [
'type' => 'invoice',
@@ -364,7 +363,7 @@ class WebhookControllerTest extends TestCase
}
/** @test */
public function it_handles_missing_optional_fields_gracefully()
public function it_handles_missing_optional_fields_gracefully(): void
{
$minimalData = [
'type' => 'invoice',