Update docs/hooks.txt for ShowSearchHitTitle
[mediawiki.git] / tests / phpunit / includes / GitInfoTest.php
blob89416f2ff28328e48602a8efe1c7c5d79e798c0c
1 <?php
2 /**
3 * @covers GitInfo
4 */
5 class GitInfoTest extends MediaWikiTestCase {
7 protected function setUp() {
8 parent::setUp();
9 $this->setMwGlobals( 'wgGitInfoCacheDirectory', __DIR__ . '/../data/gitinfo' );
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() );
23 public function testValidJsonData() {
24 global $IP;
26 $this->assertValidGitInfo( new GitInfo( "$IP/testValidJsonData") );
27 $this->assertValidGitInfo( new GitInfo( __DIR__ . "/../data/gitinfo/extension" ) );
30 public function testMissingJsonData() {
31 $dir = $GLOBALS['IP'] . '/testMissingJsonData';
32 $fixture = new GitInfo( $dir );
34 $this->assertFalse( $fixture->cacheIsComplete() );
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() );
42 // After calling all the outputs, the cache should be complete
43 $this->assertTrue( $fixture->cacheIsComplete() );