Index: trunk/extensions/CodeReview/CodeReview.php |
— | — | @@ -350,6 +350,7 @@ |
351 | 351 | $wgHooks['UnitTestsList'][] = 'efCodeReviewUnitTests'; |
352 | 352 | |
353 | 353 | function efCodeReviewUnitTests( &$files ) { |
| 354 | + $files[] = dirname( __FILE__ ) . '/tests/CodeReviewApiTest.php'; |
354 | 355 | $files[] = dirname( __FILE__ ) . '/tests/CodeReviewTest.php'; |
355 | 356 | $files[] = dirname( __FILE__ ) . '/tests/DiffHighlighterTest.php'; |
356 | 357 | 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 | +} |