r96135 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96134‎ | r96135 | r96136 >
Date:18:10, 2 September 2011
Author:hashar
Status:ok (Comments)
Tags:
Comment:
CodeReview API testing class (broken!!)

I am sending this patch so I can talk about it with other devs. Since
the test is in the 'Broken' group, there it is not harmful.
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/CodeReview/tests/CodeReviewApiTest.php (added) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.php
@@ -350,6 +350,7 @@
351351 $wgHooks['UnitTestsList'][] = 'efCodeReviewUnitTests';
352352
353353 function efCodeReviewUnitTests( &$files ) {
 354+ $files[] = dirname( __FILE__ ) . '/tests/CodeReviewApiTest.php';
354355 $files[] = dirname( __FILE__ ) . '/tests/CodeReviewTest.php';
355356 $files[] = dirname( __FILE__ ) . '/tests/DiffHighlighterTest.php';
356357 return true;
Index: trunk/extensions/CodeReview/tests/CodeReviewApiTest.php
@@ -0,0 +1,78 @@
 2+<?php
 3+
 4+/**
 5+ * This should let us test the CodeReview API
 6+ * Broken as of 2011-09-02
 7+ */
 8+class CodeReviewApiTest extends ApiTestCase {
 9+
 10+ /** The test repository created by CodeReviewApiTest::createRepo() */
 11+ private $repo;
 12+ /** array of common parameters used to query API */
 13+ private $commonApiData;
 14+
 15+ function setUp() {
 16+ parent::setUp();
 17+ $this->doLogin();
 18+ $this->createRepo();
 19+ $this->commonApiData = array(
 20+ 'repo' => 'Test',
 21+ 'format' => 'json',
 22+ );
 23+ }
 24+
 25+ function tearDown() {
 26+ parent::tearDown();
 27+ //TODO:
 28+ //$this->destroyRepo();
 29+ }
 30+
 31+ private function createRepo() {
 32+ $dbw = wfGetDB( DB_MASTER );
 33+ $dbw->insert(
 34+ 'code_repo',
 35+ array(
 36+ 'repo_name' => 'Test',
 37+ 'repo_path' => 'somewhere',
 38+ 'repo_viewvc' => 'http://example.com/view/',
 39+ 'repo_bugzilla' => 'http://www.example.com/$1',
 40+ ),
 41+ __METHOD__
 42+ );
 43+ $id = $dbw->insertId();
 44+
 45+ $this->repo = CodeRepository::newFromId( $id );
 46+
 47+ # Now insert a revision
 48+ $row = new StdClass();
 49+ $row->cr_repo_id = $this->repo->getId();
 50+ $row->cr_id = 777;
 51+ $row->cr_author = 'hashar';
 52+ $row->cr_timestamp = '20110731063300';
 53+ $row->cr_message = 'I am the very first revision of this life';
 54+ $row->cr_status = '';
 55+ $row->cr_path = '/trunk/';
 56+
 57+ $rev = CodeRevision::newFromRow( $this->repo, $row );
 58+ $rev->save();
 59+ }
 60+
 61+ /**
 62+ * @group Broken
 63+ * Send a backtrace:
 64+ * MWException: Empty $mTitle in OutputPage::parse
 65+ * Caused because our wgOut object does not have a title thus a call to
 66+ * $wgOut->parse() backtrace :b
 67+ */
 68+ function testAddInlineComment() {
 69+ $data = $this->doApiRequest( array(
 70+ 'action' => 'coderevisionupdate',
 71+ 'rev' => 777,
 72+ 'patchline' => 51,
 73+ 'comment' => 'Awesome comment',
 74+
 75+ ) + $this->commonApiData );
 76+
 77+ //$this->assertArrayHasKey( 'key', $data );
 78+ }
 79+}

Comments

#Comment by Reedy (talk | contribs)   18:12, 2 September 2011

Missing svn:eol-style native ;)

#Comment by Aaron Schulz (talk | contribs)   18:13, 2 September 2011

Maybe we can have a post-commit hook for .php files for this?

#Comment by Reedy (talk | contribs)   18:50, 2 September 2011

Having reliable syntax checking would be good first ;)

Well, almost any text based file should have it set

#Comment by Tim Starling (talk | contribs)   05:56, 8 December 2011

IAlex fixed it in r96301. He's almost as good as a post-commit hook.

Status & tagging log