Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ReferenceRelation
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 satisfiedBy
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\WptHarness;
6
7/**
8 * The relation a WPT reftest declares between itself and one of its
9 * references.
10 *
11 * WPT's manifest generator reads exactly two `<link>` relations and
12 * maps them onto the two comparison operators
13 * (`tools/manifest/sourcefile.py::references`):
14 *
15 *     rel_map = {"match": "==", "mismatch": "!="}
16 *
17 * The case values here are those operators, so a serialised relation
18 * reads the same way WPT's own manifest writes it.
19 *
20 * A `mismatch` reference is not a weaker assertion than a `match`
21 * one, it is the opposite assertion: the test must render
22 * *differently* from the reference. That makes mismatch fixtures
23 * uniquely valuable to this harness, which renders both sides with
24 * its own engine — an unimplemented feature blanks the test and the
25 * reference alike, and two blank pages are identical, so a mismatch
26 * fixture correctly FAILS where a match fixture would falsely pass.
27 */
28enum ReferenceRelation: string
29{
30    case Match = '==';
31    case Mismatch = '!=';
32
33    /**
34     * Turn the frame comparison into a verdict for this relation.
35     *
36     * `$framesMatched` is "the two screenshots are equal within
37     * whatever tolerance applies" — wptrunner's `equal` local in
38     * `executors/base.py::check_pass`, which then returns
39     * `False if relation == "==" else True` on inequality. The
40     * tolerance question is settled before this is called; all that
41     * happens here is the sign.
42     */
43    public function satisfiedBy(bool $framesMatched): bool
44    {
45        return match ($this) {
46            self::Match => $framesMatched,
47            self::Mismatch => !$framesMatched,
48        };
49    }
50}