r95208 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95207‎ | r95208 | r95209 >
Date:15:12, 22 August 2011
Author:kbrown
Status:deferred
Tags:
Comment:
*add rudimentary and probably broken tests for link rewriter function
* remove @ in code per r94726
Modified paths:
  • /trunk/extensions/ArchiveLinks/ArchiveLinksTests.php (added) (history)
  • /trunk/extensions/ArchiveLinks/spider.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArchiveLinks/ArchiveLinksTests.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+class ArchiveLinksTests extends PHPUnit_Framework_TestCase {
 5+ public function testLinksRewrittenCorrectly( ) {
 6+ global $wgArchiveLinksConfig;
 7+
 8+ ArchiveLinks::rewriteLinks( 'http://test.com', 'test.com', &$rewritten_link, array( 'rel' => 'nofollow', 'class' => 'external free' ) );
 9+
 10+ switch ( $wgArchiveLinksConfig['archive_service'] ) {
 11+ case 'local':
 12+ //spider is not fully implmented, until it is we can't test this
 13+ break;
 14+ case 'wikiwix':
 15+ $this->assertEquals( '<a rel="nofollow" class="external free" href="http://test.com">http://test.com</a><sup><small>&#160;' .
 16+ '<a rel="nofollow" href="http://archive.wikiwix.com/cache/?url=http://test.com">[cache]</a></small></sup>',
 17+ $rewritten_link );
 18+ break;
 19+ case 'webcitation':
 20+ $this->assertEquals( '<a rel="nofollow" class="external free" href="http://test.com">http://test.com</a><sup><small>&#160;' .
 21+ '<a rel="nofollow" href="http://webcitation.org/query?url=http://test.com">[cache]</a></small></sup>',
 22+ $rewritten_link );
 23+ break;
 24+ case 'internet_archive':
 25+ default:
 26+ $this->assertEquals( 'http://wayback.archive.org/web/*/test.com',
 27+ $rewritten_link );
 28+ break;
 29+ }
 30+
 31+ //$this->assertRegex( '%%', $rewritten_link );
 32+ }
 33+}
\ No newline at end of file
Property changes on: trunk/extensions/ArchiveLinks/ArchiveLinksTests.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/extensions/ArchiveLinks/spider.php
@@ -312,8 +312,7 @@
313313 * @return array
314314 */
315315 private function parse_wget_log( $log_path, $url ) {
316 - //We have a die statement here, PHP error unnecessary
317 - @$fp = fopen( $log_path, 'r' ) or die( 'can\'t find wget log file to parse' );
 316+ $fp = fopen( $log_path, 'r' ) or die( 'can\'t find wget log file to parse' );
318317
319318 $this->downloaded_files = array ( );
320319

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94726*Changes to spider.php to use wfShellExec instead of shell_exec...kbrown02:51, 17 August 2011

Status & tagging log