[MediaWiki-commits] [Gerrit] mediawiki/core[master]: changes: Remove assertTag from RCCacheEntryFactoryTest

2017-03-31 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/345947 )

Change subject: changes: Remove assertTag from RCCacheEntryFactoryTest
..


changes: Remove assertTag from RCCacheEntryFactoryTest

Use PHPUnit's Xml::load() to validate that all tags and attributes
are balanced.

Use simple assertEquals or assertRegexp for the specific parts.

Change-Id: I25796954a3bb9903e88256b8345ef751c767d7d5
---
M tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
1 file changed, 28 insertions(+), 62 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php 
b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
index 4ff1eb8..97b4c08 100644
--- a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
+++ b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
@@ -141,103 +141,69 @@
$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 );
}
 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: changes: Remove assertTag from RCCacheEntryFactoryTest

2017-03-31 Thread Krinkle (Code Review)
Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/345947 )

Change subject: changes: Remove assertTag from RCCacheEntryFactoryTest
..

changes: Remove assertTag from RCCacheEntryFactoryTest

Use PHPUnit's Xml::load() to validate that all tags and attributes
are balanced.

Use simple assertEquals or assertRegexp for the specific parts.

Change-Id: I25796954a3bb9903e88256b8345ef751c767d7d5
---
M tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
1 file changed, 21 insertions(+), 47 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/47/345947/1

diff --git a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php 
b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
index 4ff1eb8..9c6d57c 100644
--- a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
+++ b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
@@ -141,77 +141,51 @@
$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