jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/330391 )

Change subject: Replace assertTag with assertContains in Entity diff classes
......................................................................


Replace assertTag with assertContains in Entity diff classes

All these assertions are super trivial. They do not do much, just
searching for an HTML element by name and if it does have a specific
content. The "exact" same can be done with a substring search for
"<tag>content</tag>". I'm stripping the start tag and searching for
">content</tag>" because the start tag contains attributes.

Note that this patch is meant as an intermediate step to get rid of
assertTag fast. We still want a proper HTML assertion framework for
this.

Bug: T69122
Change-Id: Ia27b83a51da38bb36abcfd676d895a95d9988c72
---
M repo/tests/phpunit/includes/Diff/EntityContentDiffViewTest.php
M repo/tests/phpunit/includes/Diff/EntityDiffVisualizerTest.php
2 files changed, 47 insertions(+), 47 deletions(-)

Approvals:
  Aleksey Bekh-Ivanov (WMDE): Looks good to me, approved
  jenkins-bot: Verified
  Thiemo Mättig (WMDE): Looks good to me, approved



diff --git a/repo/tests/phpunit/includes/Diff/EntityContentDiffViewTest.php 
b/repo/tests/phpunit/includes/Diff/EntityContentDiffViewTest.php
index f045b76..c8376fd 100644
--- a/repo/tests/phpunit/includes/Diff/EntityContentDiffViewTest.php
+++ b/repo/tests/phpunit/includes/Diff/EntityContentDiffViewTest.php
@@ -65,56 +65,56 @@
                $redirect2 = new EntityRedirect( new ItemId( 'Q11' ), new 
ItemId( 'Q22' ) );
 
                $insTags = array(
-                       'has <td>label / de</td>' => array( 'tag' => 'td', 
'content' => 'label / de' ),
-                       'has <ins>foo</ins>' => array( 'tag' => 'ins', 
'content' => 'foo' ),
-                       'has <td>aliases / nl / 0</td>' => array( 'tag' => 
'td', 'content' => 'aliases / nl / 0' ),
-                       'has <ins>bar</ins>' => array( 'tag' => 'ins', 
'content' => 'bar' ),
-                       'has <td>description / en</td>' => array( 'tag' => 
'td', 'content' => 'description / en' ),
-                       'has <ins>ohi there</ins>' => array( 'tag' => 'ins', 
'content' => 'ohi there' ),
+                       'has <td>label / de</td>' => '>label / de</td>',
+                       'has <ins>foo</ins>' => '>foo</ins>',
+                       'has <td>aliases / nl / 0</td>' => '>aliases / nl / 
0</td>',
+                       'has <ins>bar</ins>' => '>bar</ins>',
+                       'has <td>description / en</td>' => '>description / 
en</td>',
+                       'has <ins>ohi there</ins>' => '>ohi there</ins>',
                );
 
                $delTags = array(
-                       'has <td>label / de</td>' => array( 'tag' => 'td', 
'content' => 'label / de' ),
-                       'has <del>foo</del>' => array( 'tag' => 'del', 
'content' => 'foo' ),
-                       'has <td>aliases / nl / 0</td>' => array( 'tag' => 
'td', 'content' => 'aliases / nl / 0' ),
-                       'has <del>bar</del>' => array( 'tag' => 'del', 
'content' => 'bar' ),
-                       'has <td>description / en</td>' => array( 'tag' => 
'td', 'content' => 'description / en' ),
-                       'has <del>ohi there</del>' => array( 'tag' => 'del', 
'content' => 'ohi there' ),
+                       'has <td>label / de</td>' => '>label / de</td>',
+                       'has <del>foo</del>' => '>foo</del>',
+                       'has <td>aliases / nl / 0</td>' => '>aliases / nl / 
0</td>',
+                       'has <del>bar</del>' => '>bar</del>',
+                       'has <td>description / en</td>' => '>description / 
en</td>',
+                       'has <del>ohi there</del>' => '>ohi there</del>',
                );
 
                $changeTags = array(
-                       'has <td>label / en</td>' => array( 'tag' => 'td', 
'content' => 'label / en' ),
-                       'has <ins>O_o</ins>' => array( 'tag' => 'ins', 
'content' => 'O_o' ),
-                       'has <td>aliases / nl / 0</td>' => array( 'tag' => 
'td', 'content' => 'aliases / nl / 0' ),
-                       'has <ins>daaaah</ins>' => array( 'tag' => 'ins', 
'content' => 'daaaah' ),
-                       'has <td>aliases / nl / 1</td>' => array( 'tag' => 
'td', 'content' => 'aliases / nl / 1' ),
-                       'has <del>foo</del>' => array( 'tag' => 'del', 
'content' => 'foo' ),
-                       'has <td>aliases / nl / 2</td>' => array( 'tag' => 
'td', 'content' => 'aliases / nl / 2' ),
-                       'has <del>bar</del>' => array( 'tag' => 'del', 
'content' => 'bar' ),
-                       'has <td>description / en</td>' => array( 'tag' => 
'td', 'content' => 'description / en' ),
-                       'has <del>ohi there</del>' => array( 'tag' => 'del', 
'content' => 'ohi there' ),
+                       'has <td>label / en</td>' => '>label / en</td>',
+                       'has <ins>O_o</ins>' => '>O_o</ins>',
+                       'has <td>aliases / nl / 0</td>' => '>aliases / nl / 
0</td>',
+                       'has <ins>daaaah</ins>' => '>daaaah</ins>',
+                       'has <td>aliases / nl / 1</td>' => '>aliases / nl / 
1</td>',
+                       'has <del>foo</del>' => '>foo</del>',
+                       'has <td>aliases / nl / 2</td>' => '>aliases / nl / 
2</td>',
+                       'has <del>bar</del>' => '>bar</del>',
+                       'has <td>description / en</td>' => '>description / 
en</td>',
+                       'has <del>ohi there</del>' => '>ohi there</del>',
                );
 
                $fromRedirTags = array(
-                       'has <td>label / de</td>' => array( 'tag' => 'td', 
'content' => 'label / de' ),
-                       'has <ins>foo</ins>' => array( 'tag' => 'ins', 
'content' => 'foo' ),
+                       'has <td>label / de</td>' => '>label / de</td>',
+                       'has <ins>foo</ins>' => '>foo</ins>',
 
-                       'has <td>redirect</td>' => array( 'tag' => 'td', 
'content' => 'redirect' ),
-                       'has <del>Q21</del>' => array( 'tag' => 'del', 
'content' => 'Q21' ),
+                       'has <td>redirect</td>' => '>redirect</td>',
+                       'has <del>Q21</del>' => '>Q21</del>',
                );
 
                $toRedirTags = array(
-                       'has <td>label / de</td>' => array( 'tag' => 'td', 
'content' => 'label / de' ),
-                       'has <del>foo</del>' => array( 'tag' => 'del', 
'content' => 'foo' ),
+                       'has <td>label / de</td>' => '>label / de</td>',
+                       'has <del>foo</del>' => '>foo</del>',
 
-                       'has <td>redirect</td>' => array( 'tag' => 'td', 
'content' => 'redirect' ),
-                       'has <ins>Q21</ins>' => array( 'tag' => 'ins', 
'content' => 'Q21' ),
+                       'has <td>redirect</td>' => '>redirect</td>',
+                       'has <ins>Q21</ins>' => '>Q21</ins>',
                );
 
                $changeRedirTags = array(
-                       'has <td>redirect</td>' => array( 'tag' => 'td', 
'content' => 'redirect' ),
-                       'has <del>Q21</del>' => array( 'tag' => 'del', 
'content' => 'Q21' ),
-                       'has <ins>Q22</del>' => array( 'tag' => 'ins', 
'content' => 'Q22' ),
+                       'has <td>redirect</td>' => '>redirect</td>',
+                       'has <del>Q21</del>' => '>Q21</del>',
+                       'has <ins>Q22</del>' => '>Q22</ins>',
                );
 
                $empty = ItemContent::newFromItem( $emptyItem );
@@ -148,7 +148,7 @@
 
                $this->assertInternalType( 'string', $html );
                foreach ( $matchers as $name => $matcher ) {
-                       $this->assertTag( $matcher, $html, $name );
+                       $this->assertContains( $matcher, $html, $name );
                }
        }
 
diff --git a/repo/tests/phpunit/includes/Diff/EntityDiffVisualizerTest.php 
b/repo/tests/phpunit/includes/Diff/EntityDiffVisualizerTest.php
index b52e7e8..8b8b2b8 100644
--- a/repo/tests/phpunit/includes/Diff/EntityDiffVisualizerTest.php
+++ b/repo/tests/phpunit/includes/Diff/EntityDiffVisualizerTest.php
@@ -59,16 +59,16 @@
                );
 
                $fingerprintTags = array(
-                       'has <td>label / en</td>' => array( 'tag' => 'td', 
'content' => 'label / en' ),
-                       'has <ins>O_o</ins>' => array( 'tag' => 'ins', 
'content' => 'O_o' ),
-                       'has <td>aliases / nl / 0</td>' => array( 'tag' => 
'td', 'content' => 'aliases / nl / 0' ),
-                       'has <ins>daaaah</ins>' => array( 'tag' => 'ins', 
'content' => 'daaaah' ),
-                       'has <td>aliases / nl / 1</td>' => array( 'tag' => 
'td', 'content' => 'aliases / nl / 1' ),
-                       'has <del>foo</del>' => array( 'tag' => 'del', 
'content' => 'foo' ),
-                       'has <td>aliases / nl / 2</td>' => array( 'tag' => 
'td', 'content' => 'aliases / nl / 2' ),
-                       'has <del>bar</del>' => array( 'tag' => 'del', 
'content' => 'bar' ),
-                       'has <td>description / en</td>' => array( 'tag' => 
'td', 'content' => 'description / en' ),
-                       'has <del>ohi there</del>' => array( 'tag' => 'del', 
'content' => 'ohi there' ),
+                       'has <td>label / en</td>' => '>label / en</td>',
+                       'has <ins>O_o</ins>' => '>O_o</ins>',
+                       'has <td>aliases / nl / 0</td>' => '>aliases / nl / 
0</td>',
+                       'has <ins>daaaah</ins>' => '>daaaah</ins>',
+                       'has <td>aliases / nl / 1</td>' => '>aliases / nl / 
1</td>',
+                       'has <del>foo</del>' => '>foo</del>',
+                       'has <td>aliases / nl / 2</td>' => '>aliases / nl / 
2</td>',
+                       'has <del>bar</del>' => '>bar</del>',
+                       'has <td>description / en</td>' => '>description / 
en</td>',
+                       'has <del>ohi there</del>' => '>ohi there</del>',
                );
 
                $redirectDiff = new EntityContentDiff( new EntityDiff(), new 
Diff( array(
@@ -76,8 +76,8 @@
                ), true ) );
 
                $redirectTags = array(
-                       'has <td>redirect</td>' => array( 'tag' => 'td', 
'content' => 'redirect' ),
-                       'has <ins>Q1234</ins>' => array( 'tag' => 'ins', 
'content' => 'Q1234' ),
+                       'has <td>redirect</td>' => '>redirect</td>',
+                       'has <ins>Q1234</ins>' => '>Q1234</ins>',
                );
 
                return array(
@@ -144,7 +144,7 @@
 
                $this->assertInternalType( 'string', $html );
                foreach ( $matchers as $name => $matcher ) {
-                       $this->assertTag( $matcher, $html, $name );
+                       $this->assertContains( $matcher, $html, $name );
                }
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/330391
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia27b83a51da38bb36abcfd676d895a95d9988c72
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aleksey Bekh-Ivanov (WMDE) <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to