Debian Codegraph @

tests/phpunit/unit/includes/editpage/Constraint/EditConstraintTestTrait.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 use MediaWiki\EditPage\Constraint\IEditConstraint;
22
23 /**
24 * Helper for the various constraint test classes
25 *
26 * @author DannyS712
27 */
28 trait EditConstraintTestTrait {
29
30 /**
31 * Assert that the constraint passes and that the status is good
32 * @param IEditConstraint $constraint
33 */
34 public function assertConstraintPassed( IEditConstraint $constraint ) {
35 $this->assertSame(
36 IEditConstraint::CONSTRAINT_PASSED,
37 $constraint->checkConstraint()
38 );
39
40 $status = $constraint->getLegacyStatus();
41 $this->assertStatusGood( $status );
42 }
43
44 /**
45 * Assert that the constraint fails with the specified status code
46 * @param IEditConstraint $constraint
47 * @param int $statusCode
48 */
49 public function assertConstraintFailed( IEditConstraint $constraint, int $statusCode ) {
50 $this->assertSame(
51 IEditConstraint::CONSTRAINT_FAILED,
52 $constraint->checkConstraint()
53 );
54
55 $status = $constraint->getLegacyStatus();
56 $this->assertStatusNotGood( $status );
57 $this->assertStatusValue( $statusCode, $status );
58 }
59
60 }