MediaWiki REL1_30
GitInfoTest.php
Go to the documentation of this file.
1<?php
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}
$dir
Definition Autoload.php:8
$GLOBALS['wgAutoloadClasses']['LocalisationUpdate']
Definition Autoload.php:10
GitInfo.
assertValidGitInfo(GitInfo $gitInfo)
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
$IP
Definition update.php:3