MediaWiki  REL1_24
GitInfoTest.php
Go to the documentation of this file.
00001 <?php
00005 class GitInfoTest extends MediaWikiTestCase {
00006 
00007     protected function setUp() {
00008         parent::setUp();
00009         $this->setMwGlobals( 'wgGitInfoCacheDirectory', __DIR__ . '/../data/gitinfo' );
00010     }
00011 
00012     public function testValidJsonData() {
00013         $dir = $GLOBALS['IP'] . '/testValidJsonData';
00014         $fixture = new GitInfo( $dir );
00015 
00016         $this->assertTrue( $fixture->cacheIsComplete() );
00017         $this->assertEquals( 'refs/heads/master', $fixture->getHead() );
00018         $this->assertEquals( '0123456789abcdef0123456789abcdef01234567',
00019             $fixture->getHeadSHA1() );
00020         $this->assertEquals( '1070884800', $fixture->getHeadCommitDate() );
00021         $this->assertEquals( 'master', $fixture->getCurrentBranch() );
00022         $this->assertContains( '0123456789abcdef0123456789abcdef01234567',
00023             $fixture->getHeadViewUrl() );
00024     }
00025 
00026     public function testMissingJsonData() {
00027         $dir = $GLOBALS['IP'] . '/testMissingJsonData';
00028         $fixture = new GitInfo( $dir );
00029 
00030         $this->assertFalse( $fixture->cacheIsComplete() );
00031 
00032         $this->assertEquals( false, $fixture->getHead() );
00033         $this->assertEquals( false, $fixture->getHeadSHA1() );
00034         $this->assertEquals( false, $fixture->getHeadCommitDate() );
00035         $this->assertEquals( false, $fixture->getCurrentBranch() );
00036         $this->assertEquals( false, $fixture->getHeadViewUrl() );
00037 
00038         // After calling all the outputs, the cache should be complete
00039         $this->assertTrue( $fixture->cacheIsComplete() );
00040     }
00041 
00042 }