Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ByPassfinalsStartedSubscriber
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 notify
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * Fast Forward Development Tools for PHP projects.
7 *
8 * This file is part of fast-forward/dev-tools project.
9 *
10 * @author   Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
11 * @license  https://opensource.org/licenses/MIT MIT License
12 *
13 * @see      https://github.com/php-fast-forward/
14 * @see      https://github.com/php-fast-forward/dev-tools
15 * @see      https://github.com/php-fast-forward/dev-tools/issues
16 * @see      https://php-fast-forward.github.io/dev-tools/
17 * @see      https://datatracker.ietf.org/doc/html/rfc2119
18 */
19
20namespace FastForward\DevTools\PhpUnit\Event\TestSuite;
21
22use DG\BypassFinals;
23use PHPUnit\Event\TestSuite\Started;
24use PHPUnit\Event\TestSuite\StartedSubscriber;
25
26/**
27 * Enables BypassFinals when the PHPUnit test suite starts.
28 *
29 * This subscriber MUST activate BypassFinals as soon as the test suite start
30 * event is emitted so that final classes, final methods, and readonly
31 * protections can be bypassed where the test environment requires that
32 * behavior.
33 *
34 * This subscriber SHALL perform only the activation side effect associated
35 * with the test suite start event.
36 */
37 class ByPassfinalsStartedSubscriber implements StartedSubscriber
38{
39    /**
40     * Handles the PHPUnit test suite started event.
41     *
42     * This method MUST enable BypassFinals for the current test execution
43     * context when the test suite starts.
44     *
45     * @param Started $event the emitted test suite started event
46     *
47     * @return void
48     */
49    public function notify(Started $event): void
50    {
51        BypassFinals::enable();
52    }
53}