X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fchanges%2FRCCacheEntryFactoryTest.php;h=97b4c0887c8f1579909f411178974ba51b5ed373;hb=6f4eda1fd3e4f592c30b4b8a86bac53301eaec9f;hp=ccabab68a90aa4f153999ccea5bd75b0227115cf;hpb=f7429252f85c5835b291def55fc04b8196c1bb39;p=lhc%2Fweb%2Fwiklou.git
diff --git a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
index ccabab68a9..97b4c0887c 100644
--- a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
+++ b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
@@ -69,19 +69,12 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase {
$diff = [ 'curid' => 5, 'diff' => 191, 'oldid' => 190 ];
$cur = [ 'curid' => 5, 'diff' => 0, 'oldid' => 191 ];
- $this->assertQueryLink( 'cur', $cur, $cacheEntry->curlink, 'cur link' );
- $this->assertQueryLink( 'prev', $diff, $cacheEntry->lastlink, 'prev link' );
- $this->assertQueryLink( 'diff', $diff, $cacheEntry->difflink, 'diff link' );
+ $this->assertQueryLink( 'cur', $cur, $cacheEntry->curlink );
+ $this->assertQueryLink( 'prev', $diff, $cacheEntry->lastlink );
+ $this->assertQueryLink( 'diff', $diff, $cacheEntry->difflink );
}
public function testNewForDeleteChange() {
- $expected = [
- 'title' => 'Abc',
- 'user' => 'TestRecentChangesUser',
- 'timestamp' => '21:21',
- 'numberofWatchingusers' => 0,
- 'unpatrolled' => false
- ];
$user = $this->getMutableTestUser()->getUser();
$recentChange = $this->testRecentChangesHelper->makeLogRecentChange(
'delete',
@@ -148,103 +141,69 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase {
$this->assertEquals( 'prev', $cacheEntry->lastlink, 'pref link for delete log or rev' );
}
+ private function assertValidHTML( $actual ) {
+ // Throws if invalid
+ $doc = PHPUnit_Util_XML::load( $actual, /* isHtml */ true );
+ }
+
private function assertUserLinks( $user, $cacheEntry ) {
- $this->assertTag(
- [
- 'tag' => 'a',
- 'attributes' => [
- 'class' => 'new mw-userlink'
- ],
- 'content' => $user
- ],
+ $this->assertValidHTML( $cacheEntry->userlink );
+ $this->assertRegExp(
+ '#^' . $user . '#',
$cacheEntry->userlink,
'verify user link'
);
- $this->assertTag(
- [
- 'tag' => 'span',
- 'attributes' => [
- 'class' => 'mw-usertoollinks'
- ],
- 'child' => [
- 'tag' => 'a',
- 'content' => 'talk',
- ]
- ],
+ $this->assertValidHTML( $cacheEntry->usertalklink );
+ $this->assertRegExp(
+ '#^ \(.*talk.*\)#',
$cacheEntry->usertalklink,
'verify user talk link'
);
- $this->assertTag(
- [
- 'tag' => 'span',
- 'attributes' => [
- 'class' => 'mw-usertoollinks'
- ],
- 'child' => [
- 'tag' => 'a',
- 'content' => 'contribs',
- ]
- ],
+ $this->assertValidHTML( $cacheEntry->usertalklink );
+ $this->assertRegExp(
+ '#^ \(.*contribs.*\)$#',
$cacheEntry->usertalklink,
'verify user tool links'
);
}
private function assertDeleteLogLink( $cacheEntry ) {
- $this->assertTag(
- [
- 'tag' => 'a',
- 'attributes' => [
- 'href' => '/wiki/Special:Log/delete',
- 'title' => 'Special:Log/delete'
- ],
- 'content' => 'Deletion log'
- ],
+ $this->assertEquals(
+ '(Deletion log)',
$cacheEntry->link,
'verify deletion log link'
);
+
+ $this->assertValidHTML( $cacheEntry->link );
}
private function assertRevDel( $cacheEntry ) {
- $this->assertTag(
- [
- 'tag' => 'span',
- 'attributes' => [
- 'class' => 'history-deleted'
- ],
- 'content' => '(username removed)'
- ],
+ $this->assertEquals(
+ ' (username removed)',
$cacheEntry->userlink,
'verify user link for change with deleted revision and user'
);
+ $this->assertValidHTML( $cacheEntry->userlink );
}
private function assertTitleLink( $title, $cacheEntry ) {
- $this->assertTag(
- [
- 'tag' => 'a',
- 'attributes' => [
- 'href' => '/wiki/' . $title,
- 'title' => $title
- ],
- 'content' => $title
- ],
+ $this->assertEquals(
+ '' . $title . '',
$cacheEntry->link,
'verify title link'
);
+ $this->assertValidHTML( $cacheEntry->link );
}
private function assertQueryLink( $content, $params, $link ) {
- $this->assertTag(
- [
- 'tag' => 'a',
- 'content' => $content
- ],
+ $this->assertRegExp(
+ "#^$content$#",
$link,
- 'assert query link element'
+ 'verify query link element'
);
+ $this->assertValidHTML( $link );
foreach ( $params as $key => $value ) {
$this->assertRegExp( '/' . $key . '=' . $value . '/', $link, "verify $key link params" );