Merge "Show protection log on creation-protected pages"
[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 protected function assertValidGitInfo( GitInfo $gitInfo ) {
13 $this->assertTrue( $gitInfo->cacheIsComplete() );
14 $this->assertEquals( 'refs/heads/master', $gitInfo->getHead() );
15 $this->assertEquals( '0123456789abcdef0123456789abcdef01234567',
16 $gitInfo->getHeadSHA1() );
17 $this->assertEquals( '1070884800', $gitInfo->getHeadCommitDate() );
18 $this->assertEquals( 'master', $gitInfo->getCurrentBranch() );
19 $this->assertContains( '0123456789abcdef0123456789abcdef01234567',
20 $gitInfo->getHeadViewUrl() );
21 }
22
23 public function testValidJsonData() {
24 global $IP;
25
26 $this->assertValidGitInfo( new GitInfo( "$IP/testValidJsonData" ) );
27 $this->assertValidGitInfo( new GitInfo( __DIR__ . "/../data/gitinfo/extension" ) );
28 }
29
30 public function testMissingJsonData() {
31 $dir = $GLOBALS['IP'] . '/testMissingJsonData';
32 $fixture = new GitInfo( $dir );
33
34 $this->assertFalse( $fixture->cacheIsComplete() );
35
36 $this->assertEquals( false, $fixture->getHead() );
37 $this->assertEquals( false, $fixture->getHeadSHA1() );
38 $this->assertEquals( false, $fixture->getHeadCommitDate() );
39 $this->assertEquals( false, $fixture->getCurrentBranch() );
40 $this->assertEquals( false, $fixture->getHeadViewUrl() );
41
42 // After calling all the outputs, the cache should be complete
43 $this->assertTrue( $fixture->cacheIsComplete() );
44 }
45
46 }