http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96135

Revision: 96135
Author:   hashar
Date:     2011-09-02 18:10:51 +0000 (Fri, 02 Sep 2011)
Log Message:
-----------
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

Added Paths:
-----------
    trunk/extensions/CodeReview/tests/CodeReviewApiTest.php

Modified: trunk/extensions/CodeReview/CodeReview.php
===================================================================
--- trunk/extensions/CodeReview/CodeReview.php  2011-09-02 18:00:42 UTC (rev 
96134)
+++ trunk/extensions/CodeReview/CodeReview.php  2011-09-02 18:10:51 UTC (rev 
96135)
@@ -350,6 +350,7 @@
 $wgHooks['UnitTestsList'][] = 'efCodeReviewUnitTests';
 
 function efCodeReviewUnitTests( &$files ) {
+       $files[] = dirname( __FILE__ ) . '/tests/CodeReviewApiTest.php';
        $files[] = dirname( __FILE__ ) . '/tests/CodeReviewTest.php';
        $files[] = dirname( __FILE__ ) . '/tests/DiffHighlighterTest.php';
        return true;

Added: trunk/extensions/CodeReview/tests/CodeReviewApiTest.php
===================================================================
--- trunk/extensions/CodeReview/tests/CodeReviewApiTest.php                     
        (rev 0)
+++ trunk/extensions/CodeReview/tests/CodeReviewApiTest.php     2011-09-02 
18:10:51 UTC (rev 96135)
@@ -0,0 +1,78 @@
+<?php
+
+/**
+ * This should let us test the CodeReview API
+ * Broken as of 2011-09-02
+ */
+class CodeReviewApiTest extends ApiTestCase {
+
+       /** The test repository created by CodeReviewApiTest::createRepo() */
+       private $repo;
+       /** array of common parameters used to query API */
+       private $commonApiData;
+
+       function setUp() {
+               parent::setUp();
+               $this->doLogin();
+               $this->createRepo();
+               $this->commonApiData = array(
+                       'repo' => 'Test',
+                       'format' => 'json',
+               );
+       }
+
+       function tearDown() {
+               parent::tearDown();
+               //TODO:
+               //$this->destroyRepo();
+       }
+
+       private function createRepo() {
+               $dbw = wfGetDB( DB_MASTER );
+               $dbw->insert(
+                       'code_repo',
+                       array(
+                               'repo_name' => 'Test',
+                               'repo_path' => 'somewhere',
+                               'repo_viewvc'   => 'http://example.com/view/',
+                               'repo_bugzilla' => 'http://www.example.com/$1',
+                       ),
+                       __METHOD__
+               );
+               $id = $dbw->insertId();
+
+               $this->repo = CodeRepository::newFromId( $id );
+
+               # Now insert a revision
+               $row = new StdClass();
+               $row->cr_repo_id = $this->repo->getId();
+               $row->cr_id = 777;
+               $row->cr_author = 'hashar';
+               $row->cr_timestamp = '20110731063300';
+               $row->cr_message = 'I am the very first revision of this life';
+               $row->cr_status = '';
+               $row->cr_path = '/trunk/';
+
+               $rev = CodeRevision::newFromRow( $this->repo, $row );
+               $rev->save();
+       }
+
+       /**
+        * @group Broken
+        * Send a backtrace:
+        * MWException: Empty $mTitle in OutputPage::parse
+        * Caused because our wgOut object does not have a title thus a call to
+        * $wgOut->parse() backtrace :b
+        */
+       function testAddInlineComment() {
+               $data = $this->doApiRequest( array(
+                       'action' => 'coderevisionupdate',
+                       'rev' => 777,
+                       'patchline' => 51,
+                       'comment' => 'Awesome comment',
+
+               ) + $this->commonApiData );
+
+               //$this->assertArrayHasKey( 'key', $data );
+       }
+}


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

Reply via email to