5 class GitInfoTest
extends MediaWikiTestCase
{
7 protected function setUp() {
9 $this->setMwGlobals( 'wgCacheDirectory', __DIR__
. '/../data' );
12 public function testValidJsonData() {
13 $dir = $GLOBALS['IP'] . '/testValidJsonData';
14 $fixture = new GitInfo( $dir );
16 $this->assertTrue( $fixture->cacheIsComplete() );
17 $this->assertEquals( 'refs/heads/master', $fixture->getHead() );
18 $this->assertEquals( '0123456789abcdef0123456789abcdef01234567',
19 $fixture->getHeadSHA1() );
20 $this->assertEquals( '1070884800', $fixture->getHeadCommitDate() );
21 $this->assertEquals( 'master', $fixture->getCurrentBranch() );
22 $this->assertContains( '0123456789abcdef0123456789abcdef01234567',
23 $fixture->getHeadViewUrl() );
26 public function testMissingJsonData() {
27 $dir = $GLOBALS['IP'] . '/testMissingJsonData';
28 $fixture = new GitInfo( $dir );
30 $this->assertFalse( $fixture->cacheIsComplete() );
32 $this->assertEquals( false, $fixture->getHead() );
33 $this->assertEquals( false, $fixture->getHeadSHA1() );
34 $this->assertEquals( false, $fixture->getHeadCommitDate() );
35 $this->assertEquals( false, $fixture->getCurrentBranch() );
36 $this->assertEquals( false, $fixture->getHeadViewUrl() );
38 // After calling all the outputs, the cache should be complete
39 $this->assertTrue( $fixture->cacheIsComplete() );