Scriptlog Docs

Scriptlog Documentation

Code reference for the Scriptlog codebase

User Tools

Site Tools


scriptlog:tests:searchapicontrollertest

This is an old revision of the document!


tests/unit/SearchApiControllerTest.php

Source: tests/unit/SearchApiControllerTest.php · 268 lines, ~1284 statements · namespace: (global) · `declare(strict_types=1)`: no


SearchApiControllerTest

Unit tests for lib/controller/api/SearchApiController.php.

Coverage focuses on the two behaviours that fixed the sidebar search widget:

1. generateExcerpt() decodes HTML entities BEFORE stripping tags, so the
   double-encoded post content stored in the DB (e.g. "<p>") never
   leaks raw HTML into the excerpt.
2. buildResponseData() exposes a top-level "total" count that the widget's
   JS reads directly (previously only data.pagination.total_items existed,
   which produced "Found undefined result(s)").

The controller is instantiated without its constructor so the tests do not need a live SearchFinder/PDO connection; the private methods under test use no instance state, so they are invoked via Reflection.

Imports

^ Alias ^ Fully-qualified name ^
| ''TestCase'' | ''PHPUnit\Framework\TestCase'' |
| ''SearchApiController'' | ''Scriptlog\Controller\Api\SearchApiController'' |

Types declared here


Generated by 'tools/gendoc'.

scriptlog/tests/searchapicontrollertest.1790413766.txt.gz · Last modified: by admin