LocalisationCache: try harder to use LCStoreCDB
[lhc/web/wiklou.git] / tests / phpunit / includes / GitInfoTest.php
1 <?php
2 /**
3 * @covers GitInfo
4 */
5 class GitInfoTest extends MediaWikiTestCase {
6
7 protected function setUp() {
8 parent::setUp();
9 $this->setMwGlobals( 'wgGitInfoCacheDirectory', __DIR__ . '/../data/gitinfo' );
10 }
11
12 public function testValidJsonData() {
13 $dir = $GLOBALS['IP'] . DIRECTORY_SEPARATOR . 'testValidJsonData';
14 $fixture = new GitInfo( $dir );
15
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() );
24 }
25
26 public function testMissingJsonData() {
27 $dir = $GLOBALS['IP'] . '/testMissingJsonData';
28 $fixture = new GitInfo( $dir );
29
30 $this->assertFalse( $fixture->cacheIsComplete() );
31
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() );
37
38 // After calling all the outputs, the cache should be complete
39 $this->assertTrue( $fixture->cacheIsComplete() );
40 }
41
42 }