instances added god may help

This commit is contained in:
2026-02-23 12:58:19 +01:00
parent 25370a1a55
commit 99db252f60
290 changed files with 9858 additions and 4914 deletions

View File

@@ -0,0 +1,56 @@
<?php
namespace MintyPHP\Tests\Service\Scheduler;
use MintyPHP\Service\Scheduler\Handler\UserLifecycleJobHandler;
use MintyPHP\Service\User\UserLifecycleService;
use PHPUnit\Framework\TestCase;
class UserLifecycleJobHandlerTest extends TestCase
{
public function testExecuteReturnsSuccessWithMappedResult(): void
{
$lifecycleService = $this->createMock(UserLifecycleService::class);
$lifecycleService->expects($this->once())
->method('run')
->with(42)
->willReturn([
'ok' => true,
'run_uuid' => 'run-1',
'deactivated_count' => 3,
'deleted_count' => 2,
'skipped_count' => 1,
'duration_ms' => 99,
]);
$handler = new UserLifecycleJobHandler($lifecycleService);
$result = $handler->execute(42);
$this->assertSame('success', $result['status']);
$this->assertNull($result['error_code']);
$this->assertSame('run-1', $result['result']['run_uuid']);
$this->assertSame(3, $result['result']['deactivated_count']);
$this->assertSame(2, $result['result']['deleted_count']);
$this->assertSame(1, $result['result']['skipped_count']);
$this->assertSame(99, $result['result']['duration_ms']);
}
public function testExecuteReturnsSkippedWhenLifecycleLockIsNotAcquired(): void
{
$lifecycleService = $this->createMock(UserLifecycleService::class);
$lifecycleService->expects($this->once())
->method('run')
->with(null)
->willReturn([
'ok' => false,
'error' => 'lock_not_acquired',
]);
$handler = new UserLifecycleJobHandler($lifecycleService);
$result = $handler->execute(null);
$this->assertSame('skipped', $result['status']);
$this->assertSame('lock_not_acquired', $result['error_code']);
}
}