Merge "WebInstallerOutput: Apply wfBCP47() to lang attribute"
[mediawiki.git] / tests / phpunit / includes / GitInfoTest.php
blobc3539d0e7d75ac99dbc643ff84d53526501622fc
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 public function testValidJsonData() {
13 $dir = $GLOBALS['IP'] . DIRECTORY_SEPARATOR . '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() );