<?php

namespace Tests\App\Controllers\Api;

use App\Controllers\Api\PolicyController;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Test\CIUnitTestCase;

class TestablePolicyController extends PolicyController
{
    protected function success($data = null, string $message = 'Success', int $code = ResponseInterface::HTTP_OK)
    {
        return ['data' => $data, 'message' => $message, 'code' => $code];
    }
}

class PolicyControllerTest extends CIUnitTestCase
{
    public function testSchoolPicturePolicyProducesHtml()
    {
        $controller = new TestablePolicyController();
        $response = $controller->schoolPicturePolicy();

        $this->assertSame(ResponseInterface::HTTP_OK, $response['code']);
        $this->assertStringContainsString('<div class="policy-text">', $response['data']['html']);
    }

    public function testSchoolPolicyReturnsMetaAndHtml()
    {
        $controller = new TestablePolicyController();
        $response = $controller->schoolPolicy();

        $this->assertSame(ResponseInterface::HTTP_OK, $response['code']);
        $this->assertArrayHasKey('meta', $response['data']);
        $this->assertArrayHasKey('html', $response['data']);
        $this->assertStringContainsString('<!DOCTYPE html>', $response['data']['html']);
    }
}
