Something went wrong. Try again.
A barebones implementation of an atproto PDS in PHP and Slim Framework 4.
pds php atproto
Something went wrong. Try again.
2.6 kB · 83 lines
PHP
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384<?php
declare(strict_types=1);
namespace Tests\Application\Actions;
use App\Application\Actions\Action;use App\Application\Actions\ActionPayload;use DateTimeImmutable;use Psr\Http\Message\ResponseInterface as Response;use Psr\Log\LoggerInterface;use Tests\TestCase;
class ActionTest extends TestCase{ public function testActionSetsHttpCodeInRespond(): void { $app = $this->getAppInstance(); $container = $app->getContainer(); self::assertNotNull($container); $logger = $container->get(LoggerInterface::class); self::assertInstanceOf(LoggerInterface::class, $logger);
$testAction = new class ($logger) extends Action { public function __construct( LoggerInterface $loggerInterface ) { parent::__construct($loggerInterface); }
public function action(): Response { return $this->respond( new ActionPayload( 202, [ 'willBeDoneAt' => (new DateTimeImmutable())->format(DateTimeImmutable::ATOM) ] ) ); } };
$app->get('/test-action-response-code', $testAction); $request = $this->createRequest('GET', '/test-action-response-code'); $response = $app->handle($request);
$this->assertEquals(202, $response->getStatusCode()); }
public function testActionSetsHttpCodeRespondData(): void { $app = $this->getAppInstance(); $container = $app->getContainer(); self::assertNotNull($container); $logger = $container->get(LoggerInterface::class); $this->assertInstanceOf(LoggerInterface::class, $logger);
$testAction = new class ($logger) extends Action { public function __construct( LoggerInterface $loggerInterface ) { parent::__construct($loggerInterface); }
public function action(): Response { return $this->respondWithData( [ 'willBeDoneAt' => (new DateTimeImmutable())->format(DateTimeImmutable::ATOM) ], 202 ); } };
$app->get('/test-action-response-code', $testAction); $request = $this->createRequest('GET', '/test-action-response-code'); $response = $app->handle($request);
$this->assertEquals(202, $response->getStatusCode()); }}