packages/requirements/src/Test/RunnerExtension.php

1<?php
2
3declare(strict_types=1);
4
5namespace Requirements\Test;
6
7/**
8 * Executes one linked test target and reports what actually ran.
9 *
10 * Configuration chooses how a runner executes; definitions choose which target it runs. A
11 * passing result needs the "passed" status and at least one executed test.
12 *
13 * @visibility public
14 *
15 * @example Implementing a runner that knows no targets
16 *     $runner = new class () implements \Requirements\Test\RunnerExtension { public function run(\Requirements\Test\RunnerConfig $config, string $target): \Requirements\Test\TestResult { return new \Requirements\Test\TestResult('error', 0, "Unknown target: $target"); } };
17 *     $runner->run(new \Requirements\Test\RunnerConfig('custom', ['true'], '/'), 'login')->message // => 'Unknown target: login'
18 */
19interface RunnerExtension
20{
21    /**
22     * Runs one test target.
23     *
24     * @param RunnerConfig $config How the runner executes: command, working directory and timeout
25     * @param string $target The test selection written in an item's tests entry
26     *
27     * @return TestResult The status, the number of executed tests and a message on failure
28     */
29    public function run(RunnerConfig $config, string $target): TestResult;
30}
31