File size: 913 Bytes
6773345
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

namespace Tests\Unit;

use App\Domain\Applications\ApplicationService;
use ReflectionClass;
use Tests\TestCase;

class CalendlyWebhookDateTimeTest extends TestCase
{
    public function test_calendly_iso_timestamp_is_normalized_for_database(): void
    {
        $this->assertSame(
            '2026-07-03 13:30:00',
            $this->normalize('2026-07-03T13:30:00.000000Z'),
        );
    }

    public function test_invalid_calendly_timestamp_returns_null(): void
    {
        $this->assertNull($this->normalize('not-a-date'));
    }

    private function normalize(mixed $value): ?string
    {
        $reflection = new ReflectionClass(ApplicationService::class);
        $service = $reflection->newInstanceWithoutConstructor();
        $method = $reflection->getMethod('calendlyDateTimeForDatabase');
        $method->setAccessible(true);

        return $method->invoke($service, $value);
    }
}