aboutsummaryrefslogtreecommitdiffstats
path: root/tests/parser/ParserTestResult.php
blob: be84728987376651b5ca92c1319373b083b3659e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
 * @file
 *
 * @copyright Copyright © 2013, Antoine Musso
 * @copyright Copyright © 2013, Wikimedia Foundation Inc.
 */
use Wikimedia\Parsoid\ParserTests\Test as ParserTest;
use Wikimedia\Parsoid\ParserTests\TestMode as ParserTestMode;

/**
 * Represent the result of a parser test.
 *
 * @since 1.22
 */
class ParserTestResult {
	/** @var ParserTest The test info */
	public $test;
	/** @var ParserTestMode The test mode */
	public $mode;
	/** @var string Text that was expected */
	public $expected;
	/** @var string Actual text rendered */
	public $actual;

	/**
	 * @param ParserTest $test The test info class
	 * @param ParserTestMode $mode The test mode
	 * @param string $expected The normalized expected output
	 * @param string $actual The actual output
	 */
	public function __construct( $test, $mode, $expected, $actual ) {
		$this->test = $test;
		$this->mode = $mode;
		$this->expected = $expected;
		$this->actual = $actual;
	}

	/**
	 * Whether the test passed
	 * @return bool
	 */
	public function isSuccess() {
		return $this->expected === $this->actual;
	}

	public function getDescription() {
		return "{$this->test->testName} [{$this->mode}]";
	}
}