Table of Contents

tests/api/unit/MediaApiControllerTest.php

Source: tests/api/unit/MediaApiControllerTest.php · 142 lines, ~490 statements · namespace: (global) · `declare(strict_types=1)`: no


MediaApiController Test

Unit tests for Scriptlog\Controller\Api\MediaApiController driven through the subprocess runner (ApiTestCase::runController). Controller actions terminate the process via ApiResponse::send(), so each action runs in an isolated PHP process against the seeded test database.

Auth: MediaApiController declares no constructor, so the inherited ApiController constructor runs with the default requiresAuth=true. Requests must therefore carry a valid API key; upload() additionally requires an admin session (scriptlog_session_login / scriptlog_session_level), which the runner's “session” option populates.

Implementation notes (deviations from the plan table): invalid upload types return 400 (not 422), and unauthenticated uploads are rejected with the generic 401 from the parent constructor. A successful upload writes image files to public/files/pictures/, so it is intentionally not exercised at the unit level to avoid filesystem side effects.

Includes

Mode Target Line
require require_once DIR . '/../ApiTestCase.php'; 25
require require_once DIR . '/../fixtures/ApiDataFixture.php'; 26

Types declared here


Generated by 'tools/gendoc'.