wiki.techinc.nl/tests/phpunit/unit/includes/editpage/Constraint/UnicodeConstraintTest.php
DannyS712 1aa3a1395c Introduce EditConstraint system, migrate unicode check to constraint
This is the start of "Phase 1" of the migration described in
T157658#6191234. For now, only a single constraint, the
requirement that EditPage::$unicodeCheck match the expected
value, is moved to the new system, in the UnicodeConstraint class.

Both the EditConstraintRunner and the new UnicodeConstraint
have 100% test coverage with pure unit tests.

Bug: T157658
Change-Id: I4fc806ec0fd631e265948a59244295eebec691fa
2020-10-20 14:09:26 +00:00

59 lines
1.7 KiB
PHP

<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
use MediaWiki\EditPage\Constraint\IEditConstraint;
use MediaWiki\EditPage\Constraint\UnicodeConstraint;
/**
* Tests the UnicodeConstraint
*
* @author DannyS712
*
* @covers \MediaWiki\EditPage\Constraint\UnicodeConstraint
*/
class UnicodeConstraintTest extends MediaWikiUnitTestCase {
public function testPass() {
$constraint = new UnicodeConstraint( UnicodeConstraint::VALID_UNICODE );
$this->assertSame(
IEditConstraint::CONSTRAINT_PASSED,
$constraint->checkConstraint()
);
$status = $constraint->getLegacyStatus();
$this->assertTrue( $status->isGood() );
}
public function testFailure() {
$constraint = new UnicodeConstraint( 'NotTheCorrectUnicode' );
$this->assertSame(
IEditConstraint::CONSTRAINT_FAILED,
$constraint->checkConstraint()
);
$status = $constraint->getLegacyStatus();
$this->assertFalse( $status->isGood() );
$this->assertSame(
IEditConstraint::AS_UNICODE_NOT_SUPPORTED,
$status->getValue()
);
}
}