コード例 #1
0
 public function setUp()
 {
     $document = new MediaWikiDocument(new SimpleXMLElement($this->documentManyRevisionsXml));
     $contributor = new MediaWikiContributor(json_decode($this->documentManyRevisionsUserJson, true));
     $this->instance = new GitCommitFileRevision($document, 'foo/', '.html');
     $revisionsList = $document->getRevisions();
     for ($revisionsList->rewind(); $revisionsList->valid(); $revisionsList->next()) {
         $rev = $revisionsList->current();
         $rev->setContributor($contributor, false);
     }
     $this->instance->setRevision($document->getLatest());
 }
コード例 #2
0
 /**
  * @covers ::normalize
  */
 public function testNormalize()
 {
     // What the page URL
     $assertions[0][0] = 'WPD:Infrastructure/proposals/Site Map';
     // Desired sanitized URL
     $assertions[0][1] = 'WPD/Infrastructure/proposals/Site_Map';
     // What would be the file name to read/write from
     $assertions[0][2] = 'out/foo/bar/WPD/Infrastructure/proposals/Site_Map/index.bazz';
     $assertions[1][0] = 'WPD:Doc Sprints';
     $assertions[1][1] = 'WPD/Doc_Sprints';
     $assertions[1][2] = 'out/foo/bar/WPD/Doc_Sprints/index.bazz';
     $assertions[2][0] = 'tutorials/What is CSS?';
     $assertions[2][1] = 'tutorials/What_is_CSS';
     $assertions[2][2] = 'out/foo/bar/tutorials/What_is_CSS/index.bazz';
     $assertions[3][0] = 'Tutorials/HTML forms - the basics';
     $assertions[3][1] = 'Tutorials/HTML_forms_-_the_basics';
     $assertions[3][2] = 'out/foo/bar/Tutorials/HTML_forms_-_the_basics/index.bazz';
     $assertions[4][0] = 'ja/concepts/programming/programming basics';
     $assertions[4][1] = 'ja/concepts/programming/programming_basics';
     $assertions[4][2] = 'out/foo/bar/ja/concepts/programming/programming_basics/index.bazz';
     $assertions[5][0] = 'concepts/Internet and Web/the history of the web/tr';
     $assertions[5][1] = 'concepts/Internet_and_Web/the_history_of_the_web/tr';
     $assertions[5][2] = 'out/foo/bar/concepts/Internet_and_Web/the_history_of_the_web/tr.bazz';
     $assertions[6][0] = 'tutorials/Raw WebGL 101 - Part 4: Textures';
     $assertions[6][1] = 'tutorials/Raw_WebGL_101_-_Part_4_Textures';
     $assertions[6][2] = 'out/foo/bar/tutorials/Raw_WebGL_101_-_Part_4_Textures/index.bazz';
     $assertions[7][0] = 'css/selectors/pseudo-classes/:optional';
     $assertions[7][1] = 'css/selectors/pseudo-classes/optional';
     $assertions[7][2] = 'out/foo/bar/css/selectors/pseudo-classes/optional/index.bazz';
     $assertions[8][0] = 'css/selectors/pseudo-classes/:nth-of-type(n)';
     $assertions[8][1] = 'css/selectors/pseudo-classes/nth-of-type';
     $assertions[8][2] = 'out/foo/bar/css/selectors/pseudo-classes/nth-of-type/index.bazz';
     $assertions[9][0] = 'css/selectors/pseudo-classes/:lang(c)';
     $assertions[9][1] = 'css/selectors/pseudo-classes/lang';
     $assertions[9][2] = 'out/foo/bar/css/selectors/pseudo-classes/lang/index.bazz';
     // False positive translated (tr HTML element that happens to conflate with the Turkish language code)
     $assertions[10][0] = 'html/elements/tr';
     $assertions[10][1] = 'html/elements/tr';
     $assertions[10][2] = 'out/foo/bar/html/elements/tr/index.bazz';
     // True positive translated document (Turkish version of the tr HTML element)
     $assertions[11][0] = 'html/elements/tr/tr';
     $assertions[11][1] = 'html/elements/tr/tr';
     $assertions[11][2] = 'out/foo/bar/html/elements/tr/tr.bazz';
     // Please, lets fix those too!!
     $assertions[12][0] = 'html/attributes/align (Table, iframe elements)';
     $assertions[12][1] = 'html/attributes/align_Table_iframe_elements';
     $assertions[12][2] = 'out/foo/bar/html/attributes/align_Table_iframe_elements/index.bazz';
     $mockDocument = '<page>
                 <title>overload me</title>
                 <revision>
                     <id>44</id>
                     <timestamp>2011-08-21T13:21:41Z</timestamp>
                     <contributor>
                         <username>Jdoe</username>
                         <id>42</id>
                     </contributor>
                     <text xml:space="preserve" bytes="20">Use me to overload title element!</text>
                 </revision>
             </page>';
     foreach ($assertions as $assertion) {
         $mock = new SimpleXMLElement($mockDocument);
         $mock->title = $assertion[0];
         // Let’s overload the title for what we want
         $document = new MediaWikiDocument($mock);
         $this->assertSame($assertion[0], $document->getTitle());
         $this->assertSame($assertion[1], $document->getName());
         $file = new GitCommitFileRevision($document, 'out/foo/bar/', '.bazz');
         $this->assertSame($assertion[2], $file->getName());
     }
 }