Merge "Add an audio file parser test"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 14 Jun 2016 16:46:26 +0000 (16:46 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 14 Jun 2016 16:46:26 +0000 (16:46 +0000)
1  2 
tests/parser/parserTest.inc
tests/parser/parserTests.txt
tests/phpunit/includes/parser/NewParserTest.php

@@@ -342,8 -342,7 +342,8 @@@ class ParserTest 
                $services->resetServiceForTesting( 'TitleFormatter' );
                $services->resetServiceForTesting( 'TitleParser' );
                $services->resetServiceForTesting( '_MediaWikiTitleCodec' );
 -
 +              $services->resetServiceForTesting( 'LinkRenderer' );
 +              $services->resetServiceForTesting( 'LinkRendererFactory' );
        }
  
        public function setupRecorder( $options ) {
                        'wgMaxTocLevel' => $maxtoclevel,
                        'wgCapitalLinks' => true,
                        'wgNoFollowLinks' => true,
 -                      'wgNoFollowDomainExceptions' => [],
 +                      'wgNoFollowDomainExceptions' => [ 'no-nofollow.org' ],
                        'wgThumbnailScriptPath' => false,
                        'wgUseImageResize' => true,
                        'wgSVGConverter' => 'null',
                        'fileExists' => true
                ], $this->db->timestamp( '20010115123500' ), $user );
  
+               $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Audio.oga' ) );
+               $image->recordUpload2( '', 'An awesome hitsong', 'Will it play', [
+                       'size' => 12345,
+                       'width' => 0,
+                       'height' => 0,
+                       'bits' => 0,
+                       'media_type' => MEDIATYPE_AUDIO,
+                       'mime' => 'application/ogg',
+                       'metadata' => serialize( [] ),
+                       'sha1' => Wikimedia\base_convert( '', 16, 36, 31 ),
+                       'fileExists' => true
+               ], $this->db->timestamp( '20010115123500' ), $user );
                # A DjVu file
                $image = wfLocalFile( Title::makeTitle( NS_FILE, 'LoremIpsum.djvu' ) );
                $image->recordUpload2( '', 'Upload a DjVu', 'A DjVu', [
                copy( "$IP/tests/phpunit/data/parser/LoremIpsum.djvu", "$dir/5/5f/LoremIpsum.djvu" );
                wfMkdirParents( $dir . '/0/00', null, __METHOD__ );
                copy( "$IP/tests/phpunit/data/parser/320x240.ogv", "$dir/0/00/Video.ogv" );
+               wfMkdirParents( $dir . '/4/41', null, __METHOD__ );
+               copy( "$IP/tests/phpunit/data/media/say-test.ogg", "$dir/4/41/Audio.oga" );
  
                return;
        }
                                "$dir/thumb/0/00/Video.ogv/270px--Video.ogv.jpg",
                                "$dir/thumb/0/00/Video.ogv/320px-seek=2-Video.ogv.jpg",
                                "$dir/thumb/0/00/Video.ogv/320px-seek=3.3666666666667-Video.ogv.jpg",
+                               "$dir/4/41/Audio.oga",
                        ]
                );
  
                                "$dir/thumb/5/5f",
                                "$dir/thumb/5",
                                "$dir/thumb",
+                               "$dir/4/41",
+                               "$dir/4",
                                "$dir/math/f/a/5",
                                "$dir/math/f/a",
                                "$dir/math/f",
@@@ -2265,17 -2265,6 +2265,17 @@@ Entities inside <pre
  
  !! end
  
 +!! test
 +<nowiki> inside of #tag:pre
 +!! wikitext
 +{{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
 +!! html/php
 +<pre>Foo &#8594;bar</pre>
 +
 +!! html/parsoid
 +<pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:pre","function":"#tag"},"params":{"1":{"wt":"Foo &lt;nowiki>&amp;rarr;bar&lt;/nowiki>"}},"i":0}}]}'>Foo <span typeof="mw:Entity">→</span>bar</pre>
 +!! end
 +
  !! test
  <nowiki> and <pre> preference (first one wins)
  !! wikitext
@@@ -2824,7 -2813,7 +2824,7 @@@ parsoi
  !! wikitext
  {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
  !! html
 -<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>[Main Page bar]</p>
 +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>[Main_Page bar]</p>
  !! end
  
  !! test
@@@ -4782,15 -4771,6 +4782,15 @@@ ok-<a rel="nofollow" class="external fr
  </p>
  !! end
  
 +!! test
 +External links: nofollow domain exception
 +!! wikitext
 +A [https://no-nofollow.org/foobar link], and another [https://example.org link].
 +!! html
 +<p>A <a class="external text" href="https://no-nofollow.org/foobar">link</a>, and another <a rel="nofollow" class="external text" href="https://example.org">link</a>.
 +</p>
 +!!end
 +
  !! test
  External image
  !! wikitext
@@@ -7170,79 -7150,6 +7170,79 @@@ parsoid=
  |}
  !!end
  
 +!! test
 +Testing selser after addition of new row before first row (T125419)
 +!! options
 +parsoid={
 +  "modes": ["wt2wt", "selser"],
 +  "changes": [
 +    [ "tr", "before", "<tr><td>X</td></tr>" ]
 +  ]
 +}
 +!! wikitext
 +{|
 +|a
 +|}
 +!! wikitext/edited
 +{|
 +|X
 +|-
 +|a
 +|}
 +!! end
 +
 +!! test
 +Serialize new table rows in a HTML table using HTML tags
 +!! options
 +parsoid={
 +  "modes": ["wt2wt", "selser"],
 +  "changes": [
 +    [ "tr", "before", "<tr><td>X</td></tr>" ]
 +  ]
 +}
 +!! wikitext
 +<table><tr><td>a</td></tr></table>
 +!! wikitext/edited
 +<table><tr><td>X</td></tr><tr><td>a</td></tr></table>
 +!! end
 +
 +!! test
 +Serialize new table cells in a HTML row using HTML tags
 +!! options
 +parsoid={
 +  "modes": ["wt2wt", "selser"],
 +  "changes": [
 +    [ "td", "before", "<td>X</td>" ]
 +  ]
 +}
 +!! wikitext
 +<table><tr><td>a</td></tr></table>
 +!! wikitext/edited
 +<table><tr><td>X</td><td>a</td></tr></table>
 +!! end
 +
 +!! test
 +Wikitext tables can be nested inside HTML tables
 +!! options
 +parsoid=html2wt
 +!! html
 +<table data-parsoid='{"stx":"html"}'>
 +<tr><td>
 +<table>
 +<tr><td>foo</td></tr>
 +</table>
 +</td></tr>
 +</table>
 +!! wikitext
 +<table>
 +<tr><td>
 +{|
 +|foo
 +|}
 +</td></tr>
 +</table>
 +!! end
 +
  ###
  ### Internal links
  ###
@@@ -7573,7 -7480,7 +7573,7 @@@ Example for such a section: == < =
  <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
  </p>
  !! html/parsoid
 -<p><a rel="mw:WikiLink" href="./Main%20Page#%3C" title="Main Page">#&lt;</a><a rel="mw:WikiLink" href="./Main%20Page#%3E" title="Main Page">#></a></p>
 +<p><a rel="mw:WikiLink" href="./Main_Page#%3C" title="Main Page">#&lt;</a><a rel="mw:WikiLink" href="./Main_Page#%3E" title="Main Page">#></a></p>
  !! end
  
  !! test
@@@ -9870,7 -9777,7 +9870,7 @@@ Magic Word: {{NUMBEROFFILES}
  !! wikitext
  {{NUMBEROFFILES}}
  !! html
- <p>6
+ <p>7
  </p>
  !! end
  
@@@ -10024,7 -9931,7 +10024,7 @@@ Parsoid: Page property magic word with 
  !! wikitext
  {{DISPLAYTITLE:''{{PAGENAME}}''}}
  !! html/parsoid
 -<meta property="mw:PageProp/displaytitle" content="Main Page" about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:&#39;&#39;{{PAGENAME}}&#39;&#39;}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"&lt;i data-parsoid=&#39;{\"dsr\":[15,31,2,2]}&#39;>&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}&#39;>Main Page&lt;/span>&lt;/i>"}]]}'/>
 +<meta property="mw:PageProp/displaytitle" content="Main_Page" about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:&#39;&#39;{{PAGENAME}}&#39;&#39;}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"&lt;i data-parsoid=&#39;{\"dsr\":[15,31,2,2]}&#39;>&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}&#39;>Main_Page&lt;/span>&lt;/i>"}]]}'/>
  !! end
  
  !! test
@@@ -13243,7 -13150,7 +13243,7 @@@ Image with link parameter, wgExternalLi
  !! config
  wgExternalLinkTarget='foobar'
  !! html/php
 -<p><a href="http://example.com/" target="foobar" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 +<p><a href="http://example.com/" target="foobar" rel="nofollow noreferrer noopener"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! end
  
@@@ -13277,7 -13184,7 +13277,7 @@@ Image with link parameter, wgExternalLi
  !! config
  wgExternalLinkTarget='foobar'
  !! html/php
 -<p><a href="http://example.com/" title="Title" target="foobar" rel="nofollow"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 +<p><a href="http://example.com/" title="Title" target="foobar" rel="nofollow noreferrer noopener"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! end
  
@@@ -14037,7 -13944,7 +14037,7 @@@ Redirected imag
  !! wikitext
  [[Image:Barfoo.jpg]]
  !! html/php
 -<p><a href="/wiki/File:Barfoo.jpg" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
 +<p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
  </p>
  !! end
  
@@@ -20739,6 -20646,7 +20739,6 @@@ this is not the the titl
  !! html/php
  Screen
  <p>this is not the the title
 -<span class="error"><strong>Warning:</strong> Display title "whatever" was ignored since it is not equivalent to the page's actual title.</span>
  </p>
  !! end
  
@@@ -94,7 -94,7 +94,7 @@@ class NewParserTest extends MediaWikiTe
                $tmpGlobals['wgParserCacheType'] = CACHE_NONE;
                $tmpGlobals['wgCapitalLinks'] = true;
                $tmpGlobals['wgNoFollowLinks'] = true;
 -              $tmpGlobals['wgNoFollowDomainExceptions'] = [];
 +              $tmpGlobals['wgNoFollowDomainExceptions'] = [ 'no-nofollow.org' ];
                $tmpGlobals['wgExternalLinkTarget'] = false;
                $tmpGlobals['wgThumbnailScriptPath'] = false;
                $tmpGlobals['wgUseImageResize'] = true;
                        ], $this->db->timestamp( '20010115123500' ), $user );
                }
  
-               # A DjVu file
+               $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Audio.oga' ) );
+               if ( !$this->db->selectField( 'image', '1', [ 'img_name' => $image->getName() ] ) ) {
+                       $image->recordUpload2( '', 'An awesome hitsong ', 'Will it play', [
+                                       'size'        => 12345,
+                                       'width'       => 0,
+                                       'height'      => 0,
+                                       'bits'        => 0,
+                                       'media_type'  => MEDIATYPE_AUDIO,
+                                       'mime'        => 'application/ogg',
+                                       'metadata'    => serialize( [] ),
+                                       'sha1'        => Wikimedia\base_convert( '', 16, 36, 32 ),
+                                       'fileExists'  => true
+                       ], $this->db->timestamp( '20010115123500' ), $user );
+               }
                # A DjVu file
                $image = wfLocalFile( Title::makeTitle( NS_FILE, 'LoremIpsum.djvu' ) );
                if ( !$this->db->selectField( 'image', '1', [ 'img_name' => $image->getName() ] ) ) {