Guides

TestExtension extends Extension
in package
implements CompilerPassInterface

FinalYes

Test support for consumers and extensions of phpDocumentor Guides.

Register this extension alongside the regular ones when building the container in a test case. It is not meant for production containers.

load() is empty, so the extension carries no configuration. Its process() method changes three things:

  • makes CommandBus, Parser, Compiler and the phpdoc.guides.output_node_renderer service public, so a test can pull them out of the container directly;
  • defines ClockInterface as a MockClock pinned to 2023-01-01 12:00:00, overriding the NativeClock alias guides-cli registers, so rendered output containing a build date stays comparable against a fixture;
  • registers Monolog's TestHandler as a public service and pushes it onto the Logger, so a test can assert on the records that were logged.

Prerequisites: the container must already define a Monolog Logger service, which phpDocumentor\Guides\Cli\DependencyInjection\ApplicationExtension registers. phpdocumentor/guides itself does not require monolog/monolog; add it to your require-dev if you register the logger yourself.

See docs/developers/extensions/testing.rst for a worked example.

Table of Contents

Interfaces

CompilerPassInterface

Methods

load()  : void
process()  : void

Methods

load()

public load(array<string|int, mixed> $configs, ContainerBuilder $container) : void
Parameters
$configs : array<string|int, mixed>
$container : ContainerBuilder

process()

public process(ContainerBuilder $container) : void
Parameters
$container : ContainerBuilder
On this page

Search results