Thiemo Mättig (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/328369 )
Change subject: Simplify assertError/assertNoError to not use regular
expressions
......................................................................
Simplify assertError/assertNoError to not use regular expressions
Change-Id: I140a78d93427894b534f9eb2077ab13230c7c85c
---
M repo/tests/phpunit/includes/Specials/SpecialMergeItemsTest.php
M repo/tests/phpunit/includes/Specials/SpecialRedirectEntityTest.php
2 files changed, 18 insertions(+), 16 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/69/328369/1
diff --git a/repo/tests/phpunit/includes/Specials/SpecialMergeItemsTest.php
b/repo/tests/phpunit/includes/Specials/SpecialMergeItemsTest.php
index 0843755..d3a51d9 100644
--- a/repo/tests/phpunit/includes/Specials/SpecialMergeItemsTest.php
+++ b/repo/tests/phpunit/includes/Specials/SpecialMergeItemsTest.php
@@ -283,18 +283,19 @@
return $permissionChecker;
}
+ /**
+ * @param string $error
+ * @param string $html
+ */
private function assertError( $error, $html ) {
- // Match error strings as generated by the ExceptionLocalizer
mock!
- if ( !preg_match( '!<p class="error">\(@(.*?)@\)</p>!', $html,
$m ) ) {
- $this->fail( 'Expected error ' . $error . '. No error
found in page!' );
- }
-
- $this->assertEquals( $error, $m[1], 'Expected error ' . $error
);
+ $this->assertContains( '<p class="error">(@' . $error .
'@)</p>', $html );
}
+ /**
+ * @param string $html
+ */
private function assertNoError( $html ) {
- $pattern = '!<p class="error"!';
- $this->assertNotRegExp( $pattern, $html, 'Expected no error!' );
+ $this->assertNotContains( 'class="error"', $html );
}
public function mergeRequestProvider() {
diff --git a/repo/tests/phpunit/includes/Specials/SpecialRedirectEntityTest.php
b/repo/tests/phpunit/includes/Specials/SpecialRedirectEntityTest.php
index 811b347..98cc24a 100644
--- a/repo/tests/phpunit/includes/Specials/SpecialRedirectEntityTest.php
+++ b/repo/tests/phpunit/includes/Specials/SpecialRedirectEntityTest.php
@@ -243,18 +243,19 @@
return $permissionChecker;
}
+ /**
+ * @param string $error
+ * @param string $html
+ */
private function assertError( $error, $html ) {
- // Match error strings as generated by the ExceptionLocalizer
mock!
- if ( !preg_match( '!<p class="error">\(@(.*?)@\)</p>!', $html,
$m ) ) {
- $this->fail( 'Expected error ' . $error . '. No error
found in page!' );
- }
-
- $this->assertEquals( $error, $m[1], 'Expected error ' . $error
);
+ $this->assertContains( '<p class="error">(@' . $error .
'@)</p>', $html );
}
+ /**
+ * @param string $html
+ */
private function assertNoError( $html ) {
- $pattern = '!<p class="error"!';
- $this->assertNotRegExp( $pattern, $html, 'Expected no error!' );
+ $this->assertNotContains( 'class="error"', $html );
}
public function testRedirectRequest() {
--
To view, visit https://gerrit.wikimedia.org/r/328369
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I140a78d93427894b534f9eb2077ab13230c7c85c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits