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

@@ -10,7 +10,7 @@ use Tests\TestCase;
class AppControllerTest extends TestCase
{
/** @test */
public function it_redirects_to_home_when_no_email_exists_in_mailbox()
public function it_redirects_to_home_when_no_email_exists_in_mailbox(): void
{
$response = $this->get('/mailbox');
@@ -18,7 +18,7 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_creates_custom_email_from_url_when_enabled()
public function it_creates_custom_email_from_url_when_enabled(): void
{
$email = 'custom@example.com';
@@ -28,7 +28,7 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_validates_email_parameter_in_mailbox_route()
public function it_validates_email_parameter_in_mailbox_route(): void
{
$response = $this->get('/mailbox/invalid-email');
@@ -37,7 +37,7 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_redirects_to_home_when_mailbox_slug_is_disabled()
public function it_redirects_to_home_when_mailbox_slug_is_disabled(): void
{
Config::set('app.settings.configuration_settings', json_encode([
'disable_mailbox_slug' => true,
@@ -49,7 +49,7 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_switches_email_successfully()
public function it_switches_email_successfully(): void
{
$email = 'newemail@example.com';
@@ -59,7 +59,7 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_redirects_to_home_when_switching_email_with_disabled_mailbox_slug()
public function it_redirects_to_home_when_switching_email_with_disabled_mailbox_slug(): void
{
Config::set('app.settings.configuration_settings', json_encode([
'disable_mailbox_slug' => true,
@@ -73,7 +73,7 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_deletes_email_successfully()
public function it_deletes_email_successfully(): void
{
$email = 'delete@example.com';
@@ -83,7 +83,7 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_redirects_to_home_when_deleting_email_without_parameter()
public function it_redirects_to_home_when_deleting_email_without_parameter(): void
{
$response = $this->get('/delete');
@@ -91,7 +91,7 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_switches_locale_successfully()
public function it_switches_locale_successfully(): void
{
$locale = 'es';
@@ -102,7 +102,7 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_aborts_with_400_for_invalid_locale()
public function it_aborts_with_400_for_invalid_locale(): void
{
$invalidLocale = 'invalid';
@@ -112,7 +112,7 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_redirects_back_after_locale_switch()
public function it_redirects_back_after_locale_switch(): void
{
$locale = 'fr';
@@ -123,12 +123,11 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_handles_get_string_between_method_correctly()
public function it_handles_get_string_between_method_correctly(): void
{
$controller = new AppController;
$reflection = new ReflectionClass($controller);
$method = $reflection->getMethod('getStringBetween');
$method->setAccessible(true);
$string = 'Hello [world] test';
$result = $method->invoke($controller, $string, '[', ']');
@@ -137,12 +136,11 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_handles_get_string_between_with_missing_end()
public function it_handles_get_string_between_with_missing_end(): void
{
$controller = new AppController;
$reflection = new ReflectionClass($controller);
$method = $reflection->getMethod('getStringBetween');
$method->setAccessible(true);
$string = 'Hello [world test';
$result = $method->invoke($controller, $string, '[', ']');
@@ -151,12 +149,11 @@ class AppControllerTest extends TestCase
}
/** @test */
public function it_handles_get_string_between_with_no_match()
public function it_handles_get_string_between_with_no_match(): void
{
$controller = new AppController;
$reflection = new ReflectionClass($controller);
$method = $reflection->getMethod('getStringBetween');
$method->setAccessible(true);
$string = 'Hello world test';
$result = $method->invoke($controller, $string, '[', ']');

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',